skytnt commited on
Commit
bb14020
1 Parent(s): eb69b00

try fix MidiSynthesizer

Browse files
Files changed (1) hide show
  1. 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.file_lock = Lock()
15
 
16
  def get_fluidsynth(self):
17
- for device in self.devices:
18
- if not device[2]:
19
- device[2] = True
20
- return device
21
- with self.file_lock:
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()
 
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()