コード例 #1
0
    def _setup_session(self):
        scene_launch_button = self._control_factory.create_scene_launch_button(
        )
        scene_stop_button = self._control_factory.create_scene_stop_button()
        self._session = SessionComponent(8, 0)
        self._session.name = 'Session_Control'
        self._session.selected_scene().name = 'Selected_Scene'
        self._session.selected_scene().set_launch_button(scene_launch_button)
        self._session.selected_scene().set_triggered_value(GREEN_BLINK)
        self._session.set_stop_all_clips_button(scene_stop_button)
        scene_stop_button.set_on_off_values(AMBER_FULL, LED_OFF)
        self._session.set_mixer(self._mixer)
        self._session.set_stop_clip_value(AMBER_HALF)
        self._session.set_stop_clip_triggered_value(GREEN_BLINK)
        clip_launch_buttons = []
        clip_stop_buttons = []
        for index in range(8):
            clip_launch_buttons.append(
                self._control_factory.create_clip_launch_button(index))
            clip_stop_buttons.append(
                self._control_factory.create_clip_stop_button(index))
            clip_slot = self._session.selected_scene().clip_slot(index)
            clip_slot.set_triggered_to_play_value(GREEN_BLINK)
            clip_slot.set_triggered_to_record_value(RED_BLINK)
            clip_slot.set_stopped_value(AMBER_FULL)
            clip_slot.set_started_value(GREEN_FULL)
            clip_slot.set_recording_value(RED_FULL)
            clip_slot.set_launch_button(clip_launch_buttons[(-1)])
            clip_slot.name = 'Selected_Clip_Slot_' + str(index)

        self._session.set_stop_track_clip_buttons(tuple(clip_stop_buttons))
コード例 #2
0
 def _setup_session(self):
     num_pads = len(PAD_TRANSLATIONS)
     self._track_left_button = ButtonElement(not IS_MOMENTARY, MIDI_CC_TYPE,
                                             0, 36)
     self._track_right_button = ButtonElement(not IS_MOMENTARY,
                                              MIDI_CC_TYPE, 0, 35)
     self._session = SessionComponent(8, 0)
     self._session.name = 'Session_Control'
     self._session.selected_scene().name = 'Selected_Scene'
     self._session.set_mixer(self._mixer)
     self._session.set_page_left_button(self._track_left_button)
     self._session.set_page_right_button(self._track_right_button)
     pads = []
     for index in range(num_pads):
         pads.append(
             ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 60 + index))
         pads[(-1)].name = 'Pad_' + str(index)
         clip_slot = self._session.selected_scene().clip_slot(index)
         clip_slot.set_triggered_to_play_value(GREEN_BLINK)
         clip_slot.set_triggered_to_record_value(RED_BLINK)
         clip_slot.set_stopped_value(AMBER_FULL)
         clip_slot.set_started_value(GREEN_FULL)
         clip_slot.set_recording_value(RED_FULL)
         clip_slot.set_launch_button(pads[(-1)])
         clip_slot.name = str(index) + '_Selected_Clip_Slot'
コード例 #3
0
 def on_selected_track_changed(self):
     SessionComponent.on_selected_track_changed(self)
     selected_track = self.song().view.selected_track
     tracks = self.tracks_to_use()
     if selected_track in tracks:
         track_index = list(tracks).index(selected_track)
         new_offset = track_index - track_index % self._num_tracks
         self.set_offsets(new_offset, self.scene_offset())
コード例 #4
0
 def _create_session(self):
     session = SessionComponent(num_tracks=NUM_TRACKS,
                                is_enabled=True,
                                auto_name=True,
                                enable_skinning=True)
     session.layer = Layer(track_bank_left_button=(self._left_button),
                           track_bank_right_button=(self._right_button))
     self._on_session_offset_changed.subject = session
     return session
コード例 #5
0
 def disconnect(self):
     SessionComponent.disconnect(self)
     self._alt_mixer = None
     if self._next_track_button != None:
         self._next_track_button.remove_value_listener(
             self._next_track_value)
         self._next_track_button = None
     if self._prev_track_button != None:
         self._prev_track_button.remove_value_listener(
             self._prev_track_value)
         self._prev_track_button = None
コード例 #6
0
 def _setup_session(self):
     self._session = SessionComponent(NUM_CHANNEL_STRIPS, name='Session_Control')
     self._session.set_enabled(False)
     stop_buttons = ButtonMatrixElement(name='Track_Stop_Buttons',
       rows=[self._shifted_solo_buttons])
     self._session.layer = Layer(stop_all_clips_button=(self._shifted_stop_button),
       stop_track_clip_buttons=stop_buttons,
       select_prev_button=(self._shifted_octave_down_button),
       select_next_button=(self._shifted_octave_up_button))
     self._session.selected_scene().name = 'Selected_Scene_Control'
     self._session.selected_scene().layer = Layer(launch_button=(self._shifted_play_button))
     for index in range(NUM_CHANNEL_STRIPS):
         slot = self._session.selected_scene().clip_slot(index)
         slot.layer = Layer(launch_button=(self._shifted_mute_buttons[index]))
