Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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.set_enabled(True)
         self.set_device_component(device)
         self._device_selection_follows_track_selection = True
Example #4
0
 def __init__(self, *a, **k):
     super(Advance, self).__init__(*a, **k)
     with self.component_guard():
         encoders = ButtonMatrixElement(rows=[[
             make_encoder(index + 22, b'Encoder_%d' % index)
             for index in xrange(8)
         ]])
         pads = ButtonMatrixElement(rows=[[
             make_button(identifier, b'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, b'Play_Button', MIDI_CC_TYPE, 0)
         stop_button = make_button(117, b'Stop_Button', MIDI_CC_TYPE, 0)
         record_button = make_button(119, b'Record_Button', MIDI_CC_TYPE, 0)
         loop_button = make_button(114, b'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(MPK249, 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)
Example #6
0
 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)
Example #7
0
    def __init__(self, *a, **k):
        super(MPK261Custom, self).__init__(*a, **k)
        with self.component_guard():
            midimap = MidiMap()
            drum_rack = DrumRackComponent(name=u'Drum_Rack', is_enabled=False,
                                          layer=Layer(pads=midimap[u'Drum_Pads']))
            drum_rack.set_enabled(True)
            transport = TransportComponent(name=u'Transport', is_enabled=False, layer=Layer(
                play_button=midimap[u'Play'],
                record_button=midimap[u'Record'],
                stop_button=midimap[u'Stop'],
                seek_forward_button=midimap[u'Forward'],
                seek_backward_button=midimap[u'Backward'],
                loop_button=midimap[u'Loop'],
                metronome_button=midimap[u'Metronome'],
                tap_tempo_button=midimap[u'TapTempoButton'],
                quant_toggle_button=midimap[u'RecQuantButton'],
                overdub_button=midimap[u'OverdubButton']
                ))
            transport.set_enabled(True)
            mixer_size = len(midimap[u'Sliders'])

            # Custom changes: Adds the "mute" buttons. By default, mute = turns light on.
            # invert_mute_feedback flips it around so muting = turns light off.
            mixer = MixerComponent(mixer_size, name=u'Mixer', is_enabled=False,
                                   invert_mute_feedback=True,
                                   layer=Layer(
                                       volume_controls=midimap[u'Sliders'],
                                       pan_controls=midimap[u'Encoders'],
                                       arm_buttons=midimap[u'Arm_Buttons'],
                                       mute_buttons=midimap[u'Mute_Buttons'],
                                   ))
            mixer.set_enabled(True)

            # Adds the blue hand controls.
            device = DeviceComponent(
                name=u'Device', is_enabled=False,
                layer=Layer(parameter_controls=midimap[u'EncodersB1']),
                device_selection_follows_track_selection=True)
            device.set_enabled(True)
            self.set_device_component(device)

            session = SessionComponent(
                SESSION_WIDTH, SESSION_HEIGHT, auto_name=True, enable_skinning=True,
                is_enabled=False, layer=Layer(
                    clip_launch_buttons=midimap[u'Drum_Pads_BankB'],
                    stop_track_clip_buttons=midimap[u'Drum_Pads_BankC_BottomRow'],
                    scene_launch_buttons=midimap[u'Drum_Pads_BankD_RightColumn']))
            session.set_enabled(True)

        self.log_message(u' ***** MPK261 Custom script loaded ****')
Example #8
0
 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 xrange(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)
Example #9
0
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=b'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=b'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=b'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 BUTTON_HARDWARE_AND_MESSAGE_IDS.keys():
            setattr(self, b'_' + button_name, make_keylab_button(button_name))

        self._pads = ButtonMatrixElement(rows=[[
            ButtonElement(True,
                          MIDI_CC_TYPE,
                          PAD_CHANNEL,
                          col_index + row_offset,
                          name=b'Pad_%d_%d' % (col_index, row_index))
            for col_index in xrange(4)
        ] for row_index, row_offset in enumerate(xrange(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, b' ') + b'\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(b'KeyLab')
        self._display_line2_data_source.set_display_string(b'Ableton Live')

    def _create_device(self):
        self._device = DeviceComponent(
            name=b'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=b'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=b'Drums',
                                        is_enabled=False,
                                        layer=Layer(pads=self._pads))
        self._drums.set_enabled(True)

    def _create_transport(self):
        self._transport = TransportComponent(
            name=b'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=b'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=b'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=b'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 izip(ENCODER_HARDWARE_IDS,
                                            ENCODER_MSG_IDS):
            self._setup_hardware_encoder(hardware_id, identifier,
                                         ENCODER_CHANNEL)

        for hardware_id, identifier in izip(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.itervalues(
        ):
            self._setup_hardware_button(hardware_id, identifier)

        for hardware_id, identifier in izip(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)
Example #10
0
 def _create_drums(self):
     self._drums = DrumRackComponent(name=b'Drums',
                                     is_enabled=False,
                                     layer=Layer(pads=self._pads))
     self._drums.set_enabled(True)
Example #11
0
 def _create_drums(self):
     self._drums = DrumRackComponent(is_enabled=True, name=u'Drums')
     self._drums.layer = Layer(pads=self._pads)
Example #12
0
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
Example #13
0
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
Example #14
0
 def __init__(self, *a, **k):
     super(MPK261MXLOOP, self).__init__(*a, **k)
     self.show_message("-----------------------= MPK261MXLOOP LOADING - maxcloutier13 says hi =----------------------------------------------------------")
     self.log_message("-----------------------= MPK261MXLOOP LOADING - maxcloutier13 says hi =----------------------------------------------------------")
     with self.component_guard():
         midimap = MidiMap()
         #Sustain pedal 1 = Play/Record/Overdub switch for live looping
         self._LoopRecordButton = ButtonElement(True, MIDI_CC_TYPE, 0, 64)
         self._LoopRecordButton.add_value_listener(self._launch_clip, False)
         #Sustain pedal 2 = Sustain pour l'instant ;o)
         #self._LoopRecordButton = ButtonElement(True, MIDI_CC_TYPE, 0, 65)            
         #Control up/down/left/right using the daw controls            
         self._UpButton = ButtonElement(False, MIDI_CC_TYPE, 0, 88, name='UpButton')
         self._DownButton = ButtonElement(False, MIDI_CC_TYPE, 0, 89, name='DownButton')
         self._LeftButton = ButtonElement(False, MIDI_CC_TYPE, 0, 20, name='LeftButton')
         self._RightButton = ButtonElement(False, MIDI_CC_TYPE, 0, 21, name='RightButton')
         #Listeners for the functions
         self._UpButton.add_value_listener(self._move_up, False)
         self._DownButton.add_value_listener(self._move_down, False)
         self._LeftButton.add_value_listener(self._move_left, False)
         self._RightButton.add_value_listener(self._move_right, False)
         #Super crude manual init for the custom buttons and faders 
         #Control Bank A - Channel 1 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         self._Encoder0 = EncoderElement(MIDI_CC_TYPE,1,22, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder0')
         self._Encoder1 = EncoderElement(MIDI_CC_TYPE,1,23, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder1')
         self._Encoder2 = EncoderElement(MIDI_CC_TYPE,1,24, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder2')
         self._Encoder3 = EncoderElement(MIDI_CC_TYPE,1,25, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder3')
         self._Encoder4 = EncoderElement(MIDI_CC_TYPE,1,26, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder4')
         self._Encoder5 = EncoderElement(MIDI_CC_TYPE,1,27, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder5')
         self._Encoder6 = EncoderElement(MIDI_CC_TYPE,1,28, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder6')
         self._Encoder7 = EncoderElement(MIDI_CC_TYPE,1,29, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder7')
         self._ArmButton0 = ButtonElement(False, MIDI_CC_TYPE, 0, 32, name='ArmButton0')
         self._ArmButton1 = ButtonElement(False, MIDI_CC_TYPE, 0, 33, name='ArmButton1')
         self._ArmButton2 = ButtonElement(False, MIDI_CC_TYPE, 0, 34, name='ArmButton2')
         self._ArmButton3 = ButtonElement(False, MIDI_CC_TYPE, 0, 35, name='ArmButton3')
         self._ArmButton4 = ButtonElement(False, MIDI_CC_TYPE, 0, 36, name='ArmButton4')
         self._ArmButton5 = ButtonElement(False, MIDI_CC_TYPE, 0, 37, name='ArmButton5')
         self._ArmButton6 = ButtonElement(False, MIDI_CC_TYPE, 0, 38, name='ArmButton6')
         self._ArmButton7 = ButtonElement(False, MIDI_CC_TYPE, 0, 39, name='ArmButton7')
         self._VolumeSlider0 = SliderElement(MIDI_CC_TYPE, 0, 12, name='VolumeSlider0')
         self._VolumeSlider1 = SliderElement(MIDI_CC_TYPE, 0, 13, name='VolumeSlider1')
         self._VolumeSlider2 = SliderElement(MIDI_CC_TYPE, 0, 14, name='VolumeSlider2')
         self._VolumeSlider3 = SliderElement(MIDI_CC_TYPE, 0, 15, name='VolumeSlider3')
         self._VolumeSlider4 = SliderElement(MIDI_CC_TYPE, 0, 16, name='VolumeSlider4')
         self._VolumeSlider5 = SliderElement(MIDI_CC_TYPE, 0, 17, name='VolumeSlider5')
         self._VolumeSlider6 = SliderElement(MIDI_CC_TYPE, 0, 18, name='VolumeSlider6')
         self._VolumeSlider7 = SliderElement(MIDI_CC_TYPE, 0, 19, name='VolumeSlider7')
         #Control Bank B - Channel 2 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         self._Encoder8 = EncoderElement(MIDI_CC_TYPE,2,22, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder8')
         self._Encoder9 = EncoderElement(MIDI_CC_TYPE,2,23, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder9')
         self._Encoder10 = EncoderElement(MIDI_CC_TYPE,2,24, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder10')
         self._Encoder11 = EncoderElement(MIDI_CC_TYPE,2,25, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder11')
         self._Encoder12 = EncoderElement(MIDI_CC_TYPE,2,26, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder12')
         self._Encoder13 = EncoderElement(MIDI_CC_TYPE,2,27, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder13')
         self._Encoder14 = EncoderElement(MIDI_CC_TYPE,2,28, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder14')
         self._Encoder15 = EncoderElement(MIDI_CC_TYPE,2,29, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder15')
         self._ArmButton8 = ButtonElement(False, MIDI_CC_TYPE, 1, 32, name='ArmButton8')
         self._ArmButton9 = ButtonElement(False, MIDI_CC_TYPE, 1, 33, name='ArmButton9')
         self._ArmButton10 = ButtonElement(False, MIDI_CC_TYPE, 1, 34, name='ArmButton10')
         self._ArmButton11 = ButtonElement(False, MIDI_CC_TYPE, 1, 35, name='ArmButton11')
         self._ArmButton12 = ButtonElement(False, MIDI_CC_TYPE, 1, 36, name='ArmButton12')
         self._ArmButton13 = ButtonElement(False, MIDI_CC_TYPE, 1, 37, name='ArmButton13')
         self._ArmButton14 = ButtonElement(False, MIDI_CC_TYPE, 1, 38, name='ArmButton14')
         self._ArmButton15 = ButtonElement(False, MIDI_CC_TYPE, 1, 39, name='ArmButton15')
         self._VolumeSlider8 = SliderElement(MIDI_CC_TYPE, 1, 12, name='VolumeSlider8')
         self._VolumeSlider9 = SliderElement(MIDI_CC_TYPE, 1, 13, name='VolumeSlider9')
         self._VolumeSlider10 = SliderElement(MIDI_CC_TYPE, 1, 14, name='VolumeSlider10')
         self._VolumeSlider11 = SliderElement(MIDI_CC_TYPE, 1, 15, name='VolumeSlider11')
         self._VolumeSlider12 = SliderElement(MIDI_CC_TYPE, 1, 16, name='VolumeSlider12')
         self._VolumeSlider13 = SliderElement(MIDI_CC_TYPE, 1, 17, name='VolumeSlider13')
         self._VolumeSlider14 = SliderElement(MIDI_CC_TYPE, 1, 18, name='VolumeSlider14')
         self._VolumeSlider15 = SliderElement(MIDI_CC_TYPE, 1, 19, name='VolumeSlider15')
         #Control Bank C - Channel 3 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         self._Encoder16 = EncoderElement(MIDI_CC_TYPE,3,22, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder16')
         self._Encoder17 = EncoderElement(MIDI_CC_TYPE,3,23, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder17')
         self._Encoder18 = EncoderElement(MIDI_CC_TYPE,3,24, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder18')
         self._Encoder19 = EncoderElement(MIDI_CC_TYPE,3,25, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder19')
         self._Encoder20 = EncoderElement(MIDI_CC_TYPE,3,26, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder20')
         self._Encoder21 = EncoderElement(MIDI_CC_TYPE,3,27, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder21')
         self._Encoder22 = EncoderElement(MIDI_CC_TYPE,3,28, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder22')
         self._Encoder23 = EncoderElement(MIDI_CC_TYPE,3,29, Live.MidiMap.MapMode.relative_two_compliment, name='Encoder23')
         self._ArmButton16 = ButtonElement(False, MIDI_CC_TYPE, 2, 32, name='ArmButton16')
         self._ArmButton17 = ButtonElement(False, MIDI_CC_TYPE, 2, 33, name='ArmButton17')
         self._ArmButton18 = ButtonElement(False, MIDI_CC_TYPE, 2, 34, name='ArmButton18')
         self._ArmButton19 = ButtonElement(False, MIDI_CC_TYPE, 2, 35, name='ArmButton19')
         self._ArmButton20 = ButtonElement(False, MIDI_CC_TYPE, 2, 36, name='ArmButton20')
         self._ArmButton21 = ButtonElement(False, MIDI_CC_TYPE, 2, 37, name='ArmButton21')
         self._ArmButton22 = ButtonElement(False, MIDI_CC_TYPE, 2, 38, name='ArmButton22')
         self._ArmButton23 = ButtonElement(False, MIDI_CC_TYPE, 2, 39, name='ArmButton23')
         self._VolumeSlider16 = SliderElement(MIDI_CC_TYPE, 2, 12, name='VolumeSlider16')
         self._VolumeSlider17 = SliderElement(MIDI_CC_TYPE, 2, 13, name='VolumeSlider17')
         self._VolumeSlider18 = SliderElement(MIDI_CC_TYPE, 2, 14, name='VolumeSlider18')
         self._VolumeSlider19 = SliderElement(MIDI_CC_TYPE, 2, 15, name='VolumeSlider19')
         self._VolumeSlider20 = SliderElement(MIDI_CC_TYPE, 2, 16, name='VolumeSlider20')
         self._VolumeSlider21 = SliderElement(MIDI_CC_TYPE, 2, 17, name='VolumeSlider21')
         self._VolumeSlider22 = SliderElement(MIDI_CC_TYPE, 2, 18, name='VolumeSlider22')
         self._VolumeSlider23 = SliderElement(MIDI_CC_TYPE, 2, 19, name='VolumeSlider23')
         #Drum Bank A - Channel 4--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         self._Pad0 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 81, name='Pad0')
         self._Pad1 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 83, name='Pad1')
         self._Pad2 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 84, name='Pad2')
         self._Pad3 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 86, name='Pad3')
         self._Pad4 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 74, name='Pad4')
         self._Pad5 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 76, name='Pad5')
         self._Pad6 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 77, name='Pad6')
         self._Pad7 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 79, name='Pad7')
         self._Pad8 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 67, name='Pad8')
         self._Pad9 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 69, name='Pad9')
         self._Pad10 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 71, name='Pad10')
         self._Pad11 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 72, name='Pad11')
         self._Pad12 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 60, name='Pad12')
         self._Pad13 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 62, name='Pad13')
         self._Pad14 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 64, name='Pad14')
         self._Pad15 = ButtonElement(True, MIDI_NOTE_TYPE, 3, 65, name='Pad15')
         self._Pads = ButtonMatrixElement(rows=[[self._Pad0, self._Pad1, self._Pad2, self._Pad3],
                                                [self._Pad4, self._Pad5, self._Pad6, self._Pad7], 
                                                [self._Pad8, self._Pad9, self._Pad10, self._Pad11],
                                                [self._Pad12, self._Pad13, self._Pad14, self._Pad15]])
         #Drum Bank B -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         #Drum Bank C -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         #Drum Bank D -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         #
         #Drum rack -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         drum_rack = DrumRackComponent(name='Drum_Rack', is_enabled=False, layer=Layer(pads=self._Pads))
         drum_rack.set_enabled(True)
         #Transport -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         transport = TransportComponent(name='Transport', is_enabled=False, layer=Layer(play_button=midimap['Play'], record_button=midimap['Record'], stop_button=midimap['Stop'], loop_button=midimap['Loop']))
         #, seek_forward_button=midimap['Forward'], seek_backward_button=midimap['Backward']
         transport.set_enabled(True)
         #Make the Back/Fwd button just normal mapable CC senders
         self._BackButton = ButtonElement(False, MIDI_CC_TYPE, 0, 116, name='BackButton')
         self._FwdButton = ButtonElement(False, MIDI_CC_TYPE, 0, 115, name='FwdButton')
         #Device -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         self._device = DeviceComponent(name='Device', is_enabled=False, layer=Layer(parameter_controls=midimap['Encoders']), device_selection_follows_track_selection=True)
         self._device.set_enabled(True)
         self.set_device_component(self._device)
         #Mixer -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         mixer_size = 24
         self._mixer = MixerComponent(mixer_size, name='Mixer', is_enabled=False)
         #Super crude and repetitive mapping because after all this shit I'm not spending time learning how to loop this crap hehe
         #Bank A
         self._mixer.channel_strip(0).layer = Layer(volume_control = self._VolumeSlider0, arm_button=self._ArmButton0, pan_control=self._Encoder0)
         self._mixer.channel_strip(1).layer = Layer(volume_control = self._VolumeSlider1, arm_button=self._ArmButton1, pan_control=self._Encoder1)
         self._mixer.channel_strip(2).layer = Layer(volume_control = self._VolumeSlider2, arm_button=self._ArmButton2, pan_control=self._Encoder2)
         self._mixer.channel_strip(3).layer = Layer(volume_control = self._VolumeSlider3, arm_button=self._ArmButton3, pan_control=self._Encoder3)
         self._mixer.channel_strip(4).layer = Layer(volume_control = self._VolumeSlider4, arm_button=self._ArmButton4, pan_control=self._Encoder4)
         self._mixer.channel_strip(5).layer = Layer(volume_control = self._VolumeSlider5, arm_button=self._ArmButton5, pan_control=self._Encoder5)
         self._mixer.channel_strip(6).layer = Layer(volume_control = self._VolumeSlider6, arm_button=self._ArmButton6, pan_control=self._Encoder6)
         self._mixer.channel_strip(7).layer = Layer(volume_control = self._VolumeSlider7, arm_button=self._ArmButton7, pan_control=self._Encoder7)
         #Bank B
         self._mixer.channel_strip(8).layer = Layer(volume_control = self._VolumeSlider8, arm_button=self._ArmButton8, pan_control=self._Encoder8)
         self._mixer.channel_strip(9).layer = Layer(volume_control = self._VolumeSlider9, arm_button=self._ArmButton9, pan_control=self._Encoder9)
         self._mixer.channel_strip(10).layer = Layer(volume_control = self._VolumeSlider10, arm_button=self._ArmButton10, pan_control=self._Encoder10)
         self._mixer.channel_strip(11).layer = Layer(volume_control = self._VolumeSlider11, arm_button=self._ArmButton11, pan_control=self._Encoder11)
         self._mixer.channel_strip(12).layer = Layer(volume_control = self._VolumeSlider12, arm_button=self._ArmButton12, pan_control=self._Encoder12)
         self._mixer.channel_strip(13).layer = Layer(volume_control = self._VolumeSlider13, arm_button=self._ArmButton13, pan_control=self._Encoder13)
         self._mixer.channel_strip(14).layer = Layer(volume_control = self._VolumeSlider14, arm_button=self._ArmButton14, pan_control=self._Encoder14)
         self._mixer.channel_strip(15).layer = Layer(volume_control = self._VolumeSlider15, arm_button=self._ArmButton15, pan_control=self._Encoder15)
         #Bank C     
         self._mixer.channel_strip(16).layer = Layer(volume_control = self._VolumeSlider16, arm_button=self._ArmButton16, pan_control=self._Encoder16)
         self._mixer.channel_strip(17).layer = Layer(volume_control = self._VolumeSlider17, arm_button=self._ArmButton17, pan_control=self._Encoder17)
         self._mixer.channel_strip(18).layer = Layer(volume_control = self._VolumeSlider18, arm_button=self._ArmButton18, pan_control=self._Encoder18)
         self._mixer.channel_strip(19).layer = Layer(volume_control = self._VolumeSlider19, arm_button=self._ArmButton19, pan_control=self._Encoder19)
         self._mixer.channel_strip(20).layer = Layer(volume_control = self._VolumeSlider20, arm_button=self._ArmButton20, pan_control=self._Encoder20)
         self._mixer.channel_strip(21).layer = Layer(volume_control = self._VolumeSlider21, arm_button=self._ArmButton21, pan_control=self._Encoder21)
         self._mixer.channel_strip(22).layer = Layer(volume_control = self._VolumeSlider22, arm_button=self._ArmButton22, pan_control=self._Encoder22)
         self._mixer.channel_strip(23).layer = Layer(volume_control = self._VolumeSlider23, arm_button=self._ArmButton23, pan_control=self._Encoder23)
         self._mixer.set_enabled(True)
         #Track change listener
         self.song().view.add_selected_track_listener(self._update_selected_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 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 xrange(4) ] for row_index, row_offset in enumerate(xrange(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))
        self._device.set_enabled(True)
        self.set_device_component(self._device)
        self._device_selection_follows_track_selection = True
        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 izip(ENCODER_HARDWARE_IDS, ENCODER_MSG_IDS):
            self._setup_hardware_encoder(hardware_id, identifier, ENCODER_CHANNEL)

        for hardware_id, identifier in izip(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.itervalues():
            self._setup_hardware_button(hardware_id, identifier)

        for hardware_id, identifier in izip(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 _create_drums(self):
     self._drums = DrumRackComponent(name='Drums', is_enabled=False, layer=Layer(pads=self._pads))
     self._drums.set_enabled(True)
Example #17
0
    def __init__(self, *a, **k):
        super(MPK261MX, self).__init__(*a, **k)
        self.show_message(
            "-----------------------= MPK261MX LOADING - maxcloutier13 says hi =----------------------------------------------------------"
        )
        self.log_message(
            "-----------------------= MPK261MX LOADING - maxcloutier13 says hi =----------------------------------------------------------"
        )
        with self.component_guard():
            midimap = MidiMap()
            #Super crude manual init for the custom buttons and faders
            #Bank A - Channel 1 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            self._Encoder0 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                22,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder0')
            self._Encoder1 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                23,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder1')
            self._Encoder2 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                24,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder2')
            self._Encoder3 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                25,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder3')
            self._Encoder4 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                26,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder4')
            self._Encoder5 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                27,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder5')
            self._Encoder6 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                28,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder6')
            self._Encoder7 = EncoderElement(
                MIDI_CC_TYPE,
                1,
                29,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder7')
            self._ArmButton0 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             32,
                                             name='ArmButton0')
            self._ArmButton1 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             33,
                                             name='ArmButton1')
            self._ArmButton2 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             34,
                                             name='ArmButton2')
            self._ArmButton3 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             35,
                                             name='ArmButton3')
            self._ArmButton4 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             36,
                                             name='ArmButton4')
            self._ArmButton5 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             37,
                                             name='ArmButton5')
            self._ArmButton6 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             38,
                                             name='ArmButton6')
            self._ArmButton7 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             39,
                                             name='ArmButton7')
            self._VolumeSlider0 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                12,
                                                name='VolumeSlider0')
            self._VolumeSlider1 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                13,
                                                name='VolumeSlider1')
            self._VolumeSlider2 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                14,
                                                name='VolumeSlider2')
            self._VolumeSlider3 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                15,
                                                name='VolumeSlider3')
            self._VolumeSlider4 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                16,
                                                name='VolumeSlider4')
            self._VolumeSlider5 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                17,
                                                name='VolumeSlider5')
            self._VolumeSlider6 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                18,
                                                name='VolumeSlider6')
            self._VolumeSlider7 = SliderElement(MIDI_CC_TYPE,
                                                0,
                                                19,
                                                name='VolumeSlider7')
            #Bank B - Channel 2 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            self._Encoder8 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                22,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder8')
            self._Encoder9 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                23,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder9')
            self._Encoder10 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                24,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder10')
            self._Encoder11 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                25,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder11')
            self._Encoder12 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                26,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder12')
            self._Encoder13 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                27,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder13')
            self._Encoder14 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                28,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder14')
            self._Encoder15 = EncoderElement(
                MIDI_CC_TYPE,
                2,
                29,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder15')
            self._ArmButton8 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             1,
                                             32,
                                             name='ArmButton8')
            self._ArmButton9 = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             1,
                                             33,
                                             name='ArmButton9')
            self._ArmButton10 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              1,
                                              34,
                                              name='ArmButton10')
            self._ArmButton11 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              1,
                                              35,
                                              name='ArmButton11')
            self._ArmButton12 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              1,
                                              36,
                                              name='ArmButton12')
            self._ArmButton13 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              1,
                                              37,
                                              name='ArmButton13')
            self._ArmButton14 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              1,
                                              38,
                                              name='ArmButton14')
            self._ArmButton15 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              1,
                                              39,
                                              name='ArmButton15')
            self._VolumeSlider8 = SliderElement(MIDI_CC_TYPE,
                                                1,
                                                12,
                                                name='VolumeSlider8')
            self._VolumeSlider9 = SliderElement(MIDI_CC_TYPE,
                                                1,
                                                13,
                                                name='VolumeSlider9')
            self._VolumeSlider10 = SliderElement(MIDI_CC_TYPE,
                                                 1,
                                                 14,
                                                 name='VolumeSlider10')
            self._VolumeSlider11 = SliderElement(MIDI_CC_TYPE,
                                                 1,
                                                 15,
                                                 name='VolumeSlider11')
            self._VolumeSlider12 = SliderElement(MIDI_CC_TYPE,
                                                 1,
                                                 16,
                                                 name='VolumeSlider12')
            self._VolumeSlider13 = SliderElement(MIDI_CC_TYPE,
                                                 1,
                                                 17,
                                                 name='VolumeSlider13')
            self._VolumeSlider14 = SliderElement(MIDI_CC_TYPE,
                                                 1,
                                                 18,
                                                 name='VolumeSlider14')
            self._VolumeSlider15 = SliderElement(MIDI_CC_TYPE,
                                                 1,
                                                 19,
                                                 name='VolumeSlider15')
            #Bank C - Channel 3 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            self._Encoder16 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                22,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder16')
            self._Encoder17 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                23,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder17')
            self._Encoder18 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                24,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder18')
            self._Encoder19 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                25,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder19')
            self._Encoder20 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                26,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder20')
            self._Encoder21 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                27,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder21')
            self._Encoder22 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                28,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder22')
            self._Encoder23 = EncoderElement(
                MIDI_CC_TYPE,
                3,
                29,
                Live.MidiMap.MapMode.relative_two_compliment,
                name='Encoder23')
            self._ArmButton16 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              32,
                                              name='ArmButton16')
            self._ArmButton17 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              33,
                                              name='ArmButton17')
            self._ArmButton18 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              34,
                                              name='ArmButton18')
            self._ArmButton19 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              35,
                                              name='ArmButton19')
            self._ArmButton20 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              36,
                                              name='ArmButton20')
            self._ArmButton21 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              37,
                                              name='ArmButton21')
            self._ArmButton22 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              38,
                                              name='ArmButton22')
            self._ArmButton23 = ButtonElement(False,
                                              MIDI_CC_TYPE,
                                              2,
                                              39,
                                              name='ArmButton23')
            self._VolumeSlider16 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 12,
                                                 name='VolumeSlider16')
            self._VolumeSlider17 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 13,
                                                 name='VolumeSlider17')
            self._VolumeSlider18 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 14,
                                                 name='VolumeSlider18')
            self._VolumeSlider19 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 15,
                                                 name='VolumeSlider19')
            self._VolumeSlider20 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 16,
                                                 name='VolumeSlider20')
            self._VolumeSlider21 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 17,
                                                 name='VolumeSlider21')
            self._VolumeSlider22 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 18,
                                                 name='VolumeSlider22')
            self._VolumeSlider23 = SliderElement(MIDI_CC_TYPE,
                                                 2,
                                                 19,
                                                 name='VolumeSlider23')
            #Drum rack -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            drum_rack = DrumRackComponent(
                name='Drum_Rack',
                is_enabled=False,
                layer=Layer(pads=midimap['Drum_Pads']))
            drum_rack.set_enabled(True)
            #Transport -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            transport = TransportComponent(name='Transport',
                                           is_enabled=False,
                                           layer=Layer(
                                               play_button=midimap['Play'],
                                               record_button=midimap['Record'],
                                               stop_button=midimap['Stop'],
                                               loop_button=midimap['Loop']))
            #, seek_forward_button=midimap['Forward'], seek_backward_button=midimap['Backward']
            transport.set_enabled(True)
            #Make the Back/Fwd button just normal mapable CC senders
            self._BackButton = ButtonElement(False,
                                             MIDI_CC_TYPE,
                                             0,
                                             116,
                                             name='BackButton')
            self._FwdButton = ButtonElement(False,
                                            MIDI_CC_TYPE,
                                            0,
                                            115,
                                            name='FwdButton')
            #Device -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            self._device = DeviceComponent(
                name='Device',
                is_enabled=False,
                layer=Layer(parameter_controls=midimap['Encoders']),
                device_selection_follows_track_selection=True)
            self._device.set_enabled(True)
            self.set_device_component(self._device)
            #Mixer -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            mixer_size = 24
            self._mixer = MixerComponent(mixer_size,
                                         name='Mixer',
                                         is_enabled=False)
            #Super crude and repetitive mapping because after all this shit I'm not spending time learning how to loop this crap hehe
            #Bank A
            self._mixer.channel_strip(0).layer = Layer(
                volume_control=self._VolumeSlider0,
                arm_button=self._ArmButton0,
                pan_control=self._Encoder0)
            self._mixer.channel_strip(1).layer = Layer(
                volume_control=self._VolumeSlider1,
                arm_button=self._ArmButton1,
                pan_control=self._Encoder1)
            self._mixer.channel_strip(2).layer = Layer(
                volume_control=self._VolumeSlider2,
                arm_button=self._ArmButton2,
                pan_control=self._Encoder2)
            self._mixer.channel_strip(3).layer = Layer(
                volume_control=self._VolumeSlider3,
                arm_button=self._ArmButton3,
                pan_control=self._Encoder3)
            self._mixer.channel_strip(4).layer = Layer(
                volume_control=self._VolumeSlider4,
                arm_button=self._ArmButton4,
                pan_control=self._Encoder4)
            self._mixer.channel_strip(5).layer = Layer(
                volume_control=self._VolumeSlider5,
                arm_button=self._ArmButton5,
                pan_control=self._Encoder5)
            self._mixer.channel_strip(6).layer = Layer(
                volume_control=self._VolumeSlider6,
                arm_button=self._ArmButton6,
                pan_control=self._Encoder6)
            self._mixer.channel_strip(7).layer = Layer(
                volume_control=self._VolumeSlider7,
                arm_button=self._ArmButton7,
                pan_control=self._Encoder7)
            #Bank B
            self._mixer.channel_strip(8).layer = Layer(
                volume_control=self._VolumeSlider8,
                arm_button=self._ArmButton8,
                pan_control=self._Encoder8)
            self._mixer.channel_strip(9).layer = Layer(
                volume_control=self._VolumeSlider9,
                arm_button=self._ArmButton9,
                pan_control=self._Encoder9)
            self._mixer.channel_strip(10).layer = Layer(
                volume_control=self._VolumeSlider10,
                arm_button=self._ArmButton10,
                pan_control=self._Encoder10)
            self._mixer.channel_strip(11).layer = Layer(
                volume_control=self._VolumeSlider11,
                arm_button=self._ArmButton11,
                pan_control=self._Encoder11)
            self._mixer.channel_strip(12).layer = Layer(
                volume_control=self._VolumeSlider12,
                arm_button=self._ArmButton12,
                pan_control=self._Encoder12)
            self._mixer.channel_strip(13).layer = Layer(
                volume_control=self._VolumeSlider13,
                arm_button=self._ArmButton13,
                pan_control=self._Encoder13)
            self._mixer.channel_strip(14).layer = Layer(
                volume_control=self._VolumeSlider14,
                arm_button=self._ArmButton14,
                pan_control=self._Encoder14)
            self._mixer.channel_strip(15).layer = Layer(
                volume_control=self._VolumeSlider15,
                arm_button=self._ArmButton15,
                pan_control=self._Encoder15)
            #Bank C
            self._mixer.channel_strip(16).layer = Layer(
                volume_control=self._VolumeSlider16,
                arm_button=self._ArmButton16,
                pan_control=self._Encoder16)
            self._mixer.channel_strip(17).layer = Layer(
                volume_control=self._VolumeSlider17,
                arm_button=self._ArmButton17,
                pan_control=self._Encoder17)
            self._mixer.channel_strip(18).layer = Layer(
                volume_control=self._VolumeSlider18,
                arm_button=self._ArmButton18,
                pan_control=self._Encoder18)
            self._mixer.channel_strip(19).layer = Layer(
                volume_control=self._VolumeSlider19,
                arm_button=self._ArmButton19,
                pan_control=self._Encoder19)
            self._mixer.channel_strip(20).layer = Layer(
                volume_control=self._VolumeSlider20,
                arm_button=self._ArmButton20,
                pan_control=self._Encoder20)
            self._mixer.channel_strip(21).layer = Layer(
                volume_control=self._VolumeSlider21,
                arm_button=self._ArmButton21,
                pan_control=self._Encoder21)
            self._mixer.channel_strip(22).layer = Layer(
                volume_control=self._VolumeSlider22,
                arm_button=self._ArmButton22,
                pan_control=self._Encoder22)
            self._mixer.channel_strip(23).layer = Layer(
                volume_control=self._VolumeSlider23,
                arm_button=self._ArmButton23,
                pan_control=self._Encoder23)
            self._mixer.set_enabled(True)


#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------