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)) self._high_priority_layer = Layer(priority=MODE_PRIORITY, 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) self._high_priority_layer.grab(session) for scene_index in xrange(self.SESSION_HEIGHT): for track_index in xrange(self.SESSION_WIDTH): slot = session.scene(scene_index).clip_slot(track_index) slot.layer = Layer(select_button=self._shift_button) return session
def _create_mixer(self): self._mixer = MixerComponent( name='Mixer', is_enabled=False, num_returns=2, layer=Layer(track_select_encoder=self._horizontal_scroll_encoder, selected_track_volume_control=self._volume_encoder, selected_track_pan_control=self._pan_encoder, selected_track_send_controls=self._send_encoders, return_volume_controls=self._return_encoders)) self._mixer.set_enabled(True)
def _create_recording(self): record_button = MultiElement(self._session_record_button, self._foot_pedal_button.single_press) self._session_recording = SessionRecordingComponent( ClipCreator(), self._view_control, name='Session_Recording', is_enabled=False, layer=Layer(new_button=self._foot_pedal_button.double_press, record_button=record_button, _uses_foot_pedal=self._foot_pedal_button))
def _create_mixer(self): mixer = NotifyingMixerComponent(NUM_TRACKS, auto_name=True) mixer.layer = Layer( send_controls=self._tone_filter_knobs, track_select_buttons=self._select_buttons, arm_buttons=self._bfx_buttons, solo_buttons=self._mfx_buttons, send_index_up_button=self._modified_cursor_up_button, send_index_down_button=self._modified_cursor_down_button, modifier_button=self._aux_button) return mixer
def _create_device(self): self._device = DeviceComponent( name='Device_Component', is_enabled=False, layer=Layer(bank_buttons=self._device_bank_buttons, on_off_button=self._device_on_off_button), use_fake_banks=True, device_selection_follows_track_selection=True) ChannelTranslationSelector(8, name='Control_Translations') self._device.set_parameter_controls( tuple(self._device_param_controls_raw))
def use_single_line(self, line_index, line_slice = None, align = align_none): """ Returns a control, that will change the notification to a single line view, if it is grabbed. """ if not (line_index >= 0 and line_index < len(self._display_lines)): raise AssertionError display = self._display_lines[line_index] display = line_slice is not None and display.subdisplay[line_slice] layer = Layer(priority=MESSAGE_BOX_PRIORITY, display_line1=display) return _CallbackControl(self._token_control, partial(self._set_message_box_layout, layer, maybe(partial(align, display.width))))
def _create_device(self): self._device = DeviceComponent( name='Device', is_enabled=False, layer=Layer(parameter_controls=self._device_controls, bank_buttons=self._device_bank_buttons, bank_prev_button=self._device_prev_bank_button, bank_next_button=self._device_next_bank_button, on_off_button=self._device_on_off_button, lock_button=self._device_lock_button), device_selection_follows_track_selection=True)
def _setup_mixer(self): self._mixer = MixerComponent(NUM_CHANNEL_STRIPS) self._mixer.name = 'Mixer' self._mixer.set_enabled(False) for index in xrange(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 _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( b'device_mode', [device_layer_mode, device_navigation_layer_mode]) self._encoder_modes.add_mode( b'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( b'send_a_mode', [send_layer_mode, partial(self._set_send_index, 0)]) self._encoder_modes.add_mode( b'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 = b'device_mode' self._encoder_modes.set_enabled(True)
def _create_session(self): def when_bank_on(button): return self._bank_toggle.create_toggle_element(on_control=button) def when_bank_off(button): return self._bank_toggle.create_toggle_element(off_control=button) self._session = SessionComponent( NUM_TRACKS, NUM_SCENES, auto_name=True, is_enabled=False, enable_skinning=True, layer=Layer( track_bank_left_button=when_bank_off(self._left_button), track_bank_right_button=when_bank_off(self._right_button), scene_bank_up_button=when_bank_off(self._up_button), scene_bank_down_button=when_bank_off(self._down_button), page_left_button=when_bank_on(self._left_button), page_right_button=when_bank_on(self._right_button), page_up_button=when_bank_on(self._up_button), page_down_button=when_bank_on(self._down_button), stop_track_clip_buttons=self._stop_buttons, stop_all_clips_button=self._stop_all_button, scene_launch_buttons=self._scene_launch_buttons, clip_launch_buttons=self._session_matrix)) clip_color_table = Colors.CLIP_COLOR_TABLE.copy() clip_color_table[16777215] = 119 self._session.set_rgb_mode(clip_color_table, Colors.RGB_COLOR_TABLE) self._session_zoom = SessionZoomingComponent( self._session, name='Session_Overview', enable_skinning=True, is_enabled=False, layer=Layer(button_matrix=self._session_matrix, zoom_button=self._shift_button, nav_left_button=self._left_button, nav_right_button=self._right_button, nav_up_button=self._up_button, nav_down_button=self._down_button, scene_bank_buttons=self._scene_launch_buttons))
def _create_modes(self): self._modes = NotifyingModesComponent(is_root=True) self._modes.default_behaviour = mixin(SkinableBehaviourMixin, ImmediateBehaviour)() self._modes.add_mode( 'session_mode', [self._session, self._session_layer_mode], layout_byte=0, behaviour=EnablingReenterBehaviour(self._session_zoom)) self._modes.add_mode('user_1_mode', [], layout_byte=1) self._modes.add_mode('user_2_mode', [], layout_byte=2) self._modes.add_mode('volume_mode', [ self._session, self._create_translating_mixer_background( consts.VOLUME_MODE_CHANNEL), self._mixer_volume_layer ], layout_byte=4, groups=set('mixer')) self._modes.add_mode('pan_mode', [ self._session, self._create_translating_mixer_background(consts.PAN_MODE_CHANNEL), self._mixer_pan_layer ], layout_byte=5, groups=set('mixer')) self._modes.add_mode('send_a_mode', [ self._session, self._create_translating_mixer_background( consts.SEND_A_MODE_CHANNEL), self._mixer_send_a_layer ], layout_byte=6, groups=set('mixer')) self._modes.add_mode('send_b_mode', [ self._session, self._create_translating_mixer_background( consts.SEND_B_MODE_CHANNEL), self._mixer_send_b_layer ], layout_byte=7, groups=set('mixer')) self._modes.add_mode('mixer_mode', [ self._session, self._stop_clip_layer_mode, self._mixer_home_page_layer ], layout_byte=3, groups=set('mixer')) self._modes.layer = Layer(session_mode_button=self._session_button, user_1_mode_button=self._user_1_button, user_2_mode_button=self._user_2_button, mixer_mode_button=self._mixer_button, volume_mode_button=self._volume_button, pan_mode_button=self._pan_button, send_a_mode_button=self._send_a_button, send_b_mode_button=self._send_b_button) self._modes.selected_mode = 'session_mode'
def _create_session_mode(self): """ Switch between Session and StepSequencer modes """ self._session_mode = ModesComponent(name='Session_Mode', is_enabled = False) self._session_mode.default_behaviour = ImmediateBehaviour() self._session_mode.add_mode('session', self._session_mode_layers()) self._session_mode.add_mode('session_2', self._session_mode_layers()) self._session_mode.add_mode('sequencer', (self._sequencer, self._sequencer_layer())) self._session_mode.layer = Layer( session_button = self._pan_button, session_2_button = self._sends_button, sequencer_button = self._user_button) self._session_mode.selected_mode = "session"
def _init_sequencer(self): self._sequencer = BaseSequencerComponent(layer = Layer( drum_matrix = self.control_surface.matrix.submatrix[:4, :4], playhead = self._playhead(), drum_bank_up_button = self.control_surface.utility_buttons[4], drum_bank_down_button = self.control_surface.utility_buttons[5], mute_button = self.control_surface.utility_buttons[6], delete_button = self.control_surface.utility_buttons[7], loop_selector_matrix = self.control_surface.shifted_matrix.submatrix[4:8, :4], button_matrix = self.control_surface.matrix.submatrix[4:8, :4])) self._sequencer._drum_group.__class__ = BaseDrumGroupComponent return self._sequencer
def __init__(self, *a, **k): super(KeyLabEssential2, 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
def _create_arrangement(self): self._arrangement = SpecialArrangementComponent( NUM_TRACKS, NUM_SCENES, auto_name=True, is_enabled=False, enable_skinning=True, layer=Layer( track_bank_up_button=self._midimap['Arrow_Up_Button'], track_bank_down_button=self._midimap['Arrow_Down_Button'], quantize_button=self._midimap['Quantize_Button'])) self._arrangement.set_enabled(True)
def __init__(self, *a, **k): super(Alesis_VI, self).__init__(*a, **k) with self.component_guard(): midimap = MidiMap() transport = TransportComponent( name='Transport', is_enabled=False, layer=Layer(play_button=midimap['Play'], stop_button=midimap['Stop'], loop_button=midimap['Loop'], record_button=midimap['Record'], seek_forward_button=midimap['Forward'], seek_backward_button=midimap['Backward'])) mixer_size = len(midimap['Volume_Encoders']) mixer = MixerComponent( mixer_size, name='Mixer', is_enabled=False, layer=Layer(volume_controls=midimap['Volume_Encoders'])) transport.set_enabled(True) mixer.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_transport(self): def play_toggle_model_transform(value): if self._shift_button.is_pressed(): return False return value return TransportComponent( name=u'Transport', is_enabled=False, play_toggle_model_transform=play_toggle_model_transform, layer=Layer(play_button=self._play_button, record_button=self._record_button))
def _create_instrument_layer(self): return Layer( playhead=self._playhead, #mute_button=self._global_mute_button, quantization_buttons=self._stop_buttons, loop_selector_matrix=self._double_press_matrix. submatrix[:8, :1], # [:, 0] short_loop_selector_matrix=self._double_press_event_matrix. submatrix[:, 0], # [:, 0] note_editor_matrices=ButtonMatrixElement([[ self._session_matrix.submatrix[:, 4 - row] for row in xrange(7) ]]))
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
def _create_solo_mode(self): solo_layer_mode = LayerMode( self._mixer, layer=Layer(solo_buttons=self._midimap['Mixer_Button_Matrix'])) self._modes.add_mode('solo_mode', [ partial(self._layout_setup, consts.SESSION_LAYOUT_SYSEX_BYTE), self._session_layer_mode, solo_layer_mode, self._session_zooming_manager, self._prioritized_session_zooming_button_layer_mode, self._session.update_navigation_buttons ], behaviour=SpecialReenterBehaviour('session_mode'))
def _create_session(self): """ Creates SessionComponent which is used for banking and visual focus box. """ self._session = SessionComponent(num_tracks=NUM_TRACKS, num_scenes=NUM_SCENES, is_enabled=True, auto_name=True, enable_skinning=True) self._session.set_offsets(0, 0) self._session.layer = Layer( track_bank_left_button=self._bank_left_button, track_bank_right_button=self._bank_right_button) self._on_session_offset_changed.subject = self._session
def _create_encoder_modes(self): knob_modes = ModesComponent(name=u'Knob Modes', is_enabled=False) parameter_knobs_matrix = self.wrap_matrix(self._parameter_knobs) send_toggle_component = SendToggleComponent( self._mixer, name=u'Toggle Send', is_enabled=False, layer=Layer(toggle_button=self._send_button, priority=1)) knob_modes.add_mode( u'volume', AddLayerMode(self._mixer, Layer(volume_controls=parameter_knobs_matrix))) knob_modes.add_mode( u'pan', AddLayerMode(self._mixer, Layer(pan_controls=parameter_knobs_matrix))) knob_modes.add_mode(u'send', [ AddLayerMode(self._mixer, Layer(send_controls=parameter_knobs_matrix)), send_toggle_component ]) knob_modes.add_mode( u'device', AddLayerMode(self._device, Layer(parameter_controls=parameter_knobs_matrix))) knob_modes.selected_mode = u'volume' knob_modes.layer = Layer(volume_button=self._volume_button, pan_button=self._pan_button, send_button=self._send_button, device_button=self._device_button) return knob_modes
def _setup_mixer_control(self): self._num_tracks = (8) self._mixer = MixerComponent(script=self, num_tracks=8, num_returns=4, invert_mute_feedback=True, autoname=True) self._mixer.name = 'Mixer' self._mixer.set_track_offset(0) self._mixer.master_strip().set_volume_control(self._master_fader) self._mixer.set_prehear_volume_control(self._side_dial[3]) self._mixer.layer = Layer(volume_controls=self._fader_matrix, track_select_dial=self._encoder[1]) self._strip = [self._mixer.channel_strip(index) for index in range(8)] for index in range(8): self._strip[index].layer = Layer( parameter_controls=self._dial_matrix.submatrix[index:index + 1, :]) self._mixer.selected_strip().layer = Layer( parameter_controls=self._selected_parameter_controls) self._mixer.master_strip().layer = Layer( parameter_controls=self._side_dial_matrix.submatrix[:3, :]) self._mixer.main_layer = AddLayerMode( self._mixer, Layer(solo_buttons=self._bottom_buttons, mute_buttons=self._top_buttons)) self._mixer.select_layer = AddLayerMode( self._mixer, Layer(arm_buttons=self._bottom_buttons, track_select_buttons=self._top_buttons)) self.song().view.selected_track = self._mixer.channel_strip(0)._track self._mixer.set_enabled(True)
def _create_session_zooming_modes(self): session_zoom_layer = Layer( button_matrix=self._midimap[b'Main_Button_Matrix'], nav_left_button=self._midimap[b'Arrow_Left_Button'], nav_right_button=self._midimap[b'Arrow_Right_Button'], nav_up_button=self._midimap[b'Arrow_Up_Button'], nav_down_button=self._midimap[b'Arrow_Down_Button']) session_zooming_layer_mode = LayerMode(self._session_zoom, session_zoom_layer) self._session_zooming_manager = SessionZoomingManagerComponent( self._modes, is_enabled=False) session_zooming_button_layer_mode = LayerMode( self._session_zooming_manager, Layer( session_zooming_button=self._midimap[b'Session_Mode_Button'])) self._prioritized_session_zooming_button_layer_mode = LayerMode( self._session_zooming_manager, Layer(session_zooming_button=self._midimap[b'Session_Mode_Button'], priority=1)) self._session_zooming_background = BackgroundComponent( name=b'Session_Zooming_Background') session_zooming_background_layer_mode = LayerMode( self._session_zooming_background, Layer(scene_launch_buttons=self. _midimap[b'Scene_Launch_Button_Matrix'], delete_button=self._midimap[b'Delete_Button'], quantize_button=self._midimap[b'Quantize_Button'], duplicate_button=self._midimap[b'Duplicate_Button'], double_loop_button=self._midimap[b'Double_Loop_Button'])) self._modes.add_mode(b'session_zooming_mode', [ self._session_zooming_manager, session_zooming_button_layer_mode, session_zooming_layer_mode, session_zooming_background_layer_mode ]) self._modes.add_mode(b'prioritized_session_zooming_mode', [ partial(self._layout_switch, consts.SESSION_LAYOUT_SYSEX_BYTE), self._session_zooming_manager, self._prioritized_session_zooming_button_layer_mode, session_zooming_layer_mode, session_zooming_background_layer_mode, self.update ])
def _create_encoder_modes(self): knob_modes = ModesComponent(name='Knob Modes', is_enabled=False) parameter_knobs_matrix = self.wrap_matrix(self._parameter_knobs) knob_modes.add_mode( 'volume', AddLayerMode(self._mixer, Layer(volume_controls=parameter_knobs_matrix))) knob_modes.add_mode( 'pan', AddLayerMode(self._mixer, Layer(pan_controls=parameter_knobs_matrix))) knob_modes.add_mode('send', [ AddLayerMode(self._mixer, Layer(send_controls=parameter_knobs_matrix)), DelayMode(LayerMode( SendToggleComponent( self._mixer, name='Toggle Send', is_enabled=False), Layer(priority=MODE_PRIORITY, toggle_button=self._send_button)), delay=TIMER_DELAY) ]) knob_modes.add_mode( 'device', AddLayerMode(self._device, Layer(parameter_controls=parameter_knobs_matrix))) knob_modes.selected_mode = 'volume' knob_modes.layer = Layer(volume_button=self._volume_button, pan_button=self._pan_button, send_button=self._send_button, device_button=self._device_button) knob_modes.layer.priority = MODE_PRIORITY
def _create_track_button_modes(self): track_button_modes = ModesComponent(name='Track Button Modes', is_enabled=False) select_button_matrix = self.wrap_matrix(self._select_buttons) track_button_modes.add_mode( 'clip_stop', AddLayerMode(self._session, Layer(stop_track_clip_buttons=select_button_matrix))) track_button_modes.add_mode( 'solo', AddLayerMode(self._mixer, layer=Layer(solo_buttons=select_button_matrix))) track_button_modes.add_mode( 'arm', AddLayerMode(self._mixer, layer=Layer(arm_buttons=select_button_matrix))) track_button_modes.add_mode( 'mute', AddLayerMode(self._mixer, layer=Layer(mute_buttons=select_button_matrix))) track_button_modes.add_mode( 'select', AddLayerMode( self._mixer, layer=Layer(track_select_buttons=select_button_matrix))) track_button_modes.selected_mode = 'clip_stop' track_button_modes.layer = Layer(clip_stop_button=self._stop_button, solo_button=self._solo_button, arm_button=self._arm_button, mute_button=self._mute_button, select_button=self._select_button)
def _create_mixer(self): mixer_volume_layer = None if self._is_25_key_model: mixer_volume_layer = Layer(volume_control=self._25_key_slider) else: mixer_volume_layer = Layer(volume_controls=self._sliders) self._mixer = MixerComponent(is_enabled=False, name='Mixer', num_tracks=self._sliders.width(), layer=mixer_volume_layer) if not self._is_25_key_model: self._mixer.master_strip().layer = Layer( volume_control=self._master_slider) self._mixer.set_enabled(True) self._mute_button_modes = ModesComponent() mute_mode = AddLayerMode(self._mixer, Layer(mute_buttons=self._mute_buttons)) solo_mode = AddLayerMode(self._mixer, Layer(solo_buttons=self._mute_buttons)) self._mute_button_modes.add_mode('mute_mode', mute_mode) self._mute_button_modes.add_mode('solo_mode', solo_mode, behaviour=CancellableBehaviour()) self._mute_button_modes.layer = Layer( solo_mode_button=self._master_button) self._mute_button_modes.selected_mode = 'mute_mode' self._mute_button_modes.set_enabled(True)
def _init_device_component(self, device_controls, bank_controls, global_channel, macro_map_mode): is_momentary = True DeviceButton = partial(ButtonElement, is_momentary, MIDI_CC_TYPE) def make_bank_button(control, name, is_momentary=True): return DeviceButton(global_channel, bank_controls[control], name=name) if device_controls: device = DeviceComponent(device_selection_follows_track_selection=True, name='Device_Component') layer_specs = {} if bank_controls: if has_specification_for('NEXTBANK', bank_controls): layer_specs['bank_next_button'] = make_bank_button('NEXTBANK', 'Device_Next_Bank_Button') if has_specification_for('PREVBANK', bank_controls): layer_specs['bank_prev_button'] = make_bank_button('PREVBANK', 'Device_Previous_Bank_Button') if has_specification_for('TOGGLELOCK', bank_controls): layer_specs['lock_button'] = make_bank_button('TOGGLELOCK', 'Device_Lock_Button') bank_buttons_raw = [] for index in xrange(8): key = 'BANK' + str(index + 1) if key in bank_controls.keys(): control_info = bank_controls[key] channel = global_channel cc = control_info if isinstance(control_info, (tuple, list)): cc = control_info[0] if is_valid_midi_channel(control_info[1]): channel = control_info[1] if is_valid_midi_identifier(cc) and is_valid_midi_channel(channel): name = 'Device_Bank_' + str(index) + '_Button' bank_buttons_raw.append(DeviceButton(channel, cc, name=name)) if len(bank_buttons_raw) > 0: layer_specs['bank_buttons'] = ButtonMatrixElement(rows=[ bank_buttons_raw]) parameter_encoders_raw = [] for index, control_info in enumerate(device_controls): channel = global_channel cc = control_info if isinstance(control_info, (tuple, list)): cc = control_info[0] if is_valid_midi_channel(control_info[1]): channel = control_info[1] if is_valid_midi_identifier(cc) and is_valid_midi_channel(channel): name = 'Device_Parameter_%d_Control' % index parameter_encoders_raw.append(EncoderElement(MIDI_CC_TYPE, channel, cc, macro_map_mode, name=name)) if len(parameter_encoders_raw) > 0: layer_specs['parameter_controls'] = ButtonMatrixElement(rows=[ parameter_encoders_raw]) device.layer = Layer(**layer_specs) self.set_device_component(device)
def _init_device(self): make_button = partial(make_launch_control_button, channel=10) make_encoder = partial(make_launch_control_encoder, channel=10) bottom_encoders, top_encoders = make_all_encoders('Device', make_encoder) parameter_controls = top_encoders[:4] + bottom_encoders[:4] bank_buttons = [ make_button(identifier, 'Device_Bank_Button_' + str(i), is_pad=True) for i, identifier in enumerate(pad_identifiers) ] for button in bank_buttons: button.set_on_off_values(Colors.LED_ON, Colors.LED_OFF) self._device_bank_registry = DeviceBankRegistry() self._device = DeviceComponent(device_bank_registry=self._device_bank_registry, name='Device') self._device.set_enabled(False) self._device.layer = Layer(parameter_controls=ButtonMatrixElement(rows=[parameter_controls]), bank_buttons=ButtonMatrixElement(rows=[bank_buttons])) self.set_device_component(self._device) self._device_navigation = DeviceNavigationComponent() self._device_navigation.set_enabled(False) self._device_navigation.name = 'Device_Navigation' self._device_navigation.layer = Layer(next_device_button=make_button(115, 'Next_Device_Button'), previous_device_button=make_button(114, 'Prev_Device_Button')) self._view_control = ViewControlComponent() self._view_control.set_enabled(False) self._view_control.name = 'View_Control' self._view_control.layer = Layer(next_track_button=make_button(117, 'Device_Next_Track_Button'), prev_track_button=make_button(116, 'Device_Prev_Track_Button'))
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])
class APC_Key_25(APC, OptimizedControlSurface): """ Script for Akai's APC_Key_25 Controller """ SESSION_WIDTH = 8 SESSION_HEIGHT = 5 HAS_TRANSPORT = True def make_shifted_button(self, button): return ComboElement(button, modifiers=[self._shift_button]) @classmethod def wrap_matrix(cls, control_list, wrapper = nop): return ButtonMatrixElement(rows=[map(wrapper, control_list)]) def __init__(self, *a, **k): super(APC_Key_25, self).__init__(*a, **k) self._color_skin = make_biled_skin() self._default_skin = make_default_skin() self._stop_button_skin = make_stop_button_skin() with self.component_guard(): self._create_controls() self._session = self._create_session() self._mixer = self._create_mixer() self._device = self._create_device_component() if self.HAS_TRANSPORT: self._transport = self._create_transport() self.set_device_component(self._device) self.set_highlighting_session_component(self._session) self._session.set_mixer(self._mixer) self._create_encoder_modes() self._create_track_button_modes() for component in self.components: component.set_enabled(False) self._device_selection_follows_track_selection = True def get_matrix_button(self, column, row): return self._matrix_buttons[row][column] def _product_model_id_byte(self): return 39 def _should_combine(self): return False def _update_hardware(self): self._session.set_show_highlight(False) super(APC_Key_25, self)._update_hardware() def _send_identity_request(self): self._send_midi((240, 126, 127, 6, 1, 247)) def _send_dongle_challenge(self): self._on_handshake_successful() self._session.set_show_highlight(True) def _create_controls(self): make_on_off_button = partial(make_button, skin=self._default_skin) make_color_button = partial(make_button, skin=self._color_skin) make_stop_button = partial(make_button, skin=self._stop_button_skin) self._shift_button = make_button(0, 98, resource_type=SharedResource, name='Shift_Button') self._parameter_knobs = [ make_knob(0, index + 48, name='Parameter_Knob_%d' % (index + 1)) for index in xrange(self.SESSION_WIDTH) ] self._select_buttons = [ make_stop_button(0, 64 + index, name='Track_Select_%d' % (index + 1)) for index in xrange(self.SESSION_WIDTH) ] self._up_button = self.make_shifted_button(self._select_buttons[0]) self._down_button = self.make_shifted_button(self._select_buttons[1]) self._left_button = self.make_shifted_button(self._select_buttons[2]) self._right_button = self.make_shifted_button(self._select_buttons[3]) self._volume_button = self.make_shifted_button(self._select_buttons[4]) self._pan_button = self.make_shifted_button(self._select_buttons[5]) self._send_button = self.make_shifted_button(self._select_buttons[6]) self._device_button = self.make_shifted_button(self._select_buttons[7]) if self.HAS_TRANSPORT: self._play_button = make_on_off_button(0, 91, name='Play_Button') self._record_button = make_on_off_button(0, 93, name='Record_Button') def matrix_note(x, y): return x + self.SESSION_WIDTH * (self.SESSION_HEIGHT - y - 1) self._matrix_buttons = [ [ make_color_button(0, matrix_note(track, scene), name='%d_Clip_%d_Button' % (track, scene)) for track in xrange(self.SESSION_WIDTH) ] for scene in xrange(self.SESSION_HEIGHT) ] self._session_matrix = ButtonMatrixElement(name='Button_Matrix', rows=self._matrix_buttons) self._scene_launch_buttons = [ make_color_button(0, index + 82, name='Scene_Launch_%d' % (index + 1)) for index in xrange(self.SESSION_HEIGHT) ] self._stop_button = self.make_shifted_button(self._scene_launch_buttons[0]) self._solo_button = self.make_shifted_button(self._scene_launch_buttons[1]) self._arm_button = self.make_shifted_button(self._scene_launch_buttons[2]) self._mute_button = self.make_shifted_button(self._scene_launch_buttons[3]) self._select_button = self.make_shifted_button(self._scene_launch_buttons[4]) self._stop_all_button = self._make_stop_all_button() def _make_stop_all_button(self): return make_button(0, 81, name='Stop_All_Clips_Button') 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)) self._high_priority_layer = Layer(priority=MODE_PRIORITY, 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) self._high_priority_layer.grab(session) for scene_index in xrange(self.SESSION_HEIGHT): for track_index in xrange(self.SESSION_WIDTH): slot = session.scene(scene_index).clip_slot(track_index) slot.layer = Layer(select_button=self._shift_button) return session def _create_mixer(self): return MixerComponent(self.SESSION_WIDTH, auto_name=True, is_enabled=False, invert_mute_feedback=True) def _create_device_component(self): return DeviceComponent(name='Device_Component', is_enabled=False) def _create_transport(self): def play_toggle_model_transform(value): return False if self._shift_button.is_pressed() else value return TransportComponent(name='Transport', is_enabled=False, play_toggle_model_transform=play_toggle_model_transform, layer=Layer(play_button=self._play_button, record_button=self._record_button)) def _create_encoder_modes(self): knob_modes = ModesComponent(name='Knob Modes', is_enabled=False) parameter_knobs_matrix = self.wrap_matrix(self._parameter_knobs) knob_modes.add_mode('volume', AddLayerMode(self._mixer, Layer(volume_controls=parameter_knobs_matrix))) knob_modes.add_mode('pan', AddLayerMode(self._mixer, Layer(pan_controls=parameter_knobs_matrix))) knob_modes.add_mode('send', [AddLayerMode(self._mixer, Layer(send_controls=parameter_knobs_matrix)), DelayMode(LayerMode(SendToggleComponent(self._mixer, name='Toggle Send', is_enabled=False), Layer(priority=MODE_PRIORITY, toggle_button=self._send_button)), delay=TIMER_DELAY)]) knob_modes.add_mode('device', AddLayerMode(self._device, Layer(parameter_controls=parameter_knobs_matrix))) knob_modes.selected_mode = 'volume' knob_modes.layer = Layer(volume_button=self._volume_button, pan_button=self._pan_button, send_button=self._send_button, device_button=self._device_button) knob_modes.layer.priority = MODE_PRIORITY def _create_track_button_modes(self): track_button_modes = ModesComponent(name='Track Button Modes', is_enabled=False) select_button_matrix = self.wrap_matrix(self._select_buttons) track_button_modes.add_mode('clip_stop', AddLayerMode(self._session, Layer(stop_track_clip_buttons=select_button_matrix))) track_button_modes.add_mode('solo', AddLayerMode(self._mixer, layer=Layer(solo_buttons=select_button_matrix))) track_button_modes.add_mode('arm', AddLayerMode(self._mixer, layer=Layer(arm_buttons=select_button_matrix))) track_button_modes.add_mode('mute', AddLayerMode(self._mixer, layer=Layer(mute_buttons=select_button_matrix))) track_button_modes.add_mode('select', AddLayerMode(self._mixer, layer=Layer(track_select_buttons=select_button_matrix))) track_button_modes.selected_mode = 'clip_stop' track_button_modes.layer = Layer(clip_stop_button=self._stop_button, solo_button=self._solo_button, arm_button=self._arm_button, mute_button=self._mute_button, select_button=self._select_button)
def _set_full_display(self, message_line_index = 2): layer = Layer(**dict([ ('display_line1' if i == message_line_index else 'bg%d' % i, line) for i, line in enumerate(self._display_lines) ])) layer.priority = consts.MESSAGE_BOX_PRIORITY self._message_box.layer = layer
def _set_single_line(self, line_index): raise line_index >= 0 and line_index < len(self._display_lines) or AssertionError layer = Layer(**{'display_line1': self._display_lines[line_index]}) layer.priority = consts.MESSAGE_BOX_PRIORITY self._message_box.layer = layer