Spaces:
Running
on
Zero
Running
on
Zero
try fix MidiSynthesizer
Browse files- midi_synthesizer.py +9 -9
midi_synthesizer.py
CHANGED
@@ -11,19 +11,19 @@ class MidiSynthesizer:
|
|
11 |
fl = fluidsynth.Synth(samplerate=float(sample_rate))
|
12 |
sfid = fl.sfload(soundfont_path)
|
13 |
self.devices = [[fl, sfid, False]]
|
14 |
-
self.
|
15 |
|
16 |
def get_fluidsynth(self):
|
17 |
-
|
18 |
-
|
19 |
-
device[2]
|
20 |
-
|
21 |
-
|
22 |
fl = fluidsynth.Synth(samplerate=float(self.sample_rate))
|
23 |
sfid = fl.sfload(self.soundfont_path)
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
def release_fluidsynth(self, device):
|
29 |
device[0].system_reset()
|
|
|
11 |
fl = fluidsynth.Synth(samplerate=float(sample_rate))
|
12 |
sfid = fl.sfload(soundfont_path)
|
13 |
self.devices = [[fl, sfid, False]]
|
14 |
+
self.devices_lock = Lock()
|
15 |
|
16 |
def get_fluidsynth(self):
|
17 |
+
with self.devices_lock:
|
18 |
+
for device in self.devices:
|
19 |
+
if not device[2]:
|
20 |
+
device[2] = True
|
21 |
+
return device
|
22 |
fl = fluidsynth.Synth(samplerate=float(self.sample_rate))
|
23 |
sfid = fl.sfload(self.soundfont_path)
|
24 |
+
device = [fl, sfid, True]
|
25 |
+
self.devices.append(device)
|
26 |
+
return device
|
27 |
|
28 |
def release_fluidsynth(self, device):
|
29 |
device[0].system_reset()
|