From: pin Date: Mon, 19 Apr 2010 13:11:44 +0000 (+0000) Subject: envoi des événements NOTEON et NOTEOFF du synthé. X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/commitdiff_plain/dc8216d3cd94fe2a5d89c6e8a4fae5de2f25bc9b?ds=sidebyside;hp=820dda3f2152d653172c5caef86ddf33fb7abc0e envoi des événements NOTEON et NOTEOFF du synthé. doc++ impression « raw » des événements quelconques. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@151 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/event_pprinters.py b/src/app/event_pprinters.py index 679924e..e399583 100755 --- a/src/app/event_pprinters.py +++ b/src/app/event_pprinters.py @@ -11,10 +11,10 @@ import sys self = sys.modules[__name__] def log_NOTEON(e): - return '' + return '%3d %3d %3d' % (e.chan, e.key, e.vel) def log_NOTEOFF(e): - return '' + return '%3d %3d' % (e.chan, e.key) def log_NOTEEND(e): return '' @@ -26,7 +26,7 @@ def log_COLSTATECHANGE(e): (col.index, col.state, tone.midi, tone.name, e.syllabus) def _log_col(e) : - """ formate l'événement + """ formate les événements de colonne COLDOWN, COLUP, COLOVER - etat - index de colonne - hauteur midi @@ -41,7 +41,6 @@ def _log_col(e) : log_COLDOWN = log_COLUP = log_COLOVER = _log_col def log_default(e) : - return '' return str(e) pprinters = {} diff --git a/src/app/log.py b/src/app/log.py index ffcf4c6..f07e3d2 100755 --- a/src/app/log.py +++ b/src/app/log.py @@ -25,7 +25,7 @@ class EventLoggerAdapter(logging.LoggerAdapter) : FORMAT = "%(ticks)-10s %(eventName)-15s %(message)s" def process(self, msg, kwargs) : - pp = pprinters.get(msg.type, lambda e: '') + pp = pprinters.get(msg.type, lambda e: str(e)) extra = {} extra['eventType'] = msg.type extra['eventName'] = eventNames[msg.type] diff --git a/src/app/minwii.py b/src/app/minwii.py index da69dd9..4b23012 100755 --- a/src/app/minwii.py +++ b/src/app/minwii.py @@ -45,7 +45,7 @@ class MinWii(object): self.WT = _WTFacade() def run(self) : - "manage the screen sequence display" + "séquençage de l'affichage des écrans" pygame.display.set_mode(self.screenResolution) pygame.display.set_caption('MinWii') @@ -130,7 +130,7 @@ class MinWii(object): playMode = PLAYING_MODES_DICT[playMode] song = musicXml2Song(songFile) bank, preset = instrumentDescription['bank'], instrumentDescription['preset'] - octave = instrumentDescription.get('octave', 0) + octave = instrumentDescription['octave'] self.synth.adjust_octave(0, octave) self.synth.program_select(0, bank, preset) playingScreen = SongPlayingScreen(self.synth, song, mode=playMode) diff --git a/src/app/synth.py b/src/app/synth.py index 9fb4a3e..71fa126 100755 --- a/src/app/synth.py +++ b/src/app/synth.py @@ -8,6 +8,8 @@ $URL$ from os.path import realpath, sep, exists from fluidsynth import Synth as FSynth from log import console +import pygame +import events class Synth(FSynth) : """ @@ -57,7 +59,11 @@ class Synth(FSynth) : def noteon(self, chan, key, vel): key = key + self._octaveAjusts.get(chan, 0) * 12 FSynth.noteon(self, chan, key, vel) + evt = pygame.event.Event(events.NOTEON, chan=chan, key=key, vel=vel) + pygame.event.post(evt) def noteoff(self, chan, key) : key = key + self._octaveAjusts.get(chan, 0) * 12 FSynth.noteoff(self, chan, key) + evt = pygame.event.Event(events.NOTEOFF, chan=chan, key=key) + pygame.event.post(evt)