From 1355364de08e9b941c6fb93cd95ff0df6703dc21 Mon Sep 17 00:00:00 2001 From: pin Date: Thu, 8 Jul 2010 14:31:50 +0000 Subject: [PATCH 1/1] =?utf8?q?Impression=20d'un=20=C3=A9v=C3=A9nement=20SO?= =?utf8?q?NGEND=20=C3=A0=20la=20fin=20de=20la=20chanson.?= 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@280 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/event_pprinters.py | 3 +++ src/minwii/events.py | 5 ++++- src/minwii/musicxml.py | 8 ++------ src/minwii/widgets/playingscreen.py | 9 ++++++++- 4 files changed, 17 insertions(+), 8 deletions(-) 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 -- 2.20.1