]> CRI, Mines Paris - PSL - minwii.git/blobdiff - src/app/synth.py
Ajout des soundfonts
[minwii.git] / src / app / synth.py
diff --git a/src/app/synth.py b/src/app/synth.py
new file mode 100755 (executable)
index 0000000..a2a0244
--- /dev/null
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+"""
+module de wrapping du synthétiseur
+
+$Id$
+$URL$
+"""
+from os.path import realpath, sep, exists
+from  fluidsynth import Synth as FSynth
+
+class Synth(FSynth) :
+    
+    def __init__(self, gain=0.2, samplerate=44100) :
+        FSynth.__init__(self, gain=gain, samplerate=samplerate)
+        
+        sfPath = realpath(__file__).split(sep)
+        sfPath = sfPath[:-1]
+        sfPath.append('soundfonts')
+
+        sfPath.append('FluidR3_GM.sf2')
+        sfPath = sep.join(sfPath)
+        assert exists(sfPath)
+
+        self.start()
+        self.fsid = self.sfload(sfPath)
+    
+    def sfunload(self, update_midi_preset=0):
+        FSynth.sfunload(self, self.fsid, update_midi_preset=update_midi_preset)
+    
+    def program_select(self, chan, bank, preset):
+        FSynth.program_select(self, chan, self.fsid, bank, preset)
+
+    def sfont_select(self, chan):
+        FSynth.sfont_select(self, chan, self.fsid)
+
+        
+
+
+if __name__ == '__main__' :
+    initsynth()
\ No newline at end of file