コード例 #1
0
    def __init__(self,
                 deleter=None,
                 undo_handler=None,
                 pad_sensitivity_update=None,
                 playhead=None,
                 velocity_levels=None,
                 continuous_mapping_sensitivity=None,
                 fine_grained_continuous_mapping_sensitivity=None,
                 full_velocity=None,
                 *a,
                 **k):
        assert deleter is not None
        assert undo_handler is not None
        assert playhead is not None
        assert velocity_levels is not None
        assert continuous_mapping_sensitivity is not None
        assert fine_grained_continuous_mapping_sensitivity is not None
        super(Elements, self).__init__(*a, **k)
        self.foot_pedal_button = DoublePressElement(
            create_button(69, b'Foot_Pedal', is_rgb=True))
        self.nav_up_button = create_button(46, b'Up_Arrow')
        self.nav_down_button = create_button(47, b'Down_Arrow')
        self.nav_left_button = create_button(44, b'Left_Arrow')
        self.nav_right_button = create_button(45, b'Right_Arrow')
        self.shift_button = create_modifier_button(49, b'Shift_Button')
        self.select_button = create_modifier_button(48, b'Select_Button')
        self.delete_button = create_modifier_button(
            118, b'Delete_Button', undo_step_handler=undo_handler)
        self.duplicate_button = create_modifier_button(
            88, b'Duplicate_Button', undo_step_handler=undo_handler)
        self.quantize_button = create_modifier_button(
            116, b'Quantization_Button', undo_step_handler=undo_handler)
        self.accent_button = create_modifier_button(57, b'Accent_Button')
        self.in_button = create_button(62, b'In_Button')
        self.out_button = create_button(63, b'Out_Button')
        self.master_select_button = create_button(28, b'Master_Select_Button')
        self.octave_down_button = create_button(54, b'Octave_Down_Button')
        self.octave_up_button = create_button(55, b'Octave_Up_Button')
        self.repeat_button = create_button(56, b'Repeat_Button')
        self.global_mute_button = create_modifier_button(
            60, b'Global_Mute_Button')
        self.global_solo_button = create_modifier_button(
            61, b'Global_Solo_Button')
        self.global_track_stop_button = create_modifier_button(
            29, b'Track_Stop_Button')
        self.scale_presets_button = create_button(58, b'Scale_Presets_Button')
        self.vol_mix_mode_button = create_button(114, b'Vol_Mix_Mode_Button')
        self.device_mode_button = create_button(110, b'Device_Mode_Button')
        self.clip_mode_button = create_button(113, b'Clip_Mode_Button')
        self.browse_mode_button = create_button(111, b'Browse_Mode_Button')
        self.single_track_mix_mode_button = create_button(
            112, b'Single_Track_Mode_Button')
        self.pan_send_mix_mode_button = create_button(
            115, b'Pan_Send_Mode_Button', resource_type=PrioritizedResource)
        self.note_mode_button = create_modifier_button(50, b'Note_Mode_Button')
        self.session_mode_button = create_button(51, b'Session_Mode_Button')
        self.play_button = create_button(85, b'Play_Button')
        self.new_button = create_button(87, b'New_Button')
        self.automation_button = create_button(89, b'Automation_Button')
        self.tap_tempo_button = create_button(3, b'Tap_Tempo_Button')
        self.metronome_button = create_button(9, b'Metronome_Button')
        self.fixed_length_button = create_button(90, b'Fixed_Length_Button')
        self.record_button = create_modifier_button(86, b'Record_Button')
        self.undo_button = create_button(119, b'Undo_Button')
        self.create_device_button = create_button(
            52, b'Create_Device_Button', undo_step_handler=undo_handler)
        self.create_track_button = create_button(
            53, b'Create_Track_Button', undo_step_handler=undo_handler)
        self.double_button = create_button(117,
                                           b'Double_Button',
                                           undo_step_handler=undo_handler)
        self.user_button = create_button(59,
                                         b'User_Button',
                                         undo_step_handler=undo_handler)
        self.select_buttons_raw = [
            create_button(20 + idx, b'Track_Select_Button' + str(idx))
            for idx in xrange(8)
        ]
        self.select_buttons = ButtonMatrixElement(
            name=b'Track_Select_Buttons', rows=[self.select_buttons_raw])
        self.track_state_buttons_raw = [
            create_button(102 + idx,
                          b'Track_State_Button' + str(idx),
                          is_rgb=True) for idx in xrange(8)
        ]
        self.track_state_buttons = ButtonMatrixElement(
            name=b'Track_State_Buttons', rows=[self.track_state_buttons_raw])
        self.side_buttons_raw = [
            create_button(36 + idx, b'Scene_Launch_Button' + str(idx))
            for idx in reversed(xrange(8))
        ]
        self.side_buttons = ButtonMatrixElement(name=b'Scene_Launch_Buttons',
                                                rows=[self.side_buttons_raw])

        @depends(skin=None)
        def create_pad_button(pad_id, name, skin=None, **k):
            return PadButtonElement(pad_id,
                                    pad_sensitivity_update,
                                    True,
                                    MIDI_NOTE_TYPE,
                                    0, (36 + pad_id),
                                    skin=skin,
                                    name=name,
                                    **k)

        self.matrix_rows_raw = [[
            create_pad_button((7 - row) * 8 + column,
                              str(column) + b'_Clip_' + str(row) + b'_Button',
                              is_rgb=True) for column in xrange(8)
        ] for row in xrange(8)]
        double_press_rows = recursive_map(DoublePressElement,
                                          self.matrix_rows_raw)
        self.matrix = ButtonMatrixElement(name=b'Button_Matrix',
                                          rows=self.matrix_rows_raw)
        self.double_press_matrix = ButtonMatrixElement(
            name=b'Double_Press_Matrix', rows=double_press_rows)
        self.single_press_event_matrix = ButtonMatrixElement(
            name=b'Single_Press_Event_Matrix',
            rows=recursive_map(lambda x: x.single_press, double_press_rows))
        self.double_press_event_matrix = ButtonMatrixElement(
            name=b'Double_Press_Event_Matrix',
            rows=recursive_map(lambda x: x.double_press, double_press_rows))
        self.tempo_control_tap = create_note_button(10, b'Tempo_Control_Tap')
        self.tempo_control = TouchEncoderElement(
            channel=0,
            identifier=14,
            map_mode=consts.GLOBAL_MAP_MODE,
            name=b'Tempo_Control',
            undo_step_handler=undo_handler,
            delete_handler=deleter,
            encoder_sensitivity=BASE_ENCODER_SENSITIVITY,
            touch_element=self.tempo_control_tap)
        self.swing_control_tap = create_note_button(9, b'Swing_Control_Tap')
        self.swing_control = TouchEncoderElement(
            channel=0,
            identifier=15,
            map_mode=consts.GLOBAL_MAP_MODE,
            name=b'Swing_Control',
            undo_step_handler=undo_handler,
            delete_handler=deleter,
            encoder_sensitivity=BASE_ENCODER_SENSITIVITY,
            touch_element=self.swing_control_tap)
        self.master_volume_control_tap = create_note_button(
            8, b'Master_Volume_Tap')
        self.master_volume_control = TouchEncoderElement(
            channel=0,
            identifier=79,
            map_mode=consts.GLOBAL_MAP_MODE,
            undo_step_handler=undo_handler,
            delete_handler=deleter,
            name=b'Master_Volume_Control',
            encoder_sensitivity=BASE_ENCODER_SENSITIVITY,
            touch_element=self.master_volume_control_tap)
        self.master_volume_control.mapping_sensitivity = continuous_mapping_sensitivity
        self.global_param_touch_buttons_raw = [
            create_note_button(index,
                               b'Track_Control_Touch_' + str(index),
                               resource_type=PrioritizedResource)
            for index in range(8)
        ]
        self.global_param_touch_buttons = ButtonMatrixElement(
            name=b'Track_Control_Touches',
            rows=[self.global_param_touch_buttons_raw])
        undo_group = object()
        self.parameter_controls_raw = [
            TouchEncoderElement(
                channel=0,
                identifier=71 + index,
                map_mode=consts.GLOBAL_MAP_MODE,
                undo_step_handler=undo_handler,
                undo_group=undo_group,
                delete_handler=deleter,
                encoder_sensitivity=BASE_ENCODER_SENSITIVITY,
                name=b'Track_Control_' + str(index),
                touch_element=self.global_param_touch_buttons_raw[index])
            for index in xrange(8)
        ]
        self.global_param_controls = ButtonMatrixElement(
            name=b'Track_Controls', rows=[self.parameter_controls_raw])
        self.fine_grain_param_controls_raw = [
            FineGrainWithModifierEncoderElement(
                encoder, self.shift_button,
                fine_grained_continuous_mapping_sensitivity,
                continuous_mapping_sensitivity)
            for encoder in self.parameter_controls_raw
        ]
        self.fine_grain_param_controls = ButtonMatrixElement(
            rows=[self.fine_grain_param_controls_raw])
        self.any_touch_button = MultiElement(
            *self.global_param_touch_buttons.nested_control_elements())
        self.playhead_element = PlayheadElement(playhead)
        self.velocity_levels_element = VelocityLevelsElement(velocity_levels)
        self.full_velocity_element = FullVelocityElement(full_velocity)
        return
