make style

This commit is contained in:
Philippe Teuwen 2020-06-10 01:17:49 +02:00
commit b55c186b3a
5 changed files with 22 additions and 20 deletions

6
client/pyscripts/theremin.py Normal file → Executable file
View file

@ -66,7 +66,8 @@ while True:
max_v = v max_v = v
# Recalculate the audio frequency to generate # Recalculate the audio frequency to generate
out_freq = (max_freq - min_freq) * (max_v - v) / (max_v - min_v) + min_freq out_freq = (max_freq - min_freq) * (max_v - v) / (max_v - min_v) \
+ min_freq
# Generate the samples and write them to the soundcard # Generate the samples and write them to the soundcard
sinevs = out_freq / sampling_freq * numpy.pi * 2 sinevs = out_freq / sampling_freq * numpy.pi * 2
@ -75,4 +76,5 @@ while True:
sinev = sinev if sinev < numpy.pi * 2 else sinev - numpy.pi * 2 sinev = sinev if sinev < numpy.pi * 2 else sinev - numpy.pi * 2
i = (i + 1) % sample_buf_size i = (i + 1) % sample_buf_size
if not i: if not i:
stream.write((numpy.sin(sample_buf) * volume).astype(numpy.float32).tobytes()) stream.write((numpy.sin(sample_buf) * volume).
astype(numpy.float32).tobytes())