コード例 #7
0
 def _setup_session_control(self):
     is_momentary = True
     down_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 12, 89)
     up_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 12, 90)
     session = SessionComponent(NUM_TRACKS, 0)
     session.set_select_buttons(down_button, up_button)
     session.selected_scene().set_launch_button(
         ButtonElement(is_momentary, MIDI_NOTE_TYPE, 12, 87))
     track_stop_buttons = [
         ButtonElement(is_momentary, MIDI_NOTE_TYPE, index, 68)
         for index in range(NUM_TRACKS)
     ]
     session.set_stop_track_clip_buttons(tuple(track_stop_buttons))
     for index in range(NUM_TRACKS):
         session.selected_scene().clip_slot(index).set_launch_button(
             ButtonElement(is_momentary, MIDI_NOTE_TYPE, index, 69))
コード例 #8
0
    def _create_session(self):
        session = SessionComponent((self.SESSION_WIDTH),
          (self.SESSION_HEIGHT),
          auto_name=True,
          enable_skinning=True,
          is_enabled=False,
          layer=Layer(scene_launch_buttons=(self.wrap_matrix(self._scene_launch_buttons)),
          clip_launch_buttons=(self._session_matrix),
          stop_all_clips_button=(self._stop_all_button),
          track_bank_left_button=(self._left_button),
          track_bank_right_button=(self._right_button),
          scene_bank_up_button=(self._up_button),
          scene_bank_down_button=(self._down_button)))
        for scene_index in range(self.SESSION_HEIGHT):
            for track_index in range(self.SESSION_WIDTH):
                slot = session.scene(scene_index).clip_slot(track_index)
                slot.layer = Layer(select_button=(self._shift_button))

        return session
コード例 #9
0
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        with self.component_guard():
            is_momentary = True
            self._suggested_input_port = 'Oxygen'
            self._suggested_output_port = 'Oxygen'
            self._has_slider_section = True
            self._shift_button = ButtonElement(is_momentary, MIDI_CC_TYPE,
                                               GLOBAL_CHANNEL, 57)
            self._shift_button.add_value_listener(self._shift_value)
            self._mixer = SpecialMixerComponent(NUM_TRACKS)
            self._mute_solo_buttons = []
            self._track_up_button = ButtonElement(is_momentary, MIDI_CC_TYPE,
                                                  GLOBAL_CHANNEL, 111)
            self._track_down_button = ButtonElement(is_momentary, MIDI_CC_TYPE,
                                                    GLOBAL_CHANNEL, 110)
            self._master_slider = SliderElement(MIDI_CC_TYPE, GLOBAL_CHANNEL,
                                                41)
            for index in range(NUM_TRACKS):
                self._mute_solo_buttons.append(
                    ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL,
                                  49 + index))
                self._mixer.channel_strip(index).set_volume_control(
                    SliderElement(MIDI_CC_TYPE, GLOBAL_CHANNEL, 33 + index))

            self._shift_value(0)
            self._mixer.master_strip().set_volume_control(self._master_slider)
            self._mixer.selected_strip().set_volume_control(None)
            device = DeviceComponent(
                device_selection_follows_track_selection=True)
            device.set_parameter_controls(
                tuple([
                    EncoderElement(MIDI_CC_TYPE, GLOBAL_CHANNEL, 17 + index,
                                   Live.MidiMap.MapMode.absolute)
                    for index in range(8)
                ]))
            self.set_device_component(device)
            ffwd_button = ButtonElement(is_momentary, MIDI_CC_TYPE,
                                        GLOBAL_CHANNEL, 115)
            rwd_button = ButtonElement(is_momentary, MIDI_CC_TYPE,
                                       GLOBAL_CHANNEL, 114)
            loop_button = ButtonElement(is_momentary, MIDI_CC_TYPE,
                                        GLOBAL_CHANNEL, 113)
            transport = TransportComponent()
            transport.set_stop_button(
                ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 116))
            transport.set_play_button(
                ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 117))
            transport.set_record_button(
                ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 118))
            session = SessionComponent(0, 0)
            transport_view_modes = TransportViewModeSelector(
                transport, session, ffwd_button, rwd_button, loop_button)
コード例 #10
0
    def _setup_mixer_control(self):
        is_momentary = True
        num_tracks = 8
        num_returns = 7
        mixer = MixerComponent(num_tracks, num_returns)
        for track in range(num_tracks):
            strip = mixer.channel_strip(track)
            strip.set_volume_control(
                SliderElement(MIDI_CC_TYPE, 15, 54 - track))
            strip.set_pan_control(SliderElement(MIDI_CC_TYPE, 15, 80 - track))
            strip.set_mute_button(
                ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 117 - track))
            strip.set_invert_mute_feedback(True)

        for track in range(num_returns):
            strip = mixer.return_strip(track)
            strip.set_volume_control(
                SliderElement(MIDI_CC_TYPE, 15, 10 + track))

        mixer.set_bank_buttons(
            ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 108),
            ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 109))
        mixer.set_crossfader_control(SliderElement(MIDI_CC_TYPE, 15, 9))
        mixer.master_strip().set_volume_control(
            SliderElement(MIDI_CC_TYPE, 15, 46))
        session = SessionComponent(0, 0)
        session.set_select_buttons(
            ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 95),
            ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 92))
        session.selected_scene().set_launch_button(
            ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 91))
