def _update(self, events): self.has_changed = True if self.midi_in_button.update(events): devices = [[od[0], od[0]] for od in midi.inDevices()] screen.stack.append(ChoiceList(devices, 'In Device')) self.channel_counter.update(events) if self.midi_out_button.update(events): devices = [[od[0], od[0]] for od in midi.outDevices()] screen.stack.append(ChoiceList(devices, 'Out Device')) self.bpm_counter.update(events)
def _update(self, events): self.has_changed = True self.name_field.update(events) self.channel_counter.update(events) self.measures_counter.update(events) if self.bank_counter.update(events) and not self.new: part = self.clip.part bank = self.bank_counter.value program = self.program_counter.value if bank > 0 and program > 0: midi.out.write_short(midi.CC + part.channel, 32, bank - 1) midi.out.write_short(midi.PC + part.channel, program - 1) if self.program_counter.update(events) and not self.new: part = self.clip.part program = self.program_counter.value if program > 0: midi.out.write_short(midi.PC + part.channel, program - 1) if self.clip is None and self.editor_button.clicked(events): screen.stack.append(ChoiceList(editors.editors, 'Editor')) if self.clip is None and self.instrument_button.clicked(events): screen.stack.append(ChoiceList(instruments, 'Instrument')) for widget in self.editor_gui: widget.update(events)
def keydown_events(self, keyevents): """Handle pygame keydown events.""" mods = pygame.key.get_mods() for e in keyevents: if mods & pygame.KMOD_SHIFT: pass elif mods & pygame.KMOD_CTRL: if e.key == pygame.K_s: self.save_as() elif mods & pygame.KMOD_ALT: # Change scene if e.key == pygame.K_0: self.goto_scene(9) else: try: scene = int(e.unicode.encode('utf-8')) self.goto_scene(scene - 1) except: pass else: if e.key == pygame.K_q: pygame.event.post(pygame.event.Event(pygame.QUIT)) elif e.key == pygame.K_SPACE: sequencer.toggle() elif e.key == pygame.K_o: # Load file files = [[f[len("projects/"):], f] for f in glob('projects/*.yaml')] screen.stack.append(ChoiceList(files, 'Load project')) elif e.key == pygame.K_s: # Save path = sequencer.project['path'] if path is None: self.save_as() else: sequencer.save(path) elif e.key == pygame.K_v: # Paste if self.clip_copy is not None: sequencer.scene().append(self.clip_copy) self.update_partrects() elif e.key == pygame.K_p: # Preferences screen.stack.append(ConfigScreen())