def play_func(): start_time = time() input_time = 0.0 keys_down = [False] * 88 for msg in ReplayViewer.playing_midi_file: input_time += msg.time playback_time = time() - start_time duration_to_next_event = input_time - playback_time while duration_to_next_event > 0.0 and ReplayViewer.playing: sleep_time = min(duration_to_next_event, 0.05) duration_to_next_event -= sleep_time sleep(sleep_time) if msg.type == "note_on": keys_down[msg.note - 21] = msg.velocity > 0 if not ReplayViewer.playing: break if isinstance(msg, mido.MetaMessage): continue midi.send(msg) if ReplayViewer.playing: ReplayViewer.playing = False ReplayViewer.update_display() else: for i in range(88): if keys_down[i]: midi.send( mido.Message("note_on", channel=0, note=i + 21, velocity=0, time=0)) midi.send( mido.Message("note_on", channel=1, note=i + 21, velocity=0, time=0)) for control in _pedal_controls: midi.send( mido.Message("control_change", channel=0, control=control, value=0, time=0)) midi.send( mido.Message("control_change", channel=1, control=control, value=0, time=0))
def Cls(port): for led in range(0, 64, 1): msg = [NOTE_OFF, led, 0] midi.send("Bhoreal", msg)
def AllColor(port, color): for led in range(0, 64, 1): msg = [NOTE_ON, led, color] midi.send("Bhoreal", msg)
def NoteOffXY(x, y): msg = [NOTE_OFF, NoteXY(x, y), 0] midi.send("Bhoreal", msg) gstt.BhorLeds[NoteXY(x, y)] = 0
def NoteOnXY(x, y, color): #print x,y msg = [NOTE_ON, NoteXY(x, y), color] midi.send("Bhoreal", msg) gstt.BhorLeds[NoteXY(x, y)] = color
def NoteOff(note): msg = [NOTE_OFF, note, 0] midi.send("Bhoreal", msg) gstt.BhorLeds[note] = 0
def NoteOn(note, color): #print x,y msg = [NOTE_ON, note, color] midi.send("Bhoreal", msg) gstt.BhorLeds[note] = color
def PadTopOff(number): msg = [CONTROLLER_CHANGE, LaunchTop[number - 1], 0] midi.send("Launchpad", msg) PadTops[number - 1] = 0
def PadTopOn(number, color): msg = [CONTROLLER_CHANGE, LaunchTop[number - 1], color] midi.send("Launchpad", msg) PadTops[number - 1] = color
def PadNoteOffXY(x, y): msg = [NOTE_OFF, PadNoteXY(x, y), 0] midi.send("Launchpad", msg) PadLeds[BhorNoteXY(x, y)] = 0
def PadNoteOnXY(x, y, color): msg = [NOTE_ON, PadNoteXY(x, y), color] #print msg midi.send("Launchpad", msg) PadLeds[BhorNoteXY(x, y)] = color
def PadRightOff(number): msg = [NOTE_OFF, LaunchRight[number - 1], 0] midi.send("Launchpad", msg) PadRights[number - 1] = 0
def PadRightOn(number, color): msg = [NOTE_ON, LaunchRight[number - 1], color] midi.send("Launchpad", msg) PadRights[number - 1] = color