X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/46f3ffd7fdde386f41020171b5733e55a8e64a85..1ccd4f7141e49707ec82ef1fc39904951250d05c:/src/minwii/synth.py diff --git a/src/minwii/synth.py b/src/minwii/synth.py index c1faee7..6d0034f 100755 --- a/src/minwii/synth.py +++ b/src/minwii/synth.py @@ -7,9 +7,11 @@ $URL$ """ from os.path import realpath, sep, exists from fluidsynth import Synth as FSynth +from fluidsynth import fluid_settings_setnum from log import console, envLogger, eventLogger import pygame import events +from config import SOUND_FONT class Synth(FSynth) : """ @@ -23,14 +25,10 @@ class Synth(FSynth) : FSynth.__init__(self, gain=gain, samplerate=samplerate) if not sfPath : - sfPath = realpath(__file__).split(sep) - sfPath = sfPath[:-1] - sfPath.append('soundfonts') - - sfPath.append('FluidR3_GM.sf2') - sfPath = sep.join(sfPath) - + sfPath = SOUND_FONT assert exists(sfPath) + + self._gain = gain self.start() self.fsid = self.sfload(sfPath) @@ -42,6 +40,22 @@ class Synth(FSynth) : console.debug('arrêt du synthétiseur') self.delete() + def gain(self, gain) : + self._gain = gain + fluid_settings_setnum(self.settings, 'synth.gain', self._gain) + + def inc_gain(self, step = 0.1) : + self._gain = self._gain + step + if self._gain > 5 : + self._gain = 5 + self.gain(self._gain) + + def dec_gain(self, step = 0.1) : + self._gain = self._gain - step + if self._gain < 0 : + self._gain = 0 + self.gain(self._gain) + def adjust_octave(self, chan, octave) : ''' Abaisse ou élève les notes de n octave