def keyboard_func(self, key, x, y): if key == b'\x1b': setsong(self.midi, action='exit') sys.exit(0) elif key == b'\t': if self.selection is not None: self.selection = (self.selection + 1) % 16 else: self.selection = 0 info = channelinfo(self.midi, self.selection) while not info['used']: self.selection = (self.selection + 1) % 16 info = channelinfo(self.midi, self.selection) elif key == b' ': setsong(self.midi, action='pause') self.pause = not self.pause elif key in b'1234567890!@#$%^': channel = b'1234567890!@#$%^'.index(key) self.muted[channel] = not self.muted[channel] self.change_mute_state(channel) elif key == b'a': for channel in range(16): self.muted[channel] = self.solo[channel] = False self.change_mute_state(channel) elif key == b'd': self.muted[9] = not self.muted[9] self.change_mute_state(9) elif key == b'D': self.change_solo_state(9) elif key in MUTE_ON_OFF: for channel in range(16): info = channelinfo(self.midi, channel) if channel != 9 and info['family'] in MUTE_ON_OFF[key]: self.muted[channel] = not self.muted[channel] self.change_mute_state(channel) elif key in SOLO_ON: for channel in range(16): info = channelinfo(self.midi, channel) if channel != 9 and info['family'] in SOLO_ON[key]: self.muted[channel] = False else: self.muted[channel] = True self.solo[channel] = False self.change_mute_state(channel) elif key == b'<': setsong(self.midi, shift=-1) elif key == b'>': setsong(self.midi, shift=+1) elif key == b'-': setsong(self.midi, bpm=-1) elif key == b'+': setsong(self.midi, bpm=+1)
def update(self): glBlitFramebufferEXT(0, 0, 730, 650, 0, 0, 730, 650, GL_COLOR_BUFFER_BIT, GL_NEAREST) for channel in range(16): color = 0 if channel != self.selection else 2 info = channelinfo(self.midi, channel) x = 10 + channel * 38 if info['used']: name = info['name'] if channel != 9 else 'Drums' draw_text(620, 562 - channel * 14, name, color) if self.muted[channel]: copy_pixels(x - 6, 633, 31, 11, 735, 633) if self.solo[channel]: copy_pixels(x - 6, 619, 31, 10, 735, 619) paint_knob(x + 9, 581, info['sense']) draw_text(x, 559, '%3d' % info['sense'], color) paint_knob(x + 9, 523, info['delay']) draw_text(x, 501, '%3d' % info['delay'], color) paint_knob(x + 9, 465, info['chorus']) draw_text(x, 443, '%3d' % info['chorus'], color) paint_knob(x + 9, 407, info['reverb']) draw_text(x, 386, '%3d' % info['reverb'], color) pan = info['pan'] paint_knob(x + 9, 349, pan) lr = 'L R'[(pan > 64) - (pan < 64) + 1] draw_text(x, 327, '%s%2d' % (lr, abs(pan - 64)), color) if info['used']: draw_text(x, 310, '%3d' % info['instrument'], color) draw_text(x - 5, 295, '%2d' % info['variation'], color) draw_text(x, 204, '%3d' % info['level'], color) copy_pixels(x + 13, 295, 12, 15, 754, 295) level = info['level'] else: level = 0 copy_pixels(x - 6, 204, 12, 91, 4, 204) copy_pixels(x - 6, 219 + level // 2, 12, 11, 735, 225) copy_pixels(x + 13, 219, 12, info['intensity'] // 2, 754, 219) if info['intensity'] >= 4: info['intensity'] -= 4 else: info['intensity'] = 0 draw_text(15, 177, fileinfo(self.midi)) draw_text(15, 162, songinfo(self.midi)) draw_text(15, 142, lyrics(self.midi), 1) chord, notes = chordinfo(self.midi) draw_text(15, 120, chord) paint_notes(notes) ticker = ' Python MIDI Player \xa8 2013 by Josef Heinen ' beat = beatinfo(self.midi) shift = beat % len(ticker.strip()) + 1 if shift + 12 < len(ticker): draw_text(630, 628, ticker[shift: shift + 12]) for led in range(4): if beat % 4 == led: copy_pixels(632 + led * 20, 309, 16, 30, 770, 585) if self.pause: copy_pixels(665, 251, 10, 10, 850, 604) else: copy_pixels(665, 251, 10, 10, 860, 604)
def update(self): copy_pixels(0, 0, 730, 650, 0, 0) for channel in range(16): color = 0 if channel != self.selection else 2 info = channelinfo(self.midi, channel) x = 10 + channel * 38 if info['used']: name = info['name'] if channel != 9 else 'Drums' draw_text(620, 562 - channel * 14, name, color) if self.muted[channel]: copy_pixels(x - 6, 633, 31, 11, 735, 633) if self.solo[channel]: copy_pixels(x - 6, 619, 31, 10, 735, 619) paint_knob(x + 9, 581, info['sense']) draw_text(x, 559, '%3d' % info['sense'], color) paint_knob(x + 9, 523, info['delay']) draw_text(x, 501, '%3d' % info['delay'], color) paint_knob(x + 9, 465, info['chorus']) draw_text(x, 443, '%3d' % info['chorus'], color) paint_knob(x + 9, 407, info['reverb']) draw_text(x, 386, '%3d' % info['reverb'], color) pan = info['pan'] paint_knob(x + 9, 349, pan) lr = 'L R'[(pan > 64) - (pan < 64) + 1] draw_text(x, 327, '%s%2d' % (lr, abs(pan - 64)), color) if info['used']: draw_text(x, 310, '%3d' % info['instrument'], color) draw_text(x - 5, 295, '%2d' % info['variation'], color) draw_text(x, 204, '%3d' % info['level'], color) copy_pixels(x + 13, 295, 12, 15, 754, 295) level = info['level'] else: level = 0 copy_pixels(x - 6, 204, 12, 91, 4, 204) copy_pixels(x - 6, 219 + level // 2, 12, 11, 735, 225) copy_pixels(x + 13, 219, 12, info['intensity'] // 2, 754, 219) if info['intensity'] >= 4: info['intensity'] -= 4 else: info['intensity'] = 0 draw_text(15, 177, fileinfo(self.midi)) draw_text(15, 162, songinfo(self.midi)) draw_text(15, 142, lyrics(self.midi), 1) chord, notes = chordinfo(self.midi) draw_text(15, 120, chord) paint_notes(notes) ticker = ' Python MIDI Player \xa8 2013 by Josef Heinen ' beat = beatinfo(self.midi) shift = beat % len(ticker.strip()) + 1 if shift + 12 < len(ticker): draw_text(630, 628, ticker[shift:shift + 12]) for led in range(4): if beat % 4 == led: copy_pixels(632 + led * 20, 309, 16, 30, 770, 585) if self.pause: copy_pixels(665, 251, 10, 10, 850, 604) else: copy_pixels(665, 251, 10, 10, 860, 604)
def mouse_func(self, button, state, x, y): self.button = button == GLUT_LEFT_BUTTON and state == GLUT_DOWN if 630 < x < 710 and self.button: if 360 < y < 370: setsong(self.midi, bar=-1) elif 390 < y < 400: setsong(self.midi, action='pause') self.pause = not self.pause elif 420 < y < 430: setsong(self.midi, bar=+1) return elif x >= 608: return channel = x // 38 info = channelinfo(self.midi, channel) if info['used']: if self.button: if 6 < y < 18: self.muted[channel] = not self.muted[channel] self.change_mute_state(channel) elif 20 < y < 32: self.change_solo_state(channel) else: self.selection = channel