From 1ccd4f7141e49707ec82ef1fc39904951250d05c Mon Sep 17 00:00:00 2001 From: pin Date: Fri, 24 Jun 2011 14:00:42 +0000 Subject: [PATCH] =?utf8?q?Ajout=20du=20contr=C3=B4le=20du=20gain=20=C3=A0?= =?utf8?q?=20la=20t=C3=A9l=C3=A9commande.?= 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@354 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/app.py | 12 ++++++++---- src/minwii/synth.py | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/minwii/app.py b/src/minwii/app.py index 87c2082..2ac1d72 100755 --- a/src/minwii/app.py +++ b/src/minwii/app.py @@ -71,15 +71,19 @@ class MinWii(object): if self.screen == SCREEN_PLAY : pygame_wiimouse._default_event_cb(wt, id, wmp) - # le bouton Home de la télécommande permet de sortir - # (envoi d'un événement clavier « q ») wm = wmp[0] - if id == self.nwiimotes - 1 and \ - wiiuse.is_just_pressed(wm, wiiuse.button['Home']) : + if id == self.nwiimotes - 1 : + # le bouton Home de la télécommande permet de sortir + # (envoi d'un événement clavier « q ») + if wiiuse.is_just_pressed(wm, wiiuse.button['Home']) : event = pygame.event.Event(pygame.KEYDOWN, key = pygame.K_q, unicode = u'q') pygame.event.post(event) + elif wiiuse.is_just_pressed(wm, wiiuse.button['+']) : + self.synth.inc_gain() + elif wiiuse.is_just_pressed(wm, wiiuse.button['-']) : + self.synth.dec_gain() elif self.screen in (SCREEN_HOME, SCREEN_INSTRUMENTS) : pygame_wiimouse._full_mouse_event_cb(wt, id, wmp) diff --git a/src/minwii/synth.py b/src/minwii/synth.py index f8e8798..6d0034f 100755 --- a/src/minwii/synth.py +++ b/src/minwii/synth.py @@ -7,6 +7,7 @@ $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 @@ -26,6 +27,8 @@ class Synth(FSynth) : if not sfPath : sfPath = SOUND_FONT assert exists(sfPath) + + self._gain = gain self.start() self.fsid = self.sfload(sfPath) @@ -37,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 -- 2.20.1