def __init__(self, *a, **k): (super(Advance, self).__init__)(*a, **k) with self.component_guard(): encoders = ButtonMatrixElement(rows=[[ make_encoder(index + 22, 'Encoder_%d' % index) for index in range(8) ]]) pads = ButtonMatrixElement(rows=[[ make_button(identifier, 'Pad_%d_%d' % (col, row)) for col, identifier in enumerate(row_ids) ] for row, row_ids in enumerate(PAD_IDS)]) device = DeviceComponent( is_enabled=False, layer=Layer(parameter_controls=encoders), device_selection_follows_track_selection=True) device.set_enabled(True) self.set_device_component(device) drums = DrumRackComponent(is_enabled=False, layer=Layer(pads=pads)) drums.set_enabled(True) play_button = make_button(118, 'Play_Button', MIDI_CC_TYPE, 0) stop_button = make_button(117, 'Stop_Button', MIDI_CC_TYPE, 0) record_button = make_button(119, 'Record_Button', MIDI_CC_TYPE, 0) loop_button = make_button(114, 'Loop_Button', MIDI_CC_TYPE, 0) transport = TransportComponent(is_enabled=False, layer=Layer( play_button=play_button, stop_button=stop_button, record_button=record_button, loop_button=loop_button)) transport.set_enabled(True)
def __init__(self, *a, **k): (super(MPK261, self).__init__)(*a, **k) with self.component_guard(): midimap = MidiMap() drum_rack = DrumRackComponent( name='Drum_Rack', is_enabled=False, layer=Layer(pads=(midimap['Drum_Pads']))) drum_rack.set_enabled(True) transport = TransportComponent( name='Transport', is_enabled=False, layer=Layer(play_button=(midimap['Play']), record_button=(midimap['Record']), stop_button=(midimap['Stop']), seek_forward_button=(midimap['Forward']), seek_backward_button=(midimap['Backward']), loop_button=(midimap['Loop']))) transport.set_enabled(True) mixer_size = len(midimap['Sliders']) mixer = MixerComponent(mixer_size, name='Mixer', is_enabled=False, layer=Layer( volume_controls=(midimap['Sliders']), pan_controls=(midimap['Encoders']), arm_buttons=(midimap['Arm_Buttons']))) mixer.set_enabled(True)
def __init__(self, *a, **k): (super(MPK225, self).__init__)(*a, **k) with self.component_guard(): midimap = MidiMap() drum_rack = DrumRackComponent( name='Drum_Rack', is_enabled=False, layer=Layer(pads=(midimap['Drum_Pads']))) drum_rack.set_enabled(True) transport = TransportComponent( name='Transport', is_enabled=False, layer=Layer(play_button=(midimap['Play']), record_button=(midimap['Record']), stop_button=(midimap['Stop']), seek_forward_button=(midimap['Forward']), seek_backward_button=(midimap['Backward']), loop_button=(midimap['Loop']))) transport.set_enabled(True) device = DeviceComponent( name='Device', is_enabled=False, layer=Layer(parameter_controls=(midimap['Encoders'])), device_selection_follows_track_selection=True) device.set_enabled(True) self.set_device_component(device)
class KeyLab(ArturiaControlSurface): def __init__(self, *a, **k): (super(KeyLab, self).__init__)(*a, **k) with self.component_guard(): self._create_controls() self._create_display() self._create_device() self._create_drums() self._create_transport() self._create_session() self._create_session_recording() self._create_mixer() def _create_controls(self): self._device_encoders = ButtonMatrixElement(rows=[[ EncoderElement(MIDI_CC_TYPE, ENCODER_CHANNEL, identifier, (Live.MidiMap.MapMode. relative_smooth_binary_offset), name=('Device_Encoder_%d_%d' % (col_index, row_index))) for col_index, identifier in enumerate(row) ] for row_index, row in enumerate((ENCODER_MSG_IDS[:4], ENCODER_MSG_IDS[4:8]))]) self._horizontal_scroll_encoder = EncoderElement( MIDI_CC_TYPE, ENCODER_CHANNEL, (ENCODER_MSG_IDS[(-2)]), (Live.MidiMap.MapMode.relative_smooth_binary_offset), name='Horizontal_Scroll_Encoder') self._vertical_scroll_encoder = EncoderElement( MIDI_CC_TYPE, ENCODER_CHANNEL, (ENCODER_MSG_IDS[(-1)]), (Live.MidiMap.MapMode.relative_smooth_binary_offset), name='Vertical_Scroll_Encoder') self._volume_sliders = ButtonMatrixElement(rows=[[ SliderElement(MIDI_CC_TYPE, ENCODER_CHANNEL, identifier) for identifier in SLIDER_MSG_IDS[:-1] ]]) self._master_slider = SliderElement(MIDI_CC_TYPE, ENCODER_CHANNEL, SLIDER_MSG_IDS[(-1)]) def make_keylab_button(name): button = ButtonElement(True, MIDI_CC_TYPE, 0, (get_button_identifier_by_name(name)), name=(name.title())) return button for button_name in list(BUTTON_HARDWARE_AND_MESSAGE_IDS.keys()): setattr(self, '_' + button_name, make_keylab_button(button_name)) self._pads = ButtonMatrixElement(rows=[[ ButtonElement(True, MIDI_CC_TYPE, PAD_CHANNEL, (col_index + row_offset), name=('Pad_%d_%d' % (col_index, row_index))) for col_index in range(4) ] for row_index, row_offset in enumerate(range(48, 35, -4))]) def _create_display(self): self._display_line1, self._display_line2 = DisplayElement( 16, 1), DisplayElement(16, 1) for index, display_line in enumerate( (self._display_line1, self._display_line2)): display_line.set_message_parts(SETUP_MSG_PREFIX + (4, 0, 96), SETUP_MSG_SUFFIX) display_line.segment(0).set_position_identifier((index + 1, )) def adjust_null_terminated_string(string, width): return string.ljust(width, ' ') + '\x00' self._display_line1_data_source, self._display_line2_data_source = DisplayDataSource( adjust_string_fn=adjust_null_terminated_string), DisplayDataSource( adjust_string_fn=adjust_null_terminated_string) self._display_line1.segment(0).set_data_source( self._display_line1_data_source) self._display_line2.segment(0).set_data_source( self._display_line2_data_source) self._display_line1_data_source.set_display_string('KeyLab') self._display_line2_data_source.set_display_string('Ableton Live') def _create_device(self): self._device = DeviceComponent( name='Device', is_enabled=False, layer=Layer(parameter_controls=(self._device_encoders)), device_selection_follows_track_selection=True) self._device.set_enabled(True) self.set_device_component(self._device) self._device_navigation = DeviceNavigationComponent( name='Device_Navigation', is_enabled=False, layer=Layer(device_nav_left_button=(self._device_left_button), device_nav_right_button=(self._device_right_button))) self._device_navigation.set_enabled(True) def _create_drums(self): self._drums = DrumRackComponent(name='Drums', is_enabled=False, layer=Layer(pads=(self._pads))) self._drums.set_enabled(True) def _create_transport(self): self._transport = TransportComponent( name='Transport', is_enabled=False, layer=Layer(play_button=(self._play_button), stop_button=(self._stop_button), record_button=(self._record_button), loop_button=(self._loop_button))) self._transport.set_enabled(True) def _create_session(self): self._session = SessionComponent( num_tracks=8, num_scenes=1, name='Session', is_enabled=False, layer=Layer( select_next_button=(self._scene_down_button), select_prev_button=(self._scene_up_button), selected_scene_launch_button=(self._scene_launch_button), stop_all_clips_button=(self._stop_all_clips_button), scene_select_encoder=(self._vertical_scroll_encoder))) self._session.set_enabled(True) def _create_session_recording(self): self._session_recording = SessionRecordingComponent( (ClipCreator()), (ViewControlComponent()), name='Session_Recording', is_enabled=False, layer=Layer(record_button=(self._session_record_button))) self._session_recording.set_enabled(True) def _create_mixer(self): self._mixer = MixerComponent( num_tracks=(self._volume_sliders.width()), name='Mixer', is_enabled=False, layer=Layer( volume_controls=(self._volume_sliders), track_select_encoder=(self._horizontal_scroll_encoder))) self._mixer.master_strip().layer = Layer( volume_control=(self._master_slider)) self._mixer.set_enabled(True) def _collect_setup_messages(self): for hardware_id, identifier in zip(ENCODER_HARDWARE_IDS, ENCODER_MSG_IDS): self._setup_hardware_encoder(hardware_id, identifier, ENCODER_CHANNEL) for hardware_id, identifier in zip(SLIDER_HARDWARE_IDS, SLIDER_MSG_IDS): self._setup_hardware_slider(hardware_id, identifier, ENCODER_CHANNEL) for hardware_id, identifier in BUTTON_HARDWARE_AND_MESSAGE_IDS.values( ): self._setup_hardware_button(hardware_id, identifier) for hardware_id, identifier in zip(PAD_HARDWARE_IDS, PAD_MSG_IDS): self._setup_hardware_pad(hardware_id, identifier) def _setup_hardware_encoder(self, hardware_id, identifier, channel=0): self._set_encoder_cc_msg_type(hardware_id, is_relative=True) self._set_identifier(hardware_id, identifier) self._set_channel(hardware_id, channel) def _setup_hardware_button(self, hardware_id, identifier, channel=0, **k): self._set_encoder_cc_msg_type(hardware_id) self._set_identifier(hardware_id, identifier) self._set_channel(hardware_id, channel) self._set_value_minimum(hardware_id) self._set_value_maximum(hardware_id) def _setup_hardware_pad(self, hardware_id, identifier, channel=PAD_CHANNEL): self._set_pad_note_msg_type(hardware_id) self._set_identifier(hardware_id, identifier) self._set_channel(hardware_id, channel) def _set_pad_note_msg_type(self, hardware_id): self._collect_setup_message(MODE_PROPERTY, hardware_id, PAD_NOTE_MODE) def _setup_hardware(self): for msg in self._messages_to_send: self._tasks.add( Task.sequence(partial(self._send_midi, msg), Task.wait(MESSAGE_DELAY))) self._messages_to_send = []
def _create_drums(self): self._drums = DrumRackComponent(name='Drums', is_enabled=False, layer=Layer(pads=(self._pads))) self._drums.set_enabled(True)
class Roland_A_PRO(ControlSurface): def __init__(self, *a, **k): (super(Roland_A_PRO, self).__init__)(*a, **k) with self.component_guard(): self._create_controls() self._create_transport() self._create_mixer() self._create_device() self._create_drums() self._create_modes() def _create_controls(self): self._encoders = ButtonMatrixElement(rows=[ [EncoderElement(MIDI_CC_TYPE, 0, identifier, (Live.MidiMap.MapMode.absolute), name=('Encoder_%d' % index)) for index, identifier in enumerate(ENCODER_IDS)]]) self._master_encoder = EncoderElement(MIDI_CC_TYPE, 0, 10, (Live.MidiMap.MapMode.absolute), name='Master_Encoder') self._sliders = ButtonMatrixElement(rows=[ [SliderElement(MIDI_CC_TYPE, 0, identifier, name=('Slider_%d' % index)) for index, identifier in enumerate(SLIDER_IDS)]]) self._master_slider = SliderElement(MIDI_CC_TYPE, 0, 7, name='Master_Slider') self._play_button = ButtonElement(True, MIDI_CC_TYPE, 0, 26) self._stop_button = ButtonElement(True, MIDI_CC_TYPE, 0, 25) self._record_button = ButtonElement(True, MIDI_CC_TYPE, 0, 28) self._forward_button = ButtonElement(True, MIDI_CC_TYPE, 0, 24) self._backward_button = ButtonElement(True, MIDI_CC_TYPE, 0, 21) self._ff_button = ButtonElement(True, MIDI_CC_TYPE, 0, 23) self._rw_button = ButtonElement(True, MIDI_CC_TYPE, 0, 22) self._device_mode_button = ButtonElement(True, MIDI_CC_TYPE, 0, 80) self._pan_mode_button = ButtonElement(True, MIDI_CC_TYPE, 0, 81) self._send_a_mode_button = ButtonElement(True, MIDI_CC_TYPE, 0, 82) self._send_b_mode_button = ButtonElement(True, MIDI_CC_TYPE, 0, 83) self._pads = ButtonMatrixElement(rows=[[ButtonElement(True, MIDI_NOTE_TYPE, 0, identifier) for identifier in row] for row in PAD_ROWS]) def _create_transport(self): self._transport = TransportComponent(name='Transport', is_enabled=False, layer=Layer(play_button=(self._play_button), stop_button=(self._stop_button), record_button=(self._record_button))) self._transport.set_enabled(True) def _create_mixer(self): mixer_size = self._sliders.width() self._mixer = MixerComponent(mixer_size, name='Mixer', is_enabled=False, layer=Layer(volume_controls=(self._sliders), prehear_volume_control=(self._master_encoder))) self._mixer.master_strip().layer = Layer(volume_control=(self._master_slider)) self._mixer.set_enabled(True) def _create_device(self): self._device = DeviceComponent(device_selection_follows_track_selection=True) self._device_navigation = DeviceNavigationComponent() self._device.set_enabled(True) self._device_navigation.set_enabled(True) self.set_device_component(self._device) def _create_drums(self): self._drums = DrumRackComponent(name='Drum_Rack', is_enabled=False, layer=Layer(pads=(self._pads))) self._drums.set_enabled(True) def _create_modes(self): self._encoder_modes = ModesComponent() device_layer_mode = LayerMode(self._device, Layer(parameter_controls=(self._encoders))) device_navigation_layer_mode = LayerMode(self._device_navigation, Layer(device_nav_right_button=(self._forward_button), device_nav_left_button=(self._backward_button))) self._encoder_modes.add_mode('device_mode', [device_layer_mode, device_navigation_layer_mode]) self._encoder_modes.add_mode('pan_mode', AddLayerMode(self._mixer, Layer(pan_controls=(self._encoders), bank_up_button=(self._forward_button), bank_down_button=(self._backward_button), track_up_button=(self._ff_button), track_down_button=(self._rw_button)))) send_layer_mode = AddLayerMode(self._mixer, Layer(send_controls=(self._encoders), bank_up_button=(self._forward_button), bank_down_button=(self._backward_button), track_up_button=(self._ff_button), track_down_button=(self._rw_button))) self._encoder_modes.add_mode('send_a_mode', [send_layer_mode, partial(self._set_send_index, 0)]) self._encoder_modes.add_mode('send_b_mode', [send_layer_mode, partial(self._set_send_index, 1)]) self._encoder_modes.layer = Layer(device_mode_button=(self._device_mode_button), pan_mode_button=(self._pan_mode_button), send_a_mode_button=(self._send_a_mode_button), send_b_mode_button=(self._send_b_mode_button)) self._encoder_modes.selected_mode = 'device_mode' self._encoder_modes.set_enabled(True) def _set_send_index(self, index): self._mixer.send_index = index
def _create_drums(self): self._drums = DrumRackComponent(is_enabled=True, name='Drums') self._drums.layer = Layer(pads=(self._pads))