コード例 #11
0
 def __init__(self, c_instance):
     ControlSurface.__init__(self, c_instance)
     with self.component_guard():
         self._suggested_input_port = 'HyperControl'
         self._suggested_output_port = 'HyperControl'
         self.set_pad_translations(PAD_TRANSLATIONS)
         stop_button = make_button(116)
         play_button = make_button(117)
         record_button = make_button(118)
         select_button = make_button(98)
         nav_left_button = make_button(99)
         nav_right_button = make_button(100)
         nav_up_button = make_button(101)
         nav_down_button = make_button(102)
         mixer_modes_toggle = make_button(58)
         mixer_or_device_toggle = make_button(59)
         hypercontrol_mode_toggle = make_button(60)
         encoders = tuple([make_encoder(33 + index) for index in range(8)])
         transport = TransportComponent()
         transport.set_stop_button(stop_button)
         transport.set_play_button(play_button)
         transport.set_record_button(record_button)
         session = SessionComponent(8, 0)
         device = BestBankDeviceComponent(
             device_selection_follows_track_selection=True)
         self.set_device_component(device)
         device_nav = DeviceNavComponent()
         mixer = SpecialMixerComponent(NUM_TRACKS)
         session.set_mixer(mixer)
         mixer_encoder_modes = EncoderMixerModeSelector(mixer)
         mixer_encoder_modes.set_mode_toggle(mixer_modes_toggle)
         mixer_or_device = MixerOrDeviceModeSelector(
             encoders, select_button, nav_up_button, nav_down_button,
             nav_left_button, nav_right_button, mixer, session, device,
             mixer_encoder_modes, device_nav)
         mixer_or_device.set_mode_buttons(
             (mixer_modes_toggle, mixer_or_device_toggle,
              hypercontrol_mode_toggle))
コード例 #12
0
class KeyPad(ControlSurface):
    _encoder_range = list(range(73, 81))
    _product_model_id = 101

    def __init__(self, c_instance):
        super(KeyPad, self).__init__(c_instance)
        with self.component_guard():
            self._create_controls()
            self._setup_mixer()
            self._setup_transport()
            self._setup_session()
            self._setup_cue_control()
            self.set_pad_translations(PAD_TRANSLATIONS)

    def _preset_message(self, send_byte):
        return (
         240, 38, self._product_model_id, send_byte, 17, 2, 247)

    def refresh_state(self):
        super(KeyPad, self).refresh_state()
        self.schedule_message(2, self._send_midi, self._preset_message(1))

    def handle_sysex(self, midi_bytes):
        if midi_bytes != self._preset_message(2):
            super(KeyPad, self).handle_sysex(midi_bytes)
        else:
            list(map(lambda x: x.set_enabled(True), (
             self._mixer, self._session, self._transport, self._cue_control)))

    def _create_controls(self):

        def make_controls_range(maker, label, cc_range):
            ccs = [(index + 1, cc) for index, cc in enumerate(cc_range)]
            return [maker(1, cc, label % index) for index, cc in ccs] + [maker(2, cc, label % (index + len(ccs))) for index, cc in ccs]

        def make_controls(maker, label, cc_offset):
            return make_controls_range(maker, label, range(cc_offset, cc_offset + 8))

        make_non_momentary_button = partial(make_button, is_momentary=False)
        self._encoders = make_controls(make_encoder, 'Encoder_%d', 57)
        self._rotaries_a = make_controls(make_slider, 'Rotary_A%d', 89)
        self._rotaries_b = make_controls(make_slider, 'Rotary_B%d', 97)
        self._faders = make_controls(make_slider, 'Fader_%d', 0)
        self._mute_buttons = make_controls(make_non_momentary_button, 'Mute_%d_Button', 8)
        self._solo_buttons = make_controls(make_button, 'Solo_%d_Button', 24)
        self._arm_buttons = make_controls(make_button, 'Arm_%d_Button', 40)
        self._play_button = make_button(1, 105, 'Play_Button')
        self._stop_button = make_button(1, 106, 'Stop_Button')
        self._record_button = make_button(1, 107, 'Record_Button')
        self._encoder_pushes = make_controls_range(partial(make_button, is_momentary=False), 'Encoder_%d_Button', self._encoder_range)
        self._shifted_mute_buttons = make_controls(make_non_momentary_button, 'Shifted_Mute_%d_Button', 16)
        self._shifted_solo_buttons = make_controls(make_button, 'Shifted_Solo_%d_Button', 32)
        self._all_shifted_arm_buttons = make_controls(make_button, 'Shifted_Arm_%d_Button', 49)
        self._shifted_arm_buttons = [CombinedButtonsElement(buttons=(self._all_shifted_arm_buttons[index], self._all_shifted_arm_buttons[(index + 8)])) for index in range(8)]
        self._shifted_play_button = make_button(1, 108, 'Shifted_Play_Button')
        self._shifted_stop_button = make_button(1, 109, 'Shifted_Stop_Button')
        self._shifted_record_button = make_button(1, 110, 'Shifted_Record_Button')
        self._shifted_octave_down_button = make_button(1, 111, 'Shifted_Octave_Down_Button')
        self._shifted_octave_up_button = make_button(1, 112, 'Shifted_Octave_Up_Button')

    def _setup_mixer(self):
        self._mixer = MixerComponent(NUM_CHANNEL_STRIPS)
        self._mixer.name = 'Mixer'
        self._mixer.set_enabled(False)
        for index in range(NUM_CHANNEL_STRIPS):
            strip = self._mixer.channel_strip(index)
            strip.set_invert_mute_feedback(True)
            sends = ButtonMatrixElement(name=('%d_Send_Controls' % (index + 1)),
              rows=[
             (
              self._rotaries_a[index], self._rotaries_b[index])])
            strip.layer = Layer(volume_control=(self._faders[index]),
              pan_control=(self._encoders[index]),
              send_controls=sends,
              mute_button=(self._mute_buttons[index]),
              solo_button=(self._solo_buttons[index]),
              arm_button=(self._arm_buttons[index]),
              select_button=(self._encoder_pushes[index]))

    def _setup_transport(self):
        self._transport = TransportComponent(name='Transport')
        self._transport.set_enabled(False)
        self._transport.layer = Layer(play_button=(self._play_button),
          stop_button=(self._stop_button),
          record_button=(self._record_button),
          overdub_button=(self._shifted_record_button),
          loop_button=(self._shifted_arm_buttons[3]),
          tap_tempo_button=(self._shifted_arm_buttons[4]),
          metronome_button=(self._shifted_arm_buttons[5]),
          nudge_down_button=(self._shifted_arm_buttons[6]),
          nudge_up_button=(self._shifted_arm_buttons[7]))

    def _setup_session(self):
        self._session = SessionComponent(NUM_CHANNEL_STRIPS, name='Session_Control')
        self._session.set_enabled(False)
        stop_buttons = ButtonMatrixElement(name='Track_Stop_Buttons',
          rows=[self._shifted_solo_buttons])
        self._session.layer = Layer(stop_all_clips_button=(self._shifted_stop_button),
          stop_track_clip_buttons=stop_buttons,
          select_prev_button=(self._shifted_octave_down_button),
          select_next_button=(self._shifted_octave_up_button))
        self._session.selected_scene().name = 'Selected_Scene_Control'
        self._session.selected_scene().layer = Layer(launch_button=(self._shifted_play_button))
        for index in range(NUM_CHANNEL_STRIPS):
            slot = self._session.selected_scene().clip_slot(index)
            slot.layer = Layer(launch_button=(self._shifted_mute_buttons[index]))

    def _setup_cue_control(self):
        self._cue_control = CuePointControlComponent(name='Cue_Point_Control')
        self._cue_control.set_enabled(False)
        self._cue_control.layer = Layer(toggle_cue_button=(self._shifted_arm_buttons[0]),
          prev_cue_button=(self._shifted_arm_buttons[1]),
          next_cue_button=(self._shifted_arm_buttons[2]))
