From 8a654eb43381bf77f3bade5a228809c90217d291 Mon Sep 17 00:00:00 2001 From: pin Date: Mon, 27 Jun 2011 13:34:18 +0000 Subject: [PATCH 1/1] =?utf8?q?Impl=C3=A9mentation=20de=20l'ajustement=20?= =?utf8?q?=C2=AB=20en=20live=20=C2=BB=20du=20tempo=20d'ex=C3=A9cution=20de?= =?utf8?q?=20la=20chanson=20sur=20les=20boutons=201=20&=202=20de=20la=20t?= =?utf8?q?=C3=A9l=C3=A9commande.?= 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@358 fe552daf-6dbe-4428-90eb-1537e0879342 --- src/minwii/app.py | 8 +++++++- src/minwii/widgets/playingscreen.py | 29 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/minwii/app.py b/src/minwii/app.py index 95bfaab..c56700a 100755 --- a/src/minwii/app.py +++ b/src/minwii/app.py @@ -50,6 +50,7 @@ class MinWii(object): self.initWiimotes() self.firstSong = True self.screen = SCREEN_HOME + self.playingScreen = None def initWiimotes(self) : if self.wiimoteSupport : @@ -84,6 +85,10 @@ class MinWii(object): self.synth.inc_gain() elif wiiuse.is_just_pressed(wm, wiiuse.button['-']) : self.synth.dec_gain() + elif wiiuse.is_just_pressed(wm, wiiuse.button['1']) and self.playingScreen : + self.playingScreen.tempoTrimUp() + elif wiiuse.is_just_pressed(wm, wiiuse.button['2']) and self.playingScreen : + self.playingScreen.tempoTrimDown() elif self.screen in (SCREEN_HOME, SCREEN_INSTRUMENTS) : pygame_wiimouse._full_mouse_event_cb(wt, id, wmp) @@ -190,10 +195,11 @@ class MinWii(object): playingScreen = PlayingScreen(self.synth) else : song = musicXml2Song(songFile) - playingScreen = SongPlayingScreen(self.synth, song, mode=playMode) + self.playingScreen = playingScreen = SongPlayingScreen(self.synth, song, mode=playMode) playingScreen.run() pygame.event.clear() EventDispatcher.reset() + self.playingScreen = None class _WTFacade : diff --git a/src/minwii/widgets/playingscreen.py b/src/minwii/widgets/playingscreen.py index b3438b4..b1dbe80 100755 --- a/src/minwii/widgets/playingscreen.py +++ b/src/minwii/widgets/playingscreen.py @@ -191,10 +191,11 @@ class PlayingScreen(PlayingScreenBase) : class SongPlayingScreen(PlayingScreenBase) : - def __init__(self, synth, song, mode=PLAYING_MODES_DICT['NORMAL']) : + def __init__(self, synth, song, mode=PLAYING_MODES_DICT['NORMAL'], tempoTrim=0) : super(SongPlayingScreen, self).__init__(synth, song.distinctNotes) self.song = song self.quarterNoteDuration = song.quarterNoteDuration + self.tempoTrim = tempoTrim self.currentColumn = None self.noteIterator = self.song.iterNotes() self.displayNext() @@ -229,10 +230,7 @@ class SongPlayingScreen(PlayingScreenBase) : col = event.column if col.state and not self.currentNotePlayed : self.playnote(col, event.pos) - SongPlayingScreen.setNoteTimeout( - int(self.currentNote.duration * \ - self.quarterNoteDuration) - ) + self.setNoteTimeout() self.currentNotePlayed = True def handleEasyColumnOver(self, event) : @@ -241,10 +239,7 @@ class SongPlayingScreen(PlayingScreenBase) : self.cursor.pressed and \ not self.currentNotePlayed : self.playnote(col, event.pos) - SongPlayingScreen.setNoteTimeout( - int(self.currentNote.duration * \ - self.quarterNoteDuration) - ) + self.setNoteTimeout() self.currentNotePlayed = True @@ -267,10 +262,7 @@ class SongPlayingScreen(PlayingScreenBase) : if col.state and \ not self.currentNotePlayed : self.playnote(col, event.pos) - SongPlayingScreen.setNoteTimeout( - int(self.currentNote.duration * \ - self.quarterNoteDuration) - ) + self.setNoteTimeout() self.currentNotePlayed = True @@ -327,10 +319,17 @@ class SongPlayingScreen(PlayingScreenBase) : self.synth.noteoff(0, self.currentNote.midi) self.displayNext() - @staticmethod - def setNoteTimeout(delay) : + def setNoteTimeout(self) : + delay = self.currentNote.duration * self.quarterNoteDuration + delay = delay + delay * self.tempoTrim pygame.time.set_timer(events.NOTEEND, delay) + def tempoTrimUp(self, step=0.1) : + self.tempoTrim = round(self.tempoTrim - step, 1) + + def tempoTrimDown(self, step=0.1) : + self.tempoTrim = round(self.tempoTrim + step, 1) + def stop(self) : pygame.time.set_timer(events.NOTEEND, 0) super(SongPlayingScreen, self).stop() -- 2.20.1