- def update(self, state) :
- if state :
- self.image = self.stateOn
- self.rect = self.rectOn
- else :
- self.image = self.stateOff
- self.rect = self.rectOff
-
-def hls_to_rgba_8bits(h, l, s) :
- #convert to rgb ranging from 0 to 255
- rgba = [floor(255 * i) for i in hls_to_rgb(h, l, s) + (1,)]
- return tuple(rgba)
-
\ No newline at end of file
+ def __init__(self, synth, song, mode=PLAYING_MODES['NORMAL']) :
+ super(SongPlayingScreen, self).__init__(synth, song.distinctNotes)
+ self.song = song
+ self.currentColumn = None
+ self.noteIterator = self.song.iterNotes()
+ self.displayNext()
+
+ def displayNext(self) :
+ if self.currentColumn:
+ self.currentColumn.update(False)
+ note, verseIndex = self.noteIterator.next()
+ syllabus = note.lyrics[verseIndex].syllabus(encoding="iso-8859-1")
+ column = self.columns[note.midi]
+ column.update(True, syllabus)
+ self.currentColumn = column
+ self.currentNotePlayed = False
+
+ @event_handler(events.COLDOWN)
+ def handleColumnDown(self, event) :
+ col = event.column
+ if col.state:
+ self.synth.noteon(0, col.tone.midi, DEFAULT_MIDI_VELOCITY)
+ self.currentNotePlayed = True
+
+ @event_handler(events.COLUP)
+ def handleColumnUp(self, event) :
+ if self.currentNotePlayed :
+ self.synth.noteoff(0, self.currentColumn.tone.midi)
+ self.displayNext()