コード例 #13
0
class Novation_Impulse(ControlSurface):
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        with self.component_guard():
            self.set_pad_translations(PAD_TRANSLATIONS)
            self._suggested_input_port = 'Impulse'
            self._suggested_output_port = 'Impulse'
            self._has_sliders = True
            self._current_midi_map = None
            self._display_reset_delay = -1
            self._shift_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0,
                                               39)
            self._preview_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0,
                                                 41)
            self._master_slider = SliderElement(MIDI_CC_TYPE, 0, 8)
            self._shift_button.name = 'Shift_Button'
            self._master_slider.name = 'Master_Volume_Control'
            self._master_slider.add_value_listener((self._slider_value),
                                                   identify_sender=True)
            self._preview_button.add_value_listener(self._preview_value)
            self._setup_mixer()
            self._setup_session()
            self._setup_transport()
            self._setup_device()
            self._setup_name_display()
            device_button = ButtonElement(not IS_MOMENTARY, MIDI_CC_TYPE, 1,
                                          10)
            mixer_button = ButtonElement(not IS_MOMENTARY, MIDI_CC_TYPE, 1, 9)
            device_button.name = 'Encoder_Device_Mode'
            mixer_button.name = 'Encoder_Mixer_Mode'
            self._encoder_modes = EncoderModeSelector(self._device_component,
                                                      self._mixer,
                                                      self._next_bank_button,
                                                      self._prev_bank_button,
                                                      self._encoders)
            self._encoder_modes.set_device_mixer_buttons(
                device_button, mixer_button)
            self._string_to_display = None
            for component in self.components:
                component.set_enabled(False)

    def refresh_state(self):
        ControlSurface.refresh_state(self)
        self.schedule_message(3, self._send_midi,
                              SYSEX_START + (6, 1, 1, 1, 247))

    def handle_sysex(self, midi_bytes):
        if midi_bytes[0:-2] == SYSEX_START + (7, ):
            if midi_bytes[(-2)] != 0:
                self._has_sliders = midi_bytes[(-2)] != 25
                self.schedule_message(1, self._show_startup_message)
                for control in self.controls:
                    if isinstance(control, InputControlElement):
                        control.clear_send_cache()

                for component in self.components:
                    component.set_enabled(True)

                if self._has_sliders:
                    self._mixer.master_strip().set_volume_control(
                        self._master_slider)
                    self._mixer.update()
                else:
                    self._mixer.master_strip().set_volume_control(None)
                    self._mixer.selected_strip().set_volume_control(
                        self._master_slider)
                    for index in range(len(self._sliders)):
                        self._mixer.channel_strip(index).set_volume_control(
                            None)
                        slider = self._sliders[index]
                        slider.release_parameter()
                        if slider.value_has_listener(self._slider_value):
                            slider.remove_value_listener(self._slider_value)

                self._encoder_modes.set_provide_volume_mode(
                    not self._has_sliders)
                self.request_rebuild_midi_map()

    def disconnect(self):
        self._name_display_data_source.set_display_string('  ')
        for encoder in self._encoders:
            encoder.remove_value_listener(self._encoder_value)

        self._master_slider.remove_value_listener(self._slider_value)
        if self._has_sliders:
            for slider in tuple(self._sliders):
                slider.remove_value_listener(self._slider_value)

        for button in self._strip_buttons:
            button.remove_value_listener(self._mixer_button_value)

        self._preview_button.remove_value_listener(self._preview_value)
        ControlSurface.disconnect(self)
        self._encoders = None
        self._sliders = None
        self._strip_buttons = None
        self._master_slider = None
        self._current_midi_map = None
        self._shift_button = None
        self._name_display = None
        self._prev_bank_button = None
        self._next_bank_button = None
        self._encoder_modes = None
        self._transport_view_modes = None
        self._send_midi(SYSEX_START + (6, 0, 0, 0, 247))

    def build_midi_map(self, midi_map_handle):
        self._current_midi_map = midi_map_handle
        ControlSurface.build_midi_map(self, midi_map_handle)

    def update_display(self):
        ControlSurface.update_display(self)
        if self._string_to_display != None:
            self._name_display_data_source.set_display_string(
                self._string_to_display)
            self._string_to_display = None
        if self._display_reset_delay >= 0:
            self._display_reset_delay -= 1
            if self._display_reset_delay == -1:
                self._show_current_track_name()

    def _setup_mixer(self):
        mute_solo_flip_button = ButtonElement(not IS_MOMENTARY, MIDI_CC_TYPE,
                                              0, 34)
        self._next_nav_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0,
                                              37)
        self._prev_nav_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0,
                                              38)
        self._strip_buttons = []
        mute_solo_flip_button.name = 'Mute_Solo_Flip_Button'
        self._next_nav_button.name = 'Next_Track_Button'
        self._prev_nav_button.name = 'Prev_Track_Button'
        self._mixer = SpecialMixerComponent(8)
        self._mixer.name = 'Mixer'
        self._mixer.set_select_buttons(self._next_nav_button,
                                       self._prev_nav_button)
        self._mixer.selected_strip().name = 'Selected_Channel_Strip'
        self._mixer.master_strip().name = 'Master_Channel_Strip'
        self._mixer.master_strip().set_volume_control(self._master_slider)
        self._sliders = []
        for index in range(8):
            strip = self._mixer.channel_strip(index)
            strip.name = 'Channel_Strip_' + str(index)
            strip.set_invert_mute_feedback(True)
            self._sliders.append(SliderElement(MIDI_CC_TYPE, 0, index))
            self._sliders[(-1)].name = str(index) + '_Volume_Control'
            self._sliders[(-1)].set_feedback_delay(-1)
            self._sliders[(-1)].add_value_listener((self._slider_value),
                                                   identify_sender=True)
            strip.set_volume_control(self._sliders[(-1)])
            self._strip_buttons.append(
                ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 9 + index))
            self._strip_buttons[(-1)].name = str(index) + '_Mute_Button'
            self._strip_buttons[(-1)].add_value_listener(
                (self._mixer_button_value), identify_sender=True)

        self._mixer.master_strip().set_mute_button(
            ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 1, 17))
        self._mixer.set_strip_mute_solo_buttons(tuple(self._strip_buttons),
                                                mute_solo_flip_button)

    def _setup_session(self):
        num_pads = len(PAD_TRANSLATIONS)
        self._track_left_button = ButtonElement(not IS_MOMENTARY, MIDI_CC_TYPE,
                                                0, 36)
        self._track_right_button = ButtonElement(not IS_MOMENTARY,
                                                 MIDI_CC_TYPE, 0, 35)
        self._session = SessionComponent(8, 0)
        self._session.name = 'Session_Control'
        self._session.selected_scene().name = 'Selected_Scene'
        self._session.set_mixer(self._mixer)
        self._session.set_page_left_button(self._track_left_button)
        self._session.set_page_right_button(self._track_right_button)
        pads = []
        for index in range(num_pads):
            pads.append(
                ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 60 + index))
            pads[(-1)].name = 'Pad_' + str(index)
            clip_slot = self._session.selected_scene().clip_slot(index)
            clip_slot.set_triggered_to_play_value(GREEN_BLINK)
            clip_slot.set_triggered_to_record_value(RED_BLINK)
            clip_slot.set_stopped_value(AMBER_FULL)
            clip_slot.set_started_value(GREEN_FULL)
            clip_slot.set_recording_value(RED_FULL)
            clip_slot.set_launch_button(pads[(-1)])
            clip_slot.name = str(index) + '_Selected_Clip_Slot'

    def _setup_transport(self):
        rwd_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 27)
        ffwd_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 28)
        stop_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 29)
        play_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 30)
        loop_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 31)
        rec_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 0, 32)
        ffwd_button.name = 'FFwd_Button'
        rwd_button.name = 'Rwd_Button'
        loop_button.name = 'Loop_Button'
        play_button.name = 'Play_Button'
        stop_button.name = 'Stop_Button'
        rec_button.name = 'Record_Button'
        transport = ShiftableTransportComponent()
        transport.name = 'Transport'
        transport.set_stop_button(stop_button)
        transport.set_play_button(play_button)
        transport.set_record_button(rec_button)
        transport.set_shift_button(self._shift_button)
        self._transport_view_modes = TransportViewModeSelector(
            transport, self._session, ffwd_button, rwd_button, loop_button)
        self._transport_view_modes.name = 'Transport_View_Modes'

    def _setup_device(self):
        encoders = []
        for index in range(8):
            encoders.append(
                PeekableEncoderElement(
                    MIDI_CC_TYPE, 1, index,
                    Live.MidiMap.MapMode.relative_binary_offset))
            encoders[(-1)].set_feedback_delay(-1)
            encoders[(-1)].add_value_listener((self._encoder_value),
                                              identify_sender=True)
            encoders[(-1)].name = 'Device_Control_' + str(index)

        self._encoders = tuple(encoders)
        self._prev_bank_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 1,
                                               12)
        self._next_bank_button = ButtonElement(IS_MOMENTARY, MIDI_CC_TYPE, 1,
                                               11)
        self._prev_bank_button.name = 'Device_Bank_Down_Button'
        self._next_bank_button.name = 'Device_Bank_Up_Button'
        device = DeviceComponent(device_selection_follows_track_selection=True)
        device.name = 'Device_Component'
        self.set_device_component(device)
        device.set_parameter_controls(self._encoders)
        device.set_bank_nav_buttons(self._prev_bank_button,
                                    self._next_bank_button)

    def _setup_name_display(self):
        self._name_display = PhysicalDisplayElement(16, 1)
        self._name_display.name = 'Display'
        self._name_display.set_message_parts(SYSEX_START + (8, ), (247, ))
        self._name_display_data_source = DisplayDataSource()
        self._name_display.segment(0).set_data_source(
            self._name_display_data_source)

    def _encoder_value(self, value, sender):
        if self._device_component.is_enabled():
            display_string = ' - '
            if sender.mapped_parameter() != None:
                display_string = sender.mapped_parameter().name
            self._set_string_to_display(display_string)

    def _slider_value(self, value, sender):
        if self._mixer.is_enabled():
            display_string = ' - '
            if sender.mapped_parameter() != None:
                master = self.song().master_track
                tracks = self.song().tracks
                returns = self.song().return_tracks
                track = None
                if sender == self._master_slider:
                    if self._has_sliders:
                        track = master
                    else:
                        track = self.song().view.selected_track
                else:
                    track = self._mixer.channel_strip(
                        self._sliders.index(sender))._track
                if track == master:
                    display_string = 'Master'
                else:
                    pass
                if track in tracks:
                    display_string = str(list(tracks).index(track) + 1)
                elif track in returns:
                    display_string = str(
                        chr(ord('A') + list(returns).index(track)))
                else:
                    pass
                display_string += ' Volume'
            self._set_string_to_display(display_string)

    def _mixer_button_value(self, value, sender):
        if self._mixer.is_enabled():
            if value > 0:
                strip = self._mixer.channel_strip(
                    self._strip_buttons.index(sender))
                if strip != None:
                    self._string_to_display = None
                    self._name_display.segment(0).set_data_source(
                        strip.track_name_data_source())
                    self._name_display.update()
                    self._display_reset_delay = STANDARD_DISPLAY_DELAY
                else:
                    self._set_string_to_display(' - ')

    def _preview_value(self, value):
        for encoder in self._encoders:
            encoder.set_peek_mode(value > 0)

    def _show_current_track_name(self):
        if self._name_display != None:
            if self._mixer != None:
                self._string_to_display = None
                self._name_display.segment(0).set_data_source(
                    self._mixer.selected_strip().track_name_data_source())
                self._name_display.update()

    def _show_startup_message(self):
        self._name_display.display_message('LIVE')
        self._display_reset_delay = INITIAL_DISPLAY_DELAY

    def _set_string_to_display(self, string_to_display):
        self._name_display.segment(0).set_data_source(
            self._name_display_data_source)
        self._string_to_display = string_to_display
        self._display_reset_delay = STANDARD_DISPLAY_DELAY

    def _on_selected_track_changed(self):
        ControlSurface._on_selected_track_changed(self)
        self._show_current_track_name()
        if not self._has_sliders:
            all_tracks = self._session.tracks_to_use()
            selected_track = self.song().view.selected_track
            num_strips = self._session.width()
            if selected_track in all_tracks:
                track_index = list(all_tracks).index(selected_track)
                new_offset = track_index - track_index % num_strips
                self._session.set_offsets(new_offset,
                                          self._session.scene_offset())
