From: pin Date: Thu, 8 Jul 2010 14:31:50 +0000 (+0000) Subject: Impression d'un événement SONGEND à la fin de la chanson. X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/commitdiff_plain/1355364de08e9b941c6fb93cd95ff0df6703dc21?ds=inline Impression d'un événement SONGEND à la fin de la chanson. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@280 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/minwii/event_pprinters.py b/src/minwii/event_pprinters.py index bc5834d..c8b270a 100755 --- a/src/minwii/event_pprinters.py +++ b/src/minwii/event_pprinters.py @@ -18,6 +18,9 @@ def log_NOTEOFF(e): def log_NOTEEND(e): return '' + +def log_SONGEND(e) : + return '' def log_COLSTATECHANGE(e): col = e.column diff --git a/src/minwii/events.py b/src/minwii/events.py index a67a416..877be75 100755 --- a/src/minwii/events.py +++ b/src/minwii/events.py @@ -7,13 +7,16 @@ events = ['NOTEON', 'COLDOWN', 'COLUP', 'COLOVER', - 'COLSTATECHANGE'] + 'COLSTATECHANGE', + 'SONGEND'] eventNames = {} self = modules[__name__] for i, name in enumerate(events) : eventType = pygame.USEREVENT + 1 + i + if eventType >= pygame.NUMEVENTS : + eventType = eventType + 1 eventNames[eventType] = name setattr(self, name, eventType) diff --git a/src/minwii/musicxml.py b/src/minwii/musicxml.py index ff819e1..8bc2508 100755 --- a/src/minwii/musicxml.py +++ b/src/minwii/musicxml.py @@ -140,13 +140,9 @@ class Part(object) : break - def iterNotes(self, indefinitely=True) : + def iterNotes(self) : "exécution de la chanson avec l'alternance couplets / refrains" - if indefinitely == False : - iterable = self.verses - else : - iterable = cycle(self.verses) - for verse in iterable : + for verse in self.verses : if self.songStartsWithChorus : for note in self.chorus : yield note, 0 diff --git a/src/minwii/widgets/playingscreen.py b/src/minwii/widgets/playingscreen.py index 0e179dd..adb6981 100755 --- a/src/minwii/widgets/playingscreen.py +++ b/src/minwii/widgets/playingscreen.py @@ -10,6 +10,7 @@ import pygame import types import minwii.events as events +from minwii.log import eventLogger from minwii.eventutils import event_handler, EventDispatcher, EventHandlerMixin from minwii.musicxml import Tone from minwii.config import FRAMERATE @@ -292,11 +293,17 @@ class SongPlayingScreen(PlayingScreenBase) : def displayNext(self, event=None) : if self.currentColumn: self.currentColumn.update(False) - note, verseIndex = self.noteIterator.next() + try : + note, verseIndex = self.noteIterator.next() + except StopIteration : + self.noteIterator = self.song.iterNotes() + note, verseIndex = self.noteIterator.next() + eventLogger.info(pygame.event.Event(events.SONGEND)) try : syllabus = note.lyrics[verseIndex].syllabus() except IndexError : syllabus = u'…' + column = self.columns[note.midi] column.update(True, syllabus) self.currentColumn = column