def set_note_intensity_from_step_num(self, step_num, on): '''if on is True, the intensity is set from the steps velocity. if on is False, the intensity is set to zero''' step = self.manta_seq._seq.steps[step_num] if step.velocity > 0: if on: intensity = step.velocity else: intensity = 0 pad_num = pad_from_note(step.note) self.manta_seq.set_pad_intensity(pad_num, intensity)
def process(self): now = time.time() events = self._manta.process() for event in events: if isinstance(event, PadVelocityEvent): self._process_pad_velocity_event(event) if isinstance(event, ButtonVelocityEvent): self._process_button_velocity_event(event) elif isinstance(event, PadValueEvent): self._process_pad_value_event(event) elif isinstance(event, SliderValueEvent): self._process_slider_value_event(event) # send any pending note_offs for note_num, timestamp in self.note_offs.items(): if now >= timestamp: # send_midi_note will take care of removing the note # from the list self._send_midi_note(note_num, 0) self.set_pad_intensity(pad_from_note(note_num), 0) # if it's time for another step, do it if self.running and now >= self.next_step_timestamp: last_step = self.current_step self.current_step = self._seq.current_step_index step_obj = self._seq.step() if step_obj.velocity > 0: self._send_midi_note(step_obj.note, step_obj.velocity) note_off_timestamp = self.next_step_timestamp + (step_obj.duration * self.step_duration) self._schedule_note_off(step_obj.note, note_off_timestamp) self.set_pad_intensity(pad_from_note(step_obj.note), step_obj.velocity) self._send_midi_cc(1, self._combine_cc(self._global_cc1, step_obj.cc1)) self._send_midi_cc(2, self._combine_cc(self._global_cc2, step_obj.cc2)) # update the step LEDs (previous and current) self.set_pad_highlight(last_step, False) self.set_pad_highlight(self.current_step, True) # remember which step we turned on so we can turn it off next time # around self.next_step_timestamp += self.step_duration
def test_octave_above_base_midi_note_gives_16th_pad(self): self.assertEquals(pad_from_note(BASE_MIDI_NOTE+12), 16)
def test_base_midi_note_gives_first_pad(self): self.assertEquals(pad_from_note(BASE_MIDI_NOTE), 0)