コード例 #14
0
 def disconnect(self):
     SessionComponent.disconnect(self)
     if self._shift_button != None:
         self._shift_button.remove_value_listener(self._shift_value)
         self._shift_button = None
     self._clip_slot_buttons = None
コード例 #15
0
 def __init__(self, num_tracks, num_scenes):
     self._shift_button = None
     self._clip_slot_buttons = None
     SessionComponent.__init__(self, num_tracks, num_scenes)
コード例 #16
0
 def __init__(self, num_tracks, num_scenes):
     self._alt_mixer = None
     self._next_track_button = None
     self._prev_track_button = None
     SessionComponent.__init__(self, num_tracks, num_scenes)
コード例 #17
0
class Launchkey(ControlSurface):
    def __init__(self,
                 c_instance,
                 control_factory=LaunchkeyControlFactory(),
                 identity_response=SIZE_RESPONSE):
        ControlSurface.__init__(self, c_instance)
        self._control_factory = control_factory
        self._identity_response = identity_response
        with self.component_guard():
            self.set_pad_translations(PAD_TRANSLATIONS)
            self._suggested_input_port = 'Launchkey InControl'
            self._suggested_output_port = 'Launchkey InControl'
            self._has_sliders = True
            self._current_midi_map = None
            self._master_slider = make_slider(7, 'Master_Volume_Control')
            self._modes_buttons = []
            for index in range(3):
                button = ButtonElement(IS_MOMENTARY, MIDI_NOTE_TYPE, 0,
                                       13 + index)
                self._modes_buttons.append(button)
                self._modes_buttons[(-1)].add_value_listener(
                    self._dummy_listener)

            self._setup_mixer()
            self._setup_session()
            self._setup_transport()
            self._setup_device()
            self._setup_navigation()
            for component in self.components:
                component.set_enabled(False)

    def refresh_state(self):
        ControlSurface.refresh_state(self)
        self.schedule_message(2, self._send_midi, LIVE_MODE_ON)
        self.schedule_message(3, self._send_midi, SIZE_QUERY)

    def handle_sysex(self, midi_bytes):
        if midi_bytes[0:11] == self._identity_response:
            self._has_sliders = midi_bytes[11] != 48
            self._send_midi(LED_FLASHING_ON)
            self._update_mixer_offset()
            for control in self.controls:
                if isinstance(control, InputControlElement):
                    control.clear_send_cache()

            for component in self.components:
                component.set_enabled(True)

            if self._has_sliders:
                self._mixer.master_strip().set_volume_control(
                    self._master_slider)
                self._mixer.update()
            else:
                self._mixer.master_strip().set_volume_control(None)
                for index in range(len(self._sliders)):
                    self._mixer.channel_strip(index).set_volume_control(None)
                    self._mixer.channel_strip(index).set_mute_button(None)
                    slider = self._sliders[index]
                    slider.release_parameter()

                self._mixer.selected_strip().set_volume_control(
                    self._master_slider)
            self.request_rebuild_midi_map()

    def disconnect(self):
        ControlSurface.disconnect(self)
        for button in self._modes_buttons:
            if button.value_has_listener(self._dummy_listener):
                button.remove_value_listener(self._dummy_listener)

        self._modes_buttons = None
        self._encoders = None
        self._sliders = None
        self._strip_buttons = None
        self._master_slider = None
        self._current_midi_map = None
        self._transport_view_modes = None
        self._send_midi(LED_FLASHING_OFF)
        self._send_midi(LIVE_MODE_OFF)

    def build_midi_map(self, midi_map_handle):
        self._current_midi_map = midi_map_handle
        ControlSurface.build_midi_map(self, midi_map_handle)

    def _setup_mixer(self):
        mute_solo_flip_button = make_button(59, 'Master_Button')
        self._mixer = SpecialMixerComponent(8)
        self._mixer.name = 'Mixer'
        self._mixer.selected_strip().name = 'Selected_Channel_Strip'
        self._mixer.master_strip().name = 'Master_Channel_Strip'
        self._mixer.master_strip().set_volume_control(self._master_slider)
        self._sliders = []
        self._strip_buttons = []
        for index in range(8):
            strip = self._mixer.channel_strip(index)
            strip.name = 'Channel_Strip_' + str(index)
            strip.set_invert_mute_feedback(True)
            self._sliders.append(
                make_slider(41 + index, 'Volume_Control_%d' % index))
            strip.set_volume_control(self._sliders[(-1)])
            self._strip_buttons.append(
                make_button(51 + index, 'Mute_Button_%d' % index))

        self._mixer.set_strip_mute_solo_buttons(tuple(self._strip_buttons),
                                                mute_solo_flip_button)

    def _setup_session(self):
        scene_launch_button = self._control_factory.create_scene_launch_button(
        )
        scene_stop_button = self._control_factory.create_scene_stop_button()
        self._session = SessionComponent(8, 0)
        self._session.name = 'Session_Control'
        self._session.selected_scene().name = 'Selected_Scene'
        self._session.selected_scene().set_launch_button(scene_launch_button)
        self._session.selected_scene().set_triggered_value(GREEN_BLINK)
        self._session.set_stop_all_clips_button(scene_stop_button)
        scene_stop_button.set_on_off_values(AMBER_FULL, LED_OFF)
        self._session.set_mixer(self._mixer)
        self._session.set_stop_clip_value(AMBER_HALF)
        self._session.set_stop_clip_triggered_value(GREEN_BLINK)
        clip_launch_buttons = []
        clip_stop_buttons = []
        for index in range(8):
            clip_launch_buttons.append(
                self._control_factory.create_clip_launch_button(index))
            clip_stop_buttons.append(
                self._control_factory.create_clip_stop_button(index))
            clip_slot = self._session.selected_scene().clip_slot(index)
            clip_slot.set_triggered_to_play_value(GREEN_BLINK)
            clip_slot.set_triggered_to_record_value(RED_BLINK)
            clip_slot.set_stopped_value(AMBER_FULL)
            clip_slot.set_started_value(GREEN_FULL)
            clip_slot.set_recording_value(RED_FULL)
            clip_slot.set_launch_button(clip_launch_buttons[(-1)])
            clip_slot.name = 'Selected_Clip_Slot_' + str(index)

        self._session.set_stop_track_clip_buttons(tuple(clip_stop_buttons))

    def _setup_transport(self):
        rwd_button = make_button(112, 'Rwd_Button')
        ffwd_button = make_button(113, 'FFwd_Button')
        stop_button = make_button(114, 'Stop_Button')
        play_button = make_button(115, 'Play_Button')
        loop_button = make_button(116, 'Loop_Button')
        rec_button = make_button(117, 'Record_Button')
        transport = TransportComponent()
        transport.name = 'Transport'
        transport.set_stop_button(stop_button)
        transport.set_play_button(play_button)
        transport.set_record_button(rec_button)
        transport.set_loop_button(loop_button)
        self._transport_view_modes = TransportViewModeSelector(
            transport, self._session, ffwd_button, rwd_button)
        self._transport_view_modes.name = 'Transport_View_Modes'

    def _setup_device(self):
        encoders = [
            make_encoder(21 + index, 'Device_Control_%d' % index)
            for index in range(8)
        ]
        self._encoders = tuple(encoders)
        device = DeviceComponent(device_selection_follows_track_selection=True)
        device.name = 'Device_Component'
        self.set_device_component(device)
        device.set_parameter_controls(self._encoders)

    def _setup_navigation(self):
        self._next_track_button = self._control_factory.create_next_track_button(
        )
        self._prev_track_button = self._control_factory.create_prev_track_button(
        )
        self._session_navigation = SessionNavigationComponent(
            name='Session_Navigation')
        self._session_navigation.set_next_track_button(self._next_track_button)
        self._session_navigation.set_prev_track_button(self._prev_track_button)

    def _dummy_listener(self, value):
        pass

    def _on_selected_track_changed(self):
        ControlSurface._on_selected_track_changed(self)
        self._update_mixer_offset()

    def _update_mixer_offset(self):
        all_tracks = self._session.tracks_to_use()
        selected_track = self.song().view.selected_track
        num_strips = self._session.width()
        if selected_track in all_tracks:
            track_index = list(all_tracks).index(selected_track)
            new_offset = track_index - track_index % num_strips
            self._session.set_offsets(new_offset, self._session.scene_offset())
