From c469bfe0b89e42f313651c097ac7bedd5cd0cae6 Mon Sep 17 00:00:00 2001 From: pin Date: Thu, 25 Mar 2010 09:55:30 +0000 Subject: [PATCH] =?utf8?q?ajout=20de=20la=20m=C3=A9thode=20adjust=5Foctave?= =?utf8?q?=20au=20synth=C3=A9=20pour=20corriger=20la=20hauteur=20des=20not?= =?utf8?q?es.?= 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@114 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/app/config.py | 9 ++++++--- src/app/minwii.py | 2 ++ src/app/synth.py | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/app/config.py b/src/app/config.py index 2482512..da0645b 100755 --- a/src/app/config.py +++ b/src/app/config.py @@ -43,7 +43,8 @@ INSTRUMENTS = ( }, {'name' : 'guitare', 'bank' : 0, - 'preset' : 24 + 'preset' : 24, + 'octave' : -1 }, {'name' : 'orgue', 'bank' : 0, @@ -55,7 +56,8 @@ INSTRUMENTS = ( }, {'name' : 'tuba', 'bank' : 0, - 'preset' : 58 + 'preset' : 58, + 'octave' : -2 }, {'name' : 'violon', 'bank' : 0, @@ -63,7 +65,8 @@ INSTRUMENTS = ( }, {'name' : 'violoncelle', 'bank' : 0, - 'preset' : 42 + 'preset' : 42, + 'octave' : -2 }, ) diff --git a/src/app/minwii.py b/src/app/minwii.py index 2e65952..b279000 100755 --- a/src/app/minwii.py +++ b/src/app/minwii.py @@ -54,6 +54,8 @@ class MinWii(object): playMode = PLAYING_MODES_DICT[playMode] song = musicXml2Song(songFile) bank, preset = instrumentDescription['bank'], instrumentDescription['preset'] + octave = instrumentDescription.get('octave', 0) + synth.adjust_octave(0, octave) synth.program_select(0, bank, preset) playingScreen = SongPlayingScreen(synth, song, mode=playMode) playingScreen.run() diff --git a/src/app/synth.py b/src/app/synth.py index a2a0244..fa65638 100755 --- a/src/app/synth.py +++ b/src/app/synth.py @@ -23,6 +23,13 @@ class Synth(FSynth) : self.start() self.fsid = self.sfload(sfPath) + self._octaveAjusts = {} + + def adjust_octave(self, chan, octave) : + ''' + Abaisse ou élève les notes de n octave + ''' + self._octaveAjusts[chan] = octave def sfunload(self, update_midi_preset=0): FSynth.sfunload(self, self.fsid, update_midi_preset=update_midi_preset) @@ -33,7 +40,13 @@ class Synth(FSynth) : def sfont_select(self, chan): FSynth.sfont_select(self, chan, self.fsid) - + def noteon(self, chan, key, vel): + key = key + self._octaveAjusts.get(chan, 0) * 12 + FSynth.noteon(self, chan, key, vel) + + def noteoff(self, chan, key) : + key = key + self._octaveAjusts.get(chan, 0) * 12 + FSynth.noteoff(self, chan, key) if __name__ == '__main__' : -- 2.20.1