- @event_handler(pygame.MOUSEBUTTONDOWN)
- def onMouseDown(self, event) :
- if self.rect.collidepoint(*event.pos) :
- self.update(True)
-
- @event_handler(pygame.MOUSEBUTTONUP)
- def onMouseUp(self, event) :
- self.update(False)
-
-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 handleColumnOver(self, event) :
+ col = event.column
+ if col.state and not self.currentNotePlayed :
+ pan = self.getPan(col.index)
+ self.synth.cc(0, 10, pan)
+ vel = self.getVelocity(event.pos)
+ self.synth.noteon(0, col.tone.midi, vel)
+ 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()
+
+
\ No newline at end of file