aboutsummaryrefslogtreecommitdiff
path: root/helpers/mixer.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-17 13:00:29 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-17 13:56:27 +0200
commit75d6cdbac628b57e206cd37808c1d3c7fecbb9eb (patch)
tree2b3633489452cf0a4528fd552bf19f83943a702a /helpers/mixer.py
parent22514f3ae6d4e19537ae5ab6bdb5bc9f99a64f47 (diff)
downloadMusicSampler-75d6cdbac628b57e206cd37808c1d3c7fecbb9eb.tar.gz
MusicSampler-75d6cdbac628b57e206cd37808c1d3c7fecbb9eb.tar.zst
MusicSampler-75d6cdbac628b57e206cd37808c1d3c7fecbb9eb.zip
Add new configurations parameters
Diffstat (limited to 'helpers/mixer.py')
-rw-r--r--helpers/mixer.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/helpers/mixer.py b/helpers/mixer.py
index 9e8179a..d08520a 100644
--- a/helpers/mixer.py
+++ b/helpers/mixer.py
@@ -2,17 +2,28 @@ import sounddevice as sd
2import audioop 2import audioop
3import time 3import time
4 4
5frame_rate = 44100 5from . import Config
6channels = 2 6
7sample_width = 2 7sample_width = Config.sample_width
8def sample_width_to_dtype(sample_width):
9 if sample_width == 1 or sample_width == 2 or sample_width == 4:
10 return 'int' + str(8*sample_width)
11 else:
12 raise "Unknown sample width"
13
14def _latency(latency):
15 if latency == "high" or latency == "low":
16 return latency
17 else:
18 return float(latency)
8 19
9class Mixer: 20class Mixer:
10 def __init__(self): 21 def __init__(self):
11 self.stream = sd.RawOutputStream(samplerate=frame_rate, 22 self.stream = sd.RawOutputStream(samplerate=Config.frame_rate,
12 channels=channels, 23 channels=Config.channels,
13 dtype='int' + str(8*sample_width), # FIXME: ? 24 dtype=sample_width_to_dtype(Config.sample_width),
14 latency="high", 25 latency=_latency(Config.latency),
15 blocksize=5000, 26 blocksize=Config.blocksize,
16 callback=self.play_callback, 27 callback=self.play_callback,
17 ) 28 )
18 self.open_files = [] 29 self.open_files = []