コード例 #2
0
	def _setup_controls(self, *a, **k):
		super(BaseJor, self)._setup_controls(*a, **k)
		self._touchpad_multi = MultiElement(self._touchpad[0], self._touchpad[1], self._touchpad[2], self._touchpad[3], self._touchpad[4], self._touchpad[5],)
 def _create_controls(self):
     self._play_button = MultiElement(
         create_button(16, 'Play_Button'),
         create_button(17, 'Play_Button_With_Shift'))
     self._record_button = create_button(18, 'Record_Button')
     self._count_in_button = create_button(19, 'Count_In_Button')
     self._stop_button = create_button(20, 'Stop_Button')
     self._clear_button = create_button(21, 'Clear_Button')
     self._loop_button = create_button(22, 'Loop_Button')
     self._metronome_button = create_button(23, 'Metronome_Button')
     self._tap_tempo_button = create_button(24, 'Tap_Tempo_Button')
     self._undo_button = create_button(32, 'Undo_Button')
     self._redo_button = create_button(33, 'Redo_Button')
     self._quantize_button = create_button(34, 'Quantize_Button')
     self._automation_button = create_button(35, 'Automation_Button')
     self._clip_launch_button = create_button(96, 'Clip_Launch_Button')
     self._track_stop_button = create_button(97, 'Track_Stop_Button')
     self._jump_encoder = create_encoder(52, 'Jump_Encoder')
     self._loop_encoder = create_encoder(53, 'Loop_Encoder')
     self._volume_encoders = ButtonMatrixElement(rows=[[
         create_encoder(index + 80, ('Volume_Encoder_{}').format(index),
                        is_s_mk2=self.is_s_mk2)
         for index in xrange(NUM_TRACKS)
     ]],
                                                 name='Volume_Encoders')
     self._pan_encoders = ButtonMatrixElement(rows=[[
         create_encoder(index + 88, ('Pan_Encoder_{}').format(index),
                        is_s_mk2=self.is_s_mk2)
         for index in xrange(NUM_TRACKS)
     ]],
                                              name='Pan_Encoders')
     self._track_name_displays = ButtonMatrixElement(
         rows=[[
             create_display_line(sysex.TRACK_NAME_DISPLAY_HEADER,
                                 index,
                                 ('Track_Name_Display_{}').format(index),
                                 width=33 if self.is_s_mk2 else 11)
             for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Name_Displays')
     self._track_volume_displays = ButtonMatrixElement(
         rows=[[
             create_display_line(sysex.TRACK_VOLUME_DISPLAY_HEADER,
                                 index,
                                 ('Track_Volume_Display_{}').format(index),
                                 width=12) for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Volume_Displays')
     self._track_panning_displays = ButtonMatrixElement(
         rows=[[
             create_display_line(sysex.TRACK_PANNING_DISPLAY_HEADER,
                                 index,
                                 ('Track_Panning_Display_{}').format(index),
                                 width=12) for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Panning_Displays')
     self._track_type_displays = ButtonMatrixElement(
         rows=[[
             create_sysex_element(sysex.TRACK_TYPE_DISPLAY_HEADER, index,
                                  ('Track_Type_Display_{}').format(index))
             for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Type_Displays')
     self._track_mute_displays = ButtonMatrixElement(
         rows=[[
             create_sysex_element(sysex.TRACK_MUTE_DISPLAY_HEADER, index,
                                  ('Track_Mute_Display_{}').format(index))
             for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Mute_Displays')
     self._track_solo_displays = ButtonMatrixElement(
         rows=[[
             create_sysex_element(sysex.TRACK_SOLO_DISPLAY_HEADER, index,
                                  ('Track_Solo_Display_{}').format(index))
             for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Solo_Displays')
     self._track_muted_via_solo_displays = ButtonMatrixElement(
         rows=[[
             create_sysex_element(
                 sysex.TRACK_MUTED_VIA_SOLO_DISPLAY_HEADER, index,
                 ('Track_Muted_via_Solo_Display_{}').format(index))
             for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Muted_via_Solo_Displays')
     self._track_selection_displays = ButtonMatrixElement(
         rows=[[
             create_sysex_element(
                 sysex.TRACK_SELECT_DISPLAY_HEADER, index,
                 ('Track_Selection_Display_{}').format(index))
             for index in xrange(NUM_TRACKS)
         ]],
         name='Track_Selection_Displays')
     self._focus_follow_control = SysexElement(
         lambda value: sysex.TRACK_CHANGED_DISPLAY_HEADER + value +
         (midi.SYSEX_END, ),
         name='Focus_Follow_Control')
     self._handshake_control = create_button(1, 'Handshake_Control')
     self._handshake_control.reset = nop
     self._on_handshake_response.subject = self._handshake_control