- 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)
+ def handleColumnUp(self, event) :
+ if self.currentNotePlayed :
+ self.synth.noteoff(0, self.currentColumn.tone.midi)
+ self.displayNext()
+
+ def handleColumnOver(self, event) :
+ col = event.column
+ if col.state and not self.currentNotePlayed :
+ self.synth.noteon(0, col.tone.midi, DEFAULT_MIDI_VELOCITY)
+ SongPlayingScreen.setNoteTimeout(
+ int(self.currentNote.duration * \
+ self.quarterNoteDuration)
+ )
+ self.currentNotePlayed = True
+
+ @event_handler(events.NOTEEND)
+ def clearTimeOutAndDisplayNext(self, evt) :
+ pygame.time.set_timer(evt.type, 0)
+ self.synth.noteoff(0, self.currentNote.midi)
+ self.displayNext()
+
+ @staticmethod
+ def setNoteTimeout(delay) :
+ pygame.time.set_timer(events.NOTEEND, delay)
+
+ def stop(self) :
+ pygame.time.set_timer(events.NOTEEND, 0)
+ super(SongPlayingScreen, self).stop()
+