コード例 #18
0
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        with self.component_guard():
            is_momentary = True
            self.set_pad_translations(PAD_TRANSLATIONS)
            self._suggested_input_port = 'HyperControl'
            self._suggested_output_port = 'HyperControl'
            self._display_on_button = ButtonElement(not is_momentary, MIDI_CC_TYPE, 15, 79)
            self._waiting_for_first_response = True
            mixer1 = DisplayingMixerComponent(0)
            mixer1.set_select_buttons(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 111), ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 110))
            mixer1.set_mute_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 12))
            mixer1.set_solo_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 13))
            mixer2 = NotifyingMixerComponent(8)
            mixer2.set_bank_buttons(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 15), ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 14))
            mixer2.master_strip().set_volume_control(SliderElement(MIDI_CC_TYPE, 15, 41))
            for index in range(8):
                mixer2.channel_strip(index).set_volume_control(SliderElement(MIDI_CC_TYPE, 15, 33 + index))

            device = PageableDeviceComponent(device_selection_follows_track_selection=True)
            self.set_device_component(device)
            ffwd_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 115)
            rwd_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 114)
            loop_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 113)
            transport = TransportComponent()
            transport.set_stop_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 116))
            transport.set_play_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 117))
            transport.set_record_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 118))
            session = SessionComponent(0, 0)
            transport_view_modes = TransportViewModeSelector(transport, session, ffwd_button, rwd_button, loop_button)
            select_button_modes = SelectButtonModeSelector(mixer2, tuple([ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 49 + offset) for offset in range(8)]))
            select_button_modes.set_mode_toggle(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 57))
            self._mixer_encoder_modes = EncoderMixerModeSelector(mixer2)
            encoders = []
            for offset in range(8):
                encoders.append(PeekableEncoderElement(MIDI_CC_TYPE, 15, 17 + offset, Live.MidiMap.MapMode.relative_smooth_two_compliment))
                encoders[(-1)].set_feedback_delay(-1)

            mixer_or_device = MixerOrDeviceModeSelector(self._mixer_encoder_modes, device, tuple(encoders), tuple([ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 74 + offset) for offset in range(4)]))
            mixer_or_device.set_mode_toggle(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 109))
            mixer_or_device.set_peek_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 15, 78))
            self._track_display = PhysicalDisplayElement(8, 1)
            self._track_display.set_clear_all_message(SYSEX_START + (16, 247))
            self._track_display.set_message_parts(SYSEX_START + (17, 1, 0, 0), (247, ))
            self._track_display.segment(0).set_data_source(mixer1.selected_strip().track_name_data_source())
            device_display = PhysicalDisplayElement(8, 1)
            device_display.set_message_parts(SYSEX_START + (17, 1, 0, 10), (247, ))
            parameter_display = PhysicalDisplayElement(16, 1)
            parameter_display.set_message_parts(SYSEX_START + (17, 2, 0, 0), (247, ))
            select_button_modes.set_mode_display(parameter_display)
            mixer1.set_display(parameter_display)
            mixer2.set_bank_display(parameter_display)
            page_displays = []
            for index in range(4):
                page_displays.append(PhysicalDisplayElement(5, 1))
                page_displays[(-1)].set_message_parts(SYSEX_START + (17, 4, index, 0), (247, ))

            encoder_display = PhysicalDisplayElement(80, 8)
            encoder_display.set_message_parts(SYSEX_START + (17, 3), (247, ))
            for index in range(8):
                pos_id = tuple()
                if index != 0:
                    pos_id += (0, )
                else:
                    if index > 3:
                        pos_id += (index % 4, 13)
                    else:
                        pos_id += (index % 4, 0)
                    encoder_display.segment(index).set_position_identifier(pos_id)

            mixer_or_device.set_displays(encoder_display, parameter_display, device_display, tuple(page_displays))
            for component in self.components:
                component.set_enabled(False)