+
+class SongPlayingScreen(_PlayingScreenBase) :
+
+ def __init__(self, synth, song, mode=PLAYING_MODES['EASY']) :
+ super(SongPlayingScreen, self).__init__(synth, song.distinctNotes)
+ self.song = song
+ self.quarterNoteDuration = song.quarterNoteDuration
+ self.currentColumn = None
+ self.noteIterator = self.song.iterNotes()
+ self.displayNext()
+ if mode == PLAYING_MODES['NORMAL'] :
+ EventDispatcher.addEventListener(events.COLDOWN, self.handleColumnDown)
+ EventDispatcher.addEventListener(events.COLUP, self.handleColumnUp)
+ elif mode == PLAYING_MODES['EASY'] :
+ EventDispatcher.addEventListener(events.COLOVER, self.handleColumnOver)
+
+
+ def displayNext(self, event=None) :
+ if self.currentColumn:
+ self.currentColumn.update(False)
+ note, verseIndex = self.noteIterator.next()
+ syllabus = note.lyrics[verseIndex].syllabus()
+ column = self.columns[note.midi]
+ column.update(True, syllabus)
+ self.currentColumn = column
+ self.currentNote = note
+ self.currentNotePlayed = False
+
+ def handleColumnDown(self, event) :
+ col = event.column
+ if col.state:
+ self.synth.noteon(0, col.tone.midi, DEFAULT_MIDI_VELOCITY)
+ self.currentNotePlayed = True
+
+ def handleColumnUp(self, event) :
+ if self.currentNotePlayed :
+ self.synth.noteoff(0, self.currentColumn.tone.midi)
+ self.displayNext()