From: pin Date: Thu, 25 Mar 2010 09:55:30 +0000 (+0000) Subject: ajout de la méthode adjust_octave au synthé pour corriger la hauteur des notes. X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/commitdiff_plain/c469bfe0b89e42f313651c097ac7bedd5cd0cae6?ds=inline ajout de la méthode adjust_octave au synthé pour corriger la hauteur des notes. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@114 fe552daf-6dbe-4428-90eb-1537e0879342 --- 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__' :