self.initWiimotes()
self.firstSong = True
self.screen = SCREEN_HOME
self.initWiimotes()
self.firstSong = True
self.screen = SCREEN_HOME
+ self.playingScreen = None
def initWiimotes(self) :
if self.wiimoteSupport :
def initWiimotes(self) :
if self.wiimoteSupport :
self.synth.inc_gain()
elif wiiuse.is_just_pressed(wm, wiiuse.button['-']) :
self.synth.dec_gain()
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)
elif self.screen in (SCREEN_HOME, SCREEN_INSTRUMENTS) :
pygame_wiimouse._full_mouse_event_cb(wt, id, wmp)
playingScreen = PlayingScreen(self.synth)
else :
song = musicXml2Song(songFile)
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()
playingScreen.run()
pygame.event.clear()
EventDispatcher.reset()
+ self.playingScreen = None
class SongPlayingScreen(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
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()
self.currentColumn = None
self.noteIterator = self.song.iterNotes()
self.displayNext()
col = event.column
if col.state and not self.currentNotePlayed :
self.playnote(col, event.pos)
col = event.column
if col.state and not self.currentNotePlayed :
self.playnote(col, event.pos)
- SongPlayingScreen.setNoteTimeout(
- int(self.currentNote.duration * \
- self.quarterNoteDuration)
- )
self.currentNotePlayed = True
def handleEasyColumnOver(self, event) :
self.currentNotePlayed = True
def handleEasyColumnOver(self, event) :
self.cursor.pressed and \
not self.currentNotePlayed :
self.playnote(col, event.pos)
self.cursor.pressed and \
not self.currentNotePlayed :
self.playnote(col, event.pos)
- SongPlayingScreen.setNoteTimeout(
- int(self.currentNote.duration * \
- self.quarterNoteDuration)
- )
self.currentNotePlayed = True
self.currentNotePlayed = True
if col.state and \
not self.currentNotePlayed :
self.playnote(col, event.pos)
if col.state and \
not self.currentNotePlayed :
self.playnote(col, event.pos)
- SongPlayingScreen.setNoteTimeout(
- int(self.currentNote.duration * \
- self.quarterNoteDuration)
- )
self.currentNotePlayed = True
self.currentNotePlayed = True
self.synth.noteoff(0, self.currentNote.midi)
self.displayNext()
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)
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()
def stop(self) :
pygame.time.set_timer(events.NOTEEND, 0)
super(SongPlayingScreen, self).stop()