From ee24fce216592a13d95977d7d4e3374692fd6924 Mon Sep 17 00:00:00 2001 From: pin Date: Mon, 19 Apr 2010 12:26:21 +0000 Subject: [PATCH] =?utf8?q?doc++=20possibilit=C3=A9=20de=20passer=20en=20pa?= =?utf8?q?ram=C3=A8tre=20un=20fichier=20.sf2=20au=20constructeur=20(non=20?= =?utf8?q?test=C3=A9)=20log=20de=20la=20soundfont=20utilis=C3=A9e=20ajout?= =?utf8?q?=20d'un=20d=C3=A9constructeur=20pour=20arr=C3=AAter=20correcteme?= =?utf8?q?nt=20fluidsynth.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@149 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/app/synth.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/app/synth.py b/src/app/synth.py index fa65638..9fb4a3e 100755 --- a/src/app/synth.py +++ b/src/app/synth.py @@ -7,23 +7,37 @@ $URL$ """ from os.path import realpath, sep, exists from fluidsynth import Synth as FSynth +from log import console class Synth(FSynth) : + """ + Interface fluidsynth avec les adaptations suivantes : + - la soundfont FluidR3_GM.sf2 est chargée par défaut + - le constructeur démarre le synthé + - octaviation + """ - def __init__(self, gain=0.2, samplerate=44100) : + def __init__(self, gain=0.2, samplerate=44100, sfPath='') : FSynth.__init__(self, gain=gain, samplerate=samplerate) - sfPath = realpath(__file__).split(sep) - sfPath = sfPath[:-1] - sfPath.append('soundfonts') + if not sfPath : + sfPath = realpath(__file__).split(sep) + sfPath = sfPath[:-1] + sfPath.append('soundfonts') + + sfPath.append('FluidR3_GM.sf2') + sfPath = sep.join(sfPath) - sfPath.append('FluidR3_GM.sf2') - sfPath = sep.join(sfPath) assert exists(sfPath) self.start() self.fsid = self.sfload(sfPath) self._octaveAjusts = {} + console.info('démarrage du synthétiseur\nsoundfont : %s', sfPath) + + def __del__(self) : + console.info('arrêt du synthétiseur.') + self.delete() def adjust_octave(self, chan, octave) : ''' @@ -47,7 +61,3 @@ class Synth(FSynth) : def noteoff(self, chan, key) : key = key + self._octaveAjusts.get(chan, 0) * 12 FSynth.noteoff(self, chan, key) - - -if __name__ == '__main__' : - initsynth() \ No newline at end of file -- 2.20.1