Пример #1
0
	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 4, num_scenes = 4)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'

		self._session_navigation.layer = Layer(priority = 4,
									down_button = self._button[14],
									up_button = self._button[15],
									left_button = self._button[12],
									right_button = self._button[13])
		self._session_navigation.set_enabled(True)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(priority = 4,
									clip_launch_buttons = self._matrix.submatrix[:,:])
		self._session.set_enabled(True)
Пример #2
0
 def _create_navigation(self):
     self._session_navigation = SessionNavigationComponent(
         session_ring=self._session_ring,
         is_enabled=False,
         layer=Layer(page_left_button=self._bank_left_button,
                     page_right_button=self._bank_right_button,
                     left_button=self._left_button,
                     right_button=self._right_button),
         name=u'Session_Navigation')
     self._session_navigation.set_enabled(True)
Пример #3
0
	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 1, num_scenes = 4, tracks_to_use = lambda : self.song.visible_tracks + self.song.return_tracks)
		self._session_ring.set_enabled(False)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(scene_launch_buttons = self._scene_launch_matrix)

		self._session_navigation =SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'

		self._session_navigation.layer = Layer(left_button = self._button[1], right_button = self._button[0])
		self._session_navigation.set_enabled(True)
Пример #4
0
	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 4, num_scenes = 4)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'

		self._session_navigation.layer = Layer(priority = 4,
									down_button = self._button[14],
									up_button = self._button[15],
									left_button = self._button[12],
									right_button = self._button[13])
		self._session_navigation.set_enabled(True)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(priority = 4,
									clip_launch_buttons = self._matrix.submatrix[:,:])
		self._session.set_enabled(True)
Пример #5
0
 def _create_session(self):
     self._session_ring = SessionRingComponent(name=b'Session_Ring',
                                               num_tracks=SESSION_WIDTH,
                                               num_scenes=SESSION_HEIGHT)
     self._session = SessionComponent(
         name=b'Session',
         is_enabled=False,
         session_ring=self._session_ring,
         layer=Layer(clip_launch_buttons=b'upper_pads'))
     self._session_navigation = SessionNavigationComponent(
         name=b'Session_Navigation',
         is_enabled=False,
         session_ring=self._session_ring,
         layer=Layer(up_button=b'up_button_with_shift',
                     down_button=b'down_button_with_shift'))
     self._session_navigation.set_enabled(True)
Пример #6
0
    def _setup_session_control(self):
        self._session_ring = SessionRingComponent(num_tracks=7, num_scenes=7)
        self._session_ring.set_enabled(True)

        self._session_navigation = SessionNavigationComponent(
            session_ring=self._session_ring)
        self._session_navigation.scroll_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  up_button=self._menu[1],
                  down_button=self._menu[4],
                  left_button=self._menu[3],
                  right_button=self._menu[5]))
        self._session_navigation.page_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  page_up_button=self._menu[2],
                  page_down_button=self._menu[5],
                  page_left_button=self._menu[3],
                  page_right_button=self._menu[4]))
        self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation.set_enabled(False)

        self._session = SpecialOhmSessionComponent(
            name='Session', session_ring=self._session_ring, auto_name=True)
        self._session.set_enabled(False)
        self._session.clip_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  clip_launch_buttons=self._matrix.submatrix[:7, :7]))
        self._session.scene_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  scene_launch_buttons=self._matrix.submatrix[7, :7]))
        self._session.stop_clips_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  stop_track_clip_buttons=self._matrix.submatrix[:7, 7],
                  stop_all_clips_button=self._grid[7][7]))
        """self._session_zoom = SessionOverviewComponent(name = 'Session_Overview', session_ring = self._session_ring, enable_skinning = True)
Пример #7
0
	def _setup_mixer_controls(self):
		self._session_ring = SessionRingComponent(name = 'Session_Ring', num_tracks = 8, num_scenes = 0)
		self._session_navigation = SessionNavigationComponent(name = 'Session_Navigation', session_ring = self._session_ring)
		self._session_navigation.layer = Layer(priority = 4, left_button = self._button[6][0], right_button = self._button[7][0])
		self._session_navigation.set_enabled(False)
		#self._session = SessionComponent(name = 'Session', session_ring = self._session_ring)
		self._mixer = CodecMixerComponent(num_returns = 4, name = 'Mixer', tracks_provider = self._session_ring, invert_mute_feedback = True, auto_name = True)
		self._mixer._mix_layer = AddLayerMode(self._mixer, Layer(priority = 4, volume_controls = self._encoder_matrix.submatrix[:8,3],
									pan_controls = self._encoder_matrix.submatrix[:8,2],
									send_controls = self._encoder_matrix.submatrix[:8, :2],
									))
		self._mixer._solo_mute_layer = AddLayerMode(self._mixer, Layer(priority = 4, solo_buttons = self._button_matrix.submatrix[:8,2],
									mute_buttons = self._button_matrix.submatrix[:8,3],
									))
		self._mixer._select_layer = AddLayerMode(self._mixer, Layer(priority = 4, track_select_buttons = self._code_keys))
		self._mixer._sends_layer = AddLayerMode(self._mixer, Layer(priority = 4, send_controls = self._encoder_matrix.submatrix[:, :]))
		self._mixer.set_enabled(False)
Пример #8
0
 def _create_session(self):
     self._session_ring = SessionRingComponent(name=u'Session_Ring',
                                               num_tracks=SESSION_WIDTH,
                                               num_scenes=SESSION_HEIGHT)
     self._session = SessionComponent(name=u'Session',
                                      session_ring=self._session_ring)
     self._session_navigation = SessionNavigationComponent(
         name=u'Session_Navigation',
         is_enabled=False,
         session_ring=self._session_ring,
         layer=Layer(left_button=u'left_button',
                     right_button=u'right_button'))
     self._session_navigation.set_enabled(True)
     self._session_overview = SessionOverviewComponent(
         name=u'Session_Overview',
         is_enabled=False,
         session_ring=self._session_ring,
         enable_skinning=True,
         layer=Layer(button_matrix=u'pads_with_zoom'))
Пример #9
0
	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 6, num_scenes = 4, tracks_to_use = tracks_to_use)
		self._session_ring.set_enabled(False)

		self._session_navigation = SessionNavigationComponent(session_ring = self._session_ring)
		self._session_navigation.navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 4, up_button = self._button[4], down_button = self._button[5], left_button = self._button[6], right_button = self._button[7]))
		self._session_navigation.page_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 4, page_up_button = self._button[4], page_down_button = self._button[5], page_left_button = self._button[6], page_right_button = self._button[7]))
		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation.set_enabled(False)

		self._session = BaseSessionComponent(name = 'Session', parent_task_group = self._task_group, session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.cliplaunch_layer = AddLayerMode(self._session, Layer(priority = 4, clip_launch_buttons = self._base_grid.submatrix[:6, :]))
		self._session.overlay_cliplaunch_layer = AddLayerMode(self._session, Layer(priority = 4, clip_launch_buttons = self._base_grid.submatrix[:5, :], scene_launch_buttons = self._base_grid.submatrix[5:6, :]))
		#self._session.clipstop_layer = AddLayerMode(self._session, Layer(priority = 4, stop_track_clip_buttons = self._base_grid.submatrix[:, 3:4]))
		self._session.set_enabled(False)
	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 1, num_scenes = 4, tracks_to_use = lambda : self.song.visible_tracks + self.song.return_tracks)
		self._session_ring.set_enabled(False)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(scene_launch_buttons = self._scene_launch_matrix)

		self._session_navigation =SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'

		self._session_navigation.layer = Layer(left_button = self._button[1], right_button = self._button[0])
		self._session_navigation.set_enabled(True)
 def _create_session(self):
     self._session_ring = SessionRingComponent(name=u'Session_Ring',
                                               num_tracks=SESSION_WIDTH,
                                               num_scenes=SESSION_HEIGHT)
     self._session = SessionComponent(
         name=u'Session',
         is_enabled=False,
         session_ring=self._session_ring,
         layer=Layer(clip_launch_buttons=u'pads',
                     scene_launch_buttons=u'scene_launch_buttons',
                     scene_encoder=u'encoder'))
     self._session.selected_scene().set_launch_button(
         self._elements.encoder_push_button)
     self._session.set_enabled(True)
     self._session_navigation = SessionNavigationComponent(
         name=u'Session_Navigation',
         is_enabled=False,
         session_ring=self._session_ring,
         layer=Layer(left_button=u'bank_left_button',
                     right_button=u'bank_right_button'))
     self._session_navigation.set_up_button(self._elements.rewind_button)
     self._session_navigation.set_down_button(
         self._elements.fastforward_button)
     self._session_navigation.set_enabled(True)
Пример #12
0
	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 7, num_scenes = 5)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(session_ring = self._session_ring)
		self._session_navigation.scroll_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 5, up_button = self._menu[2], down_button = self._menu[5], left_button = self._menu[3], right_button = self._menu[4]))
		self._session_navigation.page_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 5, page_up_button = self._menu[2], page_down_button = self._menu[5], page_left_button = self._menu[3], page_right_button = self._menu[4]))
		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation.set_enabled(False)

		self._session = OhmSessionComponent(name = 'Session', session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.set_enabled(False)
		self._session.clip_launch_layer = AddLayerMode(self._session, Layer(priority = 5,  clip_launch_buttons = self._matrix.submatrix[:7,:5]))
		self._session.scene_launch_layer = AddLayerMode(self._session, Layer(priority = 5,  scene_launch_buttons = self._matrix.submatrix[7,:5]))

		self._session_zoom = SessionOverviewComponent(name = 'Session_Overview', session_ring = self._session_ring, enable_skinning = True)
		self._session_zoom.layer = Layer(priority = 5, button_matrix = self._matrix.submatrix[:7,:5])
		self._session_zoom.set_enabled(False)

		self._session_modes = ModesComponent(name = 'Session_Modes')
		self._session_modes.add_mode('disabled', [self._session, 
														self._session.clip_launch_layer, 
														self._session.scene_launch_layer, 
														self._session_navigation, 
														self._session_navigation.scroll_navigation_layer])
		self._session_modes.add_mode('enabled', [self._session, 
														self._session.scene_launch_layer, 
														self._session_zoom, 
														self._session_navigation, 
														self._session_navigation.page_navigation_layer],  
														behaviour = DefaultedBehaviour())
		self._session_modes.layer = Layer(priority = 5, enabled_button = self._grid[7][7])
		self._session_modes.selected_mode = 'disabled'
		self._session_modes.set_enabled(False)
Пример #13
0
class KeyLabEssential(ControlSurface):
    mixer_component_type = MixerComponent
    session_component_type = SessionComponent
    view_control_component_type = ViewControlComponent
    hardware_settings_component_type = HardwareSettingsComponent
    channel_strip_component_type = ChannelStripComponent

    def __init__(self, *a, **k):
        super(KeyLabEssential, self).__init__(*a, **k)
        with self.component_guard():
            with inject(skin=const(default_skin)).everywhere():
                self._create_controls()
            self._create_hardware_settings()
        self._on_focused_view_changed.subject = self.application.view
        self._hardware_settings.set_hardware_live_mode_enabled(True)
        self._on_memory_preset_changed_on_hardware.subject = self._hardware_settings
        self._hardware_settings.select_memory_preset(
            sysex.DAW_MEMORY_PRESET_INDEX)
        with self.component_guard():
            self._create_transport()
            self._create_undo()
            self._create_session()
            self._create_navigation()
            self._create_mixer()
            self._create_view_control()
            self._create_arrangement()
            self._create_jogwheel_modes()

    def port_settings_changed(self):
        super(KeyLabEssential, self).port_settings_changed()
        self._hardware_settings.set_hardware_live_mode_enabled(True)

    def _create_controls(self):
        self._hardware_live_mode_switch = SysexElement(
            send_message_generator=lambda b: sysex.LIVE_MODE_MESSAGE_HEADER +
            (b, sysex.END_BYTE),
            default_value=sysex.OFF_VALUE,
            name=u'Hardware_Live_Mode_Switch')
        self._memory_preset_switch = SysexElement(
            send_message_generator=lambda b: sysex.
            MEMORY_PRESET_SWITCH_MESSAGE_HEADER + (b, sysex.END_BYTE),
            sysex_identifier=sysex.MEMORY_PRESET_SWITCH_MESSAGE_HEADER,
            name=u'Memory_Preset_Switch')
        self._memory_preset_select_mode_switch = SysexElement(
            sysex_identifier=sysex.MEMORY_PRESET_SELECT_MODE_MESSAGE_HEADER,
            name=u'Memory_Preset_Select_Mode')
        self._play_button = create_button(94, u'Play_Button')
        self._stop_button = create_button(93, u'Stop_Button')
        self._punch_in_button = create_button(87, u'Punch_In_Button')
        self._punch_out_button = create_button(88, u'Punch_Out_Button')
        self._metronome_button = create_button(89, u'Metronome_Button')
        self._loop_button = create_button(86, u'Loop_Button')
        self._rwd_button = create_button(91, u'Rewind_Button')
        self._ff_button = create_button(92, u'Fast_Forward_Button')
        self._record_button = create_button(95, u'Record_Button')
        self._undo_button = create_button(81, u'Undo_Button')
        self._bank_left_button = create_button(46, u'Bank_Left_Button')
        self._bank_right_button = create_button(47, u'Bank_Right_Button')
        self._left_button = create_button(48, u'Left_Button')
        self._right_button = create_button(49, u'Right_Button')
        self._left_arrow_button = create_button(98, u'Left_Arrow_Button')
        self._right_arrow_button = create_button(99, u'Right_Arrow_Button')
        self._marker_button = create_button(84, u'Marker_Button')
        self._pads = ButtonMatrixElement(rows=[[
            create_button(col + 36, u'Pad_%d' % (col, ), channel=10)
            for col in xrange(8)
        ]],
                                         name=u'Pad_Matrix')
        self._pad_leds = ButtonMatrixElement(rows=[[
            create_pad_led(column + 112, u'Pad_LED_%d' % (column, ))
            for column in xrange(8)
        ]],
                                             name=u'Pad_LED_Matrix')
        self._faders = ButtonMatrixElement(rows=[[
            SliderElement(msg_type=MIDI_PB_TYPE,
                          channel=index,
                          identifier=None,
                          name=u'Fader_%d' % (index, )) for index in xrange(8)
        ]],
                                           name=u'Faders')
        self._master_fader = SliderElement(MIDI_PB_TYPE,
                                           8,
                                           identifier=None,
                                           name=u'Master_Fader')
        self._encoders = ButtonMatrixElement(rows=[[
            create_ringed_encoder(index + 16, index + 48, u'Encoder_%d' %
                                  (index, )) for index in xrange(8)
        ]])
        self._jogwheel = EncoderElement(
            MIDI_CC_TYPE,
            0,
            60,
            Live.MidiMap.MapMode.relative_smooth_signed_bit,
            name=u'Jogwheel')

    def _create_hardware_settings(self):
        self._hardware_settings = self.hardware_settings_component_type(
            is_enabled=False,
            layer=Layer(
                hardware_live_mode_switch=self._hardware_live_mode_switch,
                memory_preset_switch=self._memory_preset_switch,
                memory_preset_select_mode_switch=self.
                _memory_preset_select_mode_switch),
            name=u'Hardware_Settings')
        self._hardware_settings.set_enabled(True)

    def _create_transport(self):
        self._transport = TransportComponent(
            is_enabled=False,
            layer=Layer(play_button=self._play_button,
                        stop_button=self._stop_button,
                        punch_in_button=self._punch_in_button,
                        punch_out_button=self._punch_out_button,
                        loop_button=self._loop_button,
                        metronome_button=self._metronome_button,
                        record_button=self._record_button))
        self._transport.set_seek_buttons(self._ff_button, self._rwd_button)
        self._transport.set_enabled(True)

    def _create_undo(self):
        self._undo = UndoComponent(is_enabled=False,
                                   layer=Layer(undo_button=self._undo_button))
        self._undo.set_enabled(True)

    def _create_session(self):
        self._session_ring = SessionRingComponent(
            num_tracks=self._pads.width(),
            num_scenes=self._pads.height(),
            name=u'Session_Ring')
        self._session_ring.set_enabled(False)
        self._session = self.session_component_type(
            session_ring=self._session_ring,
            name=u'Session',
            is_enabled=False,
            layer=Layer(clip_launch_buttons=self._pads,
                        clip_slot_leds=self._pad_leds))
        self._session.set_enabled(True)

    def _create_navigation(self):
        self._session_navigation = SessionNavigationComponent(
            session_ring=self._session_ring,
            is_enabled=False,
            layer=Layer(page_left_button=self._bank_left_button,
                        page_right_button=self._bank_right_button,
                        left_button=self._left_button,
                        right_button=self._right_button),
            name=u'Session_Navigation')
        self._session_navigation.set_enabled(True)

    def _create_mixer(self):
        self._mixer = self.mixer_component_type(
            tracks_provider=self._session_ring,
            channel_strip_component_type=self.channel_strip_component_type,
            is_enabled=False,
            layer=Layer(volume_controls=self._faders,
                        pan_controls=self._encoders))
        self._mixer.master_strip().set_volume_control(self._master_fader)
        self._mixer.set_enabled(True)

    def _create_view_control(self):
        self._view_control = self.view_control_component_type(
            is_enabled=False,
            layer=Layer(prev_track_button=self._left_arrow_button,
                        next_track_button=self._right_arrow_button,
                        scene_scroll_encoder=self._jogwheel),
            name=u'View_Control')
        self._view_control.set_enabled(True)

    def _create_arrangement(self):
        self._arrangement = ArrangementComponent(
            is_enabled=False,
            layer=Layer(set_or_delete_cue_button=self._marker_button),
            name=u'Arrangement')
        self._arrangement.set_enabled(True)

    def _create_jogwheel_modes(self):
        self._jogwheel_modes = ModesComponent()
        self._jogwheel_modes.add_mode(
            u'Session',
            AddLayerMode(self._view_control,
                         Layer(scene_scroll_encoder=self._jogwheel)))
        self._jogwheel_modes.add_mode(
            u'Arranger',
            AddLayerMode(self._arrangement,
                         Layer(jump_encoder=self._jogwheel)))
        self._on_focused_view_changed()

    @listens(u'focused_document_view')
    def _on_focused_view_changed(self):
        view = self.application.view.focused_document_view
        if self._jogwheel_modes:
            self._jogwheel_modes.selected_mode = view

    @listens(u'daw_preset')
    def _on_memory_preset_changed_on_hardware(self, is_daw_preset_on):
        self._session.set_allow_update(is_daw_preset_on)
        if is_daw_preset_on:
            for control in self.controls:
                control.clear_send_cache()

        self._session.set_enabled(is_daw_preset_on)
Пример #14
0
class Cntrlr(LividControlSurface):
	__module__ = __name__
	__doc__ = " Monomodular controller script for Livid CNTRLR "


	_sysex_id = 8
	_model_name = 'Cntrlr'
	_host_name = 'Cntrlr'
	monomodular = None

	device_provider_class = ModDeviceProvider

	def __init__(self, *a, **k):
		super(Cntrlr, self).__init__(*a, **k)
		self._skin = Skin(CntrlrColors)
		self._device_selection_follows_track_selection = FOLLOW
		with self.component_guard():
			self._setup_controls()
			self._define_sysex()
			self._setup_background()
			#self._setup_autoarm()
			self._setup_viewcontrol()
			self._setup_session_control()
			self._setup_mixer_control()
			self._setup_transport_control()
			#self._setup_device_control()
			#self._setup_device_selector()
			#self._setup_session_recording_component()
			#self._setup_modes()
			self._setup_m4l_interface()
	

	def _initialize_script(self):
		super(Cntrlr, self)._initialize_script()
		self._connected = True
		#self._main_modes.selected_mode = 'MixMode'

		self._session_ring._update_highlight()
		self._session_ring.track_offset = 0
		if liveobj_valid(self.song.visible_tracks[0]):
			self.song.view.selected_track = self.song.visible_tracks[0]
	

	def _setup_controls(self):
		is_momentary = True
		optimized = True
		resource = PrioritizedResource
		self._fader = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_FADERS[index], name = 'Fader_' + str(index), num = index, script = self,  optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(8)]
		self._dial_left = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_KNOBS_LEFT[index], name = 'Dial_Left_' + str(index), num = CNTRLR_KNOBS_LEFT[index], script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)]
		self._dial_right = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_KNOBS_RIGHT[index], name = 'Dial_Right_' + str(index), num = CNTRLR_KNOBS_RIGHT[index], script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)]
		self._encoder = [CodecEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_DIALS[index], name = 'Encoder_' + str(index), num = CNTRLR_DIALS[index], script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)] 
		self._encoder_button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CNTRLR_DIAL_BUTTONS[index], name = 'Encoder_Button_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)]	
		self._grid = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CNTRLR_GRID[index], name = 'Grid_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(16)]
		self._button = [MonoButtonElement(is_momentary = is_momentary,msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CNTRLR_BUTTONS[index], name = 'Button_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(32)]
		self._knobs = self._dial_left + self._dial_right

		self._fader_matrix = ButtonMatrixElement(name = 'Fader_Matrix', rows = [self._fader])
		self._matrix = ButtonMatrixElement(name = 'Matrix', rows = [self._grid[index*4:(index*4)+4] for index in range(4)])
		self._knob_left_matrix = ButtonMatrixElement(name = 'Knob_Left_Matrix', rows = [self._dial_left[index*4:(index*4)+4] for index in range(3)])
		self._knob_right_matrix = ButtonMatrixElement(name = 'Knob_Right_Matrix', rows = [self._dial_right[index*4:(index*4)+4] for index in range(3)])
		self._dial_matrix = ButtonMatrixElement(name = 'Dial_Matrix', rows = [self._encoder[index*4:(index*4)+4] for index in range(3)])
		self._dial_button_matrix = ButtonMatrixElement(name = 'Dial_Button_Matrix', rows = [self._encoder_button[index*4:(index*4)+4] for index in range(1,3)])
		self._key_matrix = ButtonMatrixElement(name = 'Key_Matrix', rows = [self._button[0:16], self._button[16:32]])
		
		self._translated_controls = self._fader + self._knobs + self._encoder[4:] + self._grid + self._button
	

	def _setup_background(self):
		self._background = BackgroundComponent(name = 'Background')
		self._background.layer = Layer(priority = 3, matrix = self._matrix.submatrix[:,:], faders = self._fader_matrix.submatrix[:,:], left_knobs = self._knob_left_matrix.submatrix[:,:], right_knobs = self._knob_right_matrix.submatrix[:,:], dials = self._dial_matrix, dial_buttons = self._dial_button_matrix.submatrix[:,:], keys = self._key_matrix.submatrix[:,:])
		self._background.set_enabled(True)
	

	def _define_sysex(self):
		#self.encoder_navigation_on = SendLividSysexMode(livid_settings = self._livid_settings, call = 'set_encoder_encosion_mode', message = [13, 0, 0, 0]) 
		pass
	

	def _setup_transport_control(self):
		self._transport = CntrlrTransportComponent(name = 'Transport') 
		self._transport._play_toggle.view_transform = lambda value: 'Transport.PlayOn' if value else 'Transport.PlayOff'
		self._transport._record_toggle.view_transform = lambda value: 'Transport.RecordOn' if value else 'Transport.RecordOff'
		self._transport._nudge_up_toggle.view_transform = lambda value: 'Transport.NudgeOn' if value else 'Transport.NudgeOff'
		self._transport._nudge_down_toggle.view_transform = lambda value: 'Transport.NudgeOn' if value else 'Transport.NudgeOff'
		self._transport._loop_toggle.view_transform = lambda value: 'Transport.LoopOn' if value else 'Transport.LoopOff'
		self._transport.layer = Layer(priority = 4,
									play_button = self._button[28],
									stop_button = self._button[29],
									record_button = self._button[30],
									tap_tempo_button = self._button[31],
									nudge_up_button = self._button[3],
									nudge_down_button = self._button[19],
									loop_button = self._button[23])
		self._transport.set_enabled(True)
	

	def _setup_autoarm(self):
		self._auto_arm = CntrlrAutoArmComponent(name='Auto_Arm')
		#self._auto_arm._update_notification = lambda a: None
		self._auto_arm.can_auto_arm_track = self._can_auto_arm_track
	

	def _setup_session_recording_component(self):
		self._clip_creator = ClipCreator()
		self._clip_creator.name = 'ClipCreator'
		self._recorder = FixedLengthSessionRecordingComponent(clip_creator = self._clip_creator, view_controller = ViewControlComponent(), name = 'SessionRecorder') # is_enabled = False)
		self._recorder.main_layer = AddLayerMode(self._recorder, Layer(priority = 4, record_button = self._button[29]))
		#self._recorder.shift_layer = AddLayerMode(self._recorder, Layer(priority = 4, automation_button = self._button[29]))
		self._recorder.set_enabled(False)
	

	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 4, num_scenes = 4)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'

		self._session_navigation.layer = Layer(priority = 4,
									down_button = self._button[14],
									up_button = self._button[15],
									left_button = self._button[12],
									right_button = self._button[13])
		self._session_navigation.set_enabled(True)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(priority = 4,
									clip_launch_buttons = self._matrix.submatrix[:,:])
		self._session.set_enabled(True)
	

	def _setup_mixer_control(self):
		self._mixer_session_ring = SessionRingComponent(num_tracks = 4, num_scenes = 4)
		self._mixer = MonoMixerComponent(name = 'Mixer', tracks_provider = self._mixer_session_ring, track_assigner = simple_track_assigner, invert_mute_feedback = True, auto_name = True, enable_skinning = True)

		self._mixer.layer = Layer(priority = 4, 
											solo_buttons = self._key_matrix.submatrix[8:11, 0],
											stop_clip_buttons = self._key_matrix.submatrix[:3, 0],
											track_select_buttons = self._key_matrix.submatrix[4:8, 0],)
		for strip in self._mixer._channel_strips:
			strip._on_select_button_double_clicked = self._toggle_view
		self._mixer.set_enabled(True)
	

	def _toggle_view(self, *a):
		debug('toggle_view')
		debug('Clip is visible:', self.application().view.is_view_visible('Detail/Clip'))
		debug('Device is visible:', self.application().view.is_view_visible('Detail/DeviceChain'))
		if self.application().view.is_view_visible('Detail/Clip'):
			self._view_control.show_view('Detail/DeviceChain')
		else:
			self._view_control.show_view('Detail/Clip')

	def _setup_device_control(self):
		self._device_selection_follows_track_selection = FOLLOW
		self._device = DeviceComponent(name = 'Device_Component', device_provider = self._device_provider, device_bank_registry = DeviceBankRegistry())
		self._device.layer = Layer(priority = 4, parameter_controls = self._dial_matrix.submatrix[:, 1:3],)
		#self._device.mod_layer = AddLayerMode(self._device, Layer(priority = 4, parameter_controls = self._dial_matrix.submatrix[:, 1:3],))
		self._device.main_layer = AddLayerMode(self._device, Layer(priority = 4, parameter_controls = self._dial_matrix.submatrix[:, 1:3], 
												on_off_button = self._encoder_button[4],
												bank_prev_button = self._encoder_button[6],
												bank_next_button = self._encoder_button[7],))
												#lock_button = self._encoder_button[5],
		self._device.set_enabled(False)

		self._device_navigator = DeviceNavigator(self._device_provider, self._mixer, self)
		self._device_navigator.name = 'Device_Navigator'
		self._device_navigator.select_dial_layer = AddLayerMode(self._device_navigator, Layer(priority = 6, device_select_dial = self._encoder[0],))
		self._device_navigator.main_layer = AddLayerMode(self._device_navigator, Layer(priority = 4, 
											prev_chain_button = self._encoder_button[8], 
											next_chain_button = self._encoder_button[9], 
											exit_button = self._encoder_button[10], 
											enter_button = self._encoder_button[11],))
		self._device_navigator.set_enabled(False)
	

	def _setup_device_selector(self):
		self._device_selector = DeviceSelectorComponent(self)
		self._device_selector.name = 'Device_Selector'
		#self._device_selector.select_layer = AddLayerMode(self._device_selector, Layer(priority = 6 , matrix = self._matrix.submatrix[:, :]))
		self._device_selector.select_layer = AddLayerMode(self._device_selector, Layer(priority = 6, matrix = ButtonMatrixElement(rows = [self._grid[:4],self._grid[4:8],self._grid[8:12],self._grid[12:14]])))
		self._device_selector.assign_layer = AddLayerMode(self._device_selector, Layer(priority = 7, assign_button = self._grid[14]))
		self._device_selector.set_enabled(False)
	

	def _setup_viewcontrol(self):
		self._view_control = ViewControlComponent(name='View_Control')
		#self._view_control.main_layer = AddLayerMode(self._view_control, Layer(priority = 5, 
		#																		scene_select_dial = self._encoder[2],
		#																		track_select_dial = self._encoder[3],))
		#self._view_control.main_layer = AddLayerMode(self._view_control, Layer(prev_track_button=self._button[24], 
		#											next_track_button= self._button[25], 
		#											next_scene_button=self._button[27], 
		#											prev_scene_button = self._button[26]))
		self._view_control.set_enabled(True)
	

	def _setup_modes(self):

		common = CompoundMode(self._mixer,
									self._session_ring)
		main_buttons=CompoundMode(self._mixer.main_buttons_layer, 
									self._transport,
									self._recorder,
									self._recorder.main_layer, 
									self._device,)
		shifted_main_buttons=CompoundMode(self._mixer.solo_buttons_layer, 
									self._recorder, 
									self._recorder.shift_layer,
									self._session.scene_launch_layer,
									self._device,)
		main_faders=CompoundMode(self._mixer.main_faders_layer, 
									self._mixer.master_fader_layer)
		main_dials=CompoundMode(self._view_control,
									self._view_control.main_layer,
									self._device_navigator,
									self._device_navigator.select_dial_layer,
									self.encoder_navigation_on)
		shifted_dials=CompoundMode(self._session_navigation,
									self._session_navigation.nav_dial_layer,
									self._device_navigator,
									self._device_navigator.select_dial_layer,
									self.encoder_navigation_on)

		self._modalt_mode = ModesComponent(name = 'ModAltMode')
		self._modalt_mode.add_mode('disabled', None)
		self._modalt_mode.add_mode('enabled', [tuple([self._enable_mod_alt, self._disable_mod_alt])], behaviour = CancellableBehaviourWithRelease(), cycle_mode_button_color = 'Mod.AltOn')
		self._modalt_mode.selected_mode = 'disabled'
		self._modalt_mode.set_enabled(False)
		self._modalt_mode.layer = Layer(priority = 4, enabled_button = self._encoder_button[1])

		self._modswitcher = ModesComponent(name = 'ModSwitcher')
		self._modswitcher.add_mode('mod', [self.modhandler, self._modalt_mode, main_faders, self._mixer.main_knobs_layer, self._device, main_dials, DelayMode(self.modhandler.update, delay = .5, parent_task_group = self._task_group)])
		self._modswitcher.add_mode('instrument', [self._instrument.shift_button_layer, main_buttons, main_faders, self._mixer.main_knobs_layer, self._device, self._device.main_layer, self._device_navigator, self._device_navigator.main_layer, self._device_navigator.select_dial_layer]) #self._instrument.shift_button_layer, self._optional_translations])
		self._modswitcher.selected_mode = 'instrument'
		self._modswitcher.set_enabled(False)

		self._instrument._main_modes = ModesComponent(name = 'InstrumentModes')
		self._instrument._main_modes.add_mode('disabled', [main_buttons, 
																					main_dials, 
																					self._device.main_layer, 
																					self._session, 
																					self._session, 
																					self._session.clip_launch_layer])
		self._instrument._main_modes.add_mode('drumpad', [self._instrument._drumpad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_split', [self._instrument._drumpad.split_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer', [self._instrument._drumpad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_shifted', [self._instrument._drumpad.sequencer_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_split_shifted', [self._instrument._drumpad.split_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer_shifted', [self._instrument._drumpad.sequencer_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad', [self._instrument._keypad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_split', [self._instrument._keypad.split_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer', [self._instrument._keypad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_shifted', [self._instrument._keypad.sequencer_shift_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_split_shifted', [self._instrument._keypad.split_layer, 
																					self._instrument.keypad_shift_layer,
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer_shifted', [self._instrument._keypad.sequencer_shift_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_session', [self._instrument._drumpad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_split_session', [self._instrument._drumpad.split_session_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer_session', [self._instrument._drumpad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session,  
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_shifted_session', [self._instrument._drumpad.sequencer_session_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_split_shifted_session', [self._instrument._drumpad.split_session_layer,
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer_shifted_session', [self._instrument._drumpad.sequencer_session_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_session', [self._instrument._keypad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session, 
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_split_session', [self._instrument._keypad.split_session_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer_session', [self._instrument._keypad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session, 
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_shifted_session', [self._instrument._keypad.sequencer_session_shift_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_split_shifted_session', [self._instrument._keypad.split_session_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer_shifted_session', [self._instrument._keypad.sequencer_session_shift_layer,
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])

		self._instrument._main_modes.add_mode('audioloop', [self._instrument.audioloop_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1)])
		self._instrument._main_modes.add_mode('audioloop_shifted', [self._instrument.audioloop_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		#self._instrument._main_modes.add_mode('audioloop_shifted_session', [self._instrument.audioloop_layer, self._session, shifted_main_buttons, main_dials, shifted_dials])
		self._instrument.register_component(self._instrument._main_modes)
		self._instrument._main_modes.selected_mode = 'disabled'
		self._instrument.set_enabled(True)

		self._main_modes = ModesComponent(name = 'MainModes')
		self._main_modes.add_mode('disabled', [self._background])
		self._main_modes.add_mode('MixMode', [common, 
													self._instrument, 
													self._instrument.shift_button_layer,
													self._mixer,
													main_faders, 
													self._mixer.main_knobs_layer,
													self._device,
													self._device.main_layer,
													self._device_navigator,
													self._device_navigator.main_layer,
													self._device_navigator.select_dial_layer])
		self._main_modes.add_mode('ModSwitcher', [common,
													main_faders, 
													main_dials, 
													self._mixer.main_knobs_layer,
													self._view_control,
													self._view_control.main_layer,
													self._device_navigator,
													self._device_navigator.select_dial_layer, 
													self.encoder_navigation_on, 
													self._modswitcher, 
													DelayMode(self._update_modswitcher, delay = .1)], 
													behaviour = ColoredCancellableBehaviourWithRelease(color = 'ModeButtons.ModSwitcher', off_color = 'ModeButtons.ModSwitcherDisabled'))
		self._main_modes.add_mode('Translations', [common, 
													main_faders, 
													main_dials,
													self._mixer.main_knobs_layer, 
													self._translations, 
													DelayMode(self._translations.selector_layer, delay = .1)], 
													behaviour = DefaultedBehaviour(default_mode = 'MixMode', color = 'ModeButtons.Translations', off_color = 'ModeButtons.TranslationsDisabled'))
		self._main_modes.add_mode('DeviceSelector', [common,
													self._device_selector,
													DelayMode(self._device_selector.select_layer, delay = .1),
													DelayMode(self.modhandler.lock_layer, delay = .1),
													DelayMode(self._device_selector.assign_layer, delay = .5), 
													main_buttons,
													main_dials, 
													main_faders, 
													self._mixer.main_knobs_layer, 
													self._device.main_layer,
													self._device_navigator,
													self._device_navigator.main_layer,
													self._device_navigator.select_dial_layer], 
													behaviour = ColoredCancellableBehaviourWithRelease(color = 'ModeButtons.DeviceSelector', off_color = 'ModeButtons.DeviceSelectorDisabled'))
		self._main_modes.layer = Layer(priority = 4, ModSwitcher_button = self._encoder_button[2], DeviceSelector_button = self._encoder_button[0], Translations_button = self._encoder_button[3]) #, 
		self._main_modes.selected_mode = 'disabled'
		self._main_modes.set_enabled(True)

		self._test.subject = self._instrument._main_modes
	

	def _setup_modes(self):
		pass
	

	def _setup_m4l_interface(self):
		self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard, priority = 10)
		self._m4l_interface.name = "M4LInterface"
		self.get_control_names = self._m4l_interface.get_control_names
		self.get_control = self._m4l_interface.get_control
		self.grab_control = self._m4l_interface.grab_control
		self.release_control = self._m4l_interface.release_control
	

	def _can_auto_arm_track(self, track):
		routing = track.current_input_routing
		return routing == 'Ext: All Ins' or routing == 'All Ins' or routing.startswith('Cntrlr Input')
	

	def _get_num_tracks(self):
		return self.num_tracks
	



#	a
Пример #15
0
class ATOMSQ(ControlSurface):
    def __init__(self, *a, **k):
        super(ATOMSQ, self).__init__(*a, **k)
        with self.component_guard():
            self._elements = Elements()
            with inject(element_container=const(self._elements)).everywhere():
                self._create_background()
                self._create_transport()
                self._create_undo()
                self._create_view_toggle()
                self._create_device_parameters()
                self._create_translating_background()
                self._create_device_navigation()
                self._create_launch_and_stop()
                self._create_session()
                self._create_mixer()
                self._create_view_control()
                self._create_button_labels()
                self._create_record_modes()
                self._create_lower_pad_modes()
                self._create_main_modes()
        self.__on_main_view_changed.subject = self.application.view

    def disconnect(self):
        super(ATOMSQ, self).disconnect()
        self._send_midi(midi.NATIVE_MODE_OFF_MESSAGE)

    def port_settings_changed(self):
        self._send_midi(midi.NATIVE_MODE_ON_MESSAGE)
        if self._main_modes.selected_mode == b'instrument':
            self.schedule_message(
                1, self._elements.upper_firmware_toggle_switch.send_value, 1)
        if self._main_modes.selected_mode != b'song':
            self.schedule_message(
                1, self._elements.lower_firmware_toggle_switch.send_value, 1)
        super(ATOMSQ, self).port_settings_changed()

    def _create_background(self):
        self._background = BackgroundComponent(
            name=b'Background',
            is_enabled=False,
            add_nop_listeners=True,
            layer=Layer(**{name: name
                           for name in BANK_BUTTON_NAMES}))
        self._background.set_enabled(True)

    def _create_transport(self):
        self._transport = TransportComponent(
            name=b'Transport',
            is_enabled=False,
            layer=Layer(scroll_encoder=b'display_encoder',
                        play_button=b'play_button',
                        loop_button=b'play_button_with_shift',
                        stop_button=b'stop_button',
                        metronome_button=b'click_button',
                        capture_midi_button=b'record_button_with_shift',
                        prev_cue_button=b'display_left_button',
                        next_cue_button=b'display_right_button',
                        shift_button=b'shift_button'))
        self._transport.set_enabled(True)

    def _create_undo(self):
        self._undo = UndoRedoComponent(
            name=b'Undo',
            is_enabled=False,
            layer=Layer(undo_button=b'stop_button_with_shift'))
        self._undo.set_enabled(True)

    def _create_view_toggle(self):
        self._view_toggle = ViewToggleComponent(
            name=b'View_Toggle',
            is_enabled=False,
            layer=Layer(main_view_toggle_button=b'bank_a_button',
                        browser_view_toggle_button=b'bank_b_button',
                        detail_view_toggle_button=b'bank_d_button',
                        clip_view_toggle_button=b'bank_h_button'))

    def _create_device_parameters(self):
        self._device_parameters = SimpleDeviceParameterComponent(
            name=b'Device_Parameters',
            device_bank_registry=self._device_bank_registry,
            toggle_lock=self.toggle_lock,
            layer=Layer(device_name_display=b'device_name_display'),
            is_enabled=False)
        self._device_parameters.set_enabled(True)

    def _create_translating_background(self):
        self._translating_background = TranslatingBackgroundComponent(
            name=b'Translating_Background',
            is_enabled=False,
            add_nop_listeners=True,
            layer=Layer(encoders=b'encoders',
                        channel_selection_buttons=b'display_buttons'))

    def _create_device_navigation(self):
        self._device_navigation = SimpleDeviceNavigationComponent(
            name=b'Device_Navigation',
            is_enabled=False,
            layer=Layer(prev_button=b'display_buttons_raw[1]',
                        next_button=b'display_buttons_raw[2]'))

    def _create_launch_and_stop(self):
        self._launch_and_stop = LaunchAndStopComponent(
            name=b'Launch_And_Stop',
            is_enabled=False,
            layer=Layer(clip_launch_button=b'display_buttons_raw[3]',
                        scene_launch_button=b'display_buttons_raw[4]',
                        track_stop_button=b'display_buttons_raw[5]'))

    def _create_session(self):
        self._session_ring = SessionRingComponent(name=b'Session_Ring',
                                                  num_tracks=SESSION_WIDTH,
                                                  num_scenes=SESSION_HEIGHT)
        self._session = SessionComponent(
            name=b'Session',
            is_enabled=False,
            session_ring=self._session_ring,
            layer=Layer(clip_launch_buttons=b'upper_pads'))
        self._session_navigation = SessionNavigationComponent(
            name=b'Session_Navigation',
            is_enabled=False,
            session_ring=self._session_ring,
            layer=Layer(up_button=b'up_button_with_shift',
                        down_button=b'down_button_with_shift'))
        self._session_navigation.set_enabled(True)

    def _create_mixer(self):
        self._mixer = MixerComponent(
            name=b'Mixer',
            auto_name=True,
            tracks_provider=self._session_ring,
            track_assigner=SimpleTrackAssigner(),
            channel_strip_component_type=ChannelStripComponent)
        self._mixer.selected_strip().layer = Layer(
            track_name_display=b'track_name_display')
        self._mixer.set_enabled(True)

    def _create_view_control(self):
        self._view_control = NotifyingViewControlComponent(
            name=b'View_Control',
            is_enabled=False,
            track_provider=self._session_ring,
            enable_skinning=False,
            layer=Layer(next_track_button=b'right_button',
                        prev_track_button=b'left_button',
                        next_scene_button=b'down_button',
                        prev_scene_button=b'up_button'))
        self._view_control.set_enabled(True)
        self._session_ring_selection_linking = self.register_disconnectable(
            SessionRingSelectionLinking(
                session_ring=self._session_ring,
                selection_changed_notifier=self._view_control))

    def _create_button_labels(self):
        self._button_labels = ButtonLabelsComponent(
            is_enabled=False,
            layer=Layer(display_lines=b'button_label_display_matrix'))
        self._button_labels.set_enabled(True)

    def _create_record_modes(self):
        self._session_record = SessionRecordingComponent(
            name=b'Session_Record',
            is_enabled=False,
            layer=Layer(record_button=b'record_button'))
        self._record_modes = ModesComponent(name=b'Record_Modes')
        self._record_modes.add_mode(b'session',
                                    EnablingMode(self._session_record))
        self._record_modes.add_mode(
            b'arrange',
            AddLayerMode(self._transport,
                         layer=Layer(record_button=b'record_button')))
        self.__on_main_view_changed()

    def _create_lower_pad_modes(self):
        self._lower_pad_modes = ModesComponent(
            name=b'Lower_Pad_Modes',
            is_enabled=False,
            layer=Layer(cycle_mode_button=b'minus_button'))
        self._lower_pad_modes.add_mode(
            b'select',
            AddLayerMode(self._mixer,
                         Layer(track_select_buttons=b'lower_pads')),
            cycle_mode_button_color=b'Session.StopClipDisabled')
        self._lower_pad_modes.add_mode(
            b'stop',
            AddLayerMode(self._session,
                         Layer(stop_track_clip_buttons=b'lower_pads')),
            cycle_mode_button_color=b'Session.StopClip')
        self._lower_pad_modes.selected_mode = b'select'

    def _create_main_modes(self):
        self._main_modes = ModesComponent(
            name=b'Main_Modes',
            is_enabled=False,
            layer=Layer(song_button=b'song_mode_button',
                        instrument_button=b'instrument_mode_button',
                        editor_button=b'editor_mode_button',
                        user_button=b'user_mode_button'))
        device_params_mode = AddLayerMode(
            self._device_parameters, Layer(parameter_controls=b'encoders'))
        enable_lower_fw_functions = partial(
            self._elements.lower_firmware_toggle_switch.send_value, 1)
        disable_upper_fw_functions = partial(
            self._elements.upper_firmware_toggle_switch.send_value, 0)
        self._main_modes.add_mode(
            b'song',
            (partial(self._elements.lower_firmware_toggle_switch.send_value,
                     0), disable_upper_fw_functions,
             self._elements.display_buttons.reset, self._view_toggle,
             self._launch_and_stop, self._session, self._lower_pad_modes,
             AddLayerMode(self._session.scene(0),
                          Layer(launch_button=b'plus_button')),
             AddLayerMode(
                 self._mixer.selected_strip(),
                 Layer(volume_control=b'encoders_raw[0]',
                       pan_control=b'encoders_raw[1]',
                       send_controls=self._elements.encoders.submatrix[2:, :],
                       solo_button=b'display_buttons_raw[0]',
                       mute_button=b'display_buttons_raw[1]',
                       arm_button=b'display_buttons_raw[2]')),
             AddLayerMode(self._mixer,
                          Layer(crossfader_control=b'touch_strip'))))
        self._main_modes.add_mode(
            b'instrument',
            (enable_lower_fw_functions,
             partial(self._elements.upper_firmware_toggle_switch.send_value,
                     1), device_params_mode))
        self._main_modes.add_mode(
            b'editor',
            (enable_lower_fw_functions, disable_upper_fw_functions,
             device_params_mode, self._device_navigation,
             AddLayerMode(
                 self._device_parameters,
                 Layer(device_lock_button=b'display_buttons_raw[0]',
                       device_on_off_button=b'display_buttons_raw[3]',
                       prev_bank_button=b'display_buttons_raw[4]',
                       next_bank_button=b'display_buttons_raw[5]'))))
        self._main_modes.add_mode(
            b'user', (enable_lower_fw_functions, disable_upper_fw_functions,
                      self._translating_background))
        self._main_modes.selected_mode = b'instrument'
        self._main_modes.set_enabled(True)
        self.__on_main_modes_changed.subject = self._main_modes

    @listens(b'selected_mode')
    def __on_main_modes_changed(self, mode):
        self._button_labels.show_button_labels_for_mode(mode)
        self._elements.track_name_display.clear_send_cache()
        self._elements.device_name_display.clear_send_cache()

    @listens(b'is_view_visible', b'Session')
    def __on_main_view_changed(self):
        if self.application.view.is_view_visible(b'Session'):
            self._record_modes.selected_mode = b'session'
        else:
            self._record_modes.selected_mode = b'arrange'
Пример #16
0
class OhmModes(LividControlSurface):


	_sysex_id = 2
	_alt_sysex_id = 7
	_model_name = 'Ohm'
	_version_check = 'b996'
	_host_name = 'Ohm'

	def __init__(self, c_instance):
		super(OhmModes, self).__init__(c_instance)
		self._skin = Skin(OhmColors)
		with self.component_guard():
			self._define_sysex()
			self._setup_controls()
			self._setup_background()
			self._setup_m4l_interface()
			self._setup_translations()
			self._setup_session_control()
			self._setup_mixer_control()
			self._setup_device_control()
			self._setup_transport_control()
			self._setup_drumgroup()
			self._setup_keygroup()
			self._setup_bassgroup()
			self._setup_mod()
			self._setup_modswitcher()
			self._setup_modes()
		self._on_device_changed.subject = self._device_provider
	

	def _define_sysex(self):
		#self._send_midi(tuple(switchxfader))
		self._reverse_crossfader = SendLividSysexMode(self._livid_settings, call = 'reverse crossfader', message = [1])
	

	def update_display(self):
		super(OhmModes, self).update_display()
		#self.strobe()
	

	def _initialize_hardware(self):
		super(OhmModes, self)._initialize_hardware()
		#self._reverse_crossfader.enter_mode()
	

	def _initialize_script(self):
		super(OhmModes, self)._initialize_script()
		self._main_modes.selected_mode = 'Mix'
		self._session.update()
		self._mixer.update()
	

	def _setup_controls(self):
		is_momentary = True
		optimized = True
		resource = PrioritizedResource
		self._fader = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = OHM_FADERS[index], name = 'Fader_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource) for index in range(8)]
		self._button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = OHM_BUTTONS[index], name = 'Button_' + str(index), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource) for index in range(8)]
		self._dial = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = OHM_DIALS[index], name = 'Encoder_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource) for index in range(16)]
		self._menu = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = OHM_MENU[index], name = 'Menu_' + str(index), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource) for index in range(6)]
		self._crossfader = MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CROSSFADER, name = 'Crossfader', script = self, optimized_send_midi = optimized, resource_type = resource)
		self._livid = MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = LIVID, name = 'Livid_Button', skin = self._skin, script = self, optimized_send_midi = optimized, resource_type = resource)
		self._shift_l = MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = SHIFT_L, name = 'Page_Button_Left', script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource)
		self._shift_r = MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = SHIFT_R, name = 'Page_Button_Right', script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource)
		self._grid = [[MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = column * 8 + row, name = 'Grid_' + str(column + (row*8)), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource) for column in range(8)] for row in range(8)]
		self._matrix = ButtonMatrixElement(name = 'Matrix', rows = [[self._grid[row][column] for column in range(8)] for row in range(8)])
		self._dial_matrix = ButtonMatrixElement(name = 'DialMatrix', rows = [self._dial[index*4:(index*4)+4] for index in range(4)])
		self._menu_matrix = ButtonMatrixElement(name = 'MenuMatrix', rows = [self._menu])
		self._fader_matrix = ButtonMatrixElement(name = 'FaderMatrix', rows = [self._fader])
		self._button_matrix = ButtonMatrixElement(name = 'ButtonMatrix', rows = [self._button])

		self._parameter_controls = ButtonMatrixElement(rows = [self._dial[:4], self._dial[4:8]])
	

	def _setup_background(self):
		self._background = BackgroundComponent(name = 'Background')
		self._background.layer = Layer(priority = 3, matrix = self._matrix.submatrix[:,:],
													livid_button = self._livid,
													shift_l_button = self._shift_l,
													shift_r_button = self._shift_r,
													crossfader = self._crossfader,
													dial_matrix = self._dial_matrix.submatrix[:,:],
													menu_matrix = self._menu_matrix.submatrix[:,:],
													fader_matrix = self._fader_matrix.submatrix[:,:],
													button_matrix = self._button_matrix.submatrix[:,:])
		self._background.set_enabled(False)
	

	def _setup_m4l_interface(self):
		self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard)
		self.get_control_names = self._m4l_interface.get_control_names
		self.get_control = self._m4l_interface.get_control
		self.grab_control = self._m4l_interface.grab_control
		self.release_control = self._m4l_interface.release_control
	

	def _setup_translations(self):
		controls = []
		for array in self._grid:
			for button in array:
				controls.append(button)
		if FADER_BANKING:
			controls = controls + self._dial
		if DIAL_BANKING:
			controls = controls + self._dial
		self._translations = TranslationComponent(controls = controls, user_channel_offset = USER_CHANNEL, channel = 8)
		self._translations.layer = Layer(priority = 5, channel_selector_buttons = self._menu_matrix.submatrix[:,:])
		self._translations.set_enabled(False)

		dj_controls = [self._grid[7][index] for index in range(7)]
		self._dj_translation = TranslationComponent(controls = dj_controls, channel = 12)
	

	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 7, num_scenes = 5)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(session_ring = self._session_ring)
		self._session_navigation.scroll_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 5, up_button = self._menu[2], down_button = self._menu[5], left_button = self._menu[3], right_button = self._menu[4]))
		self._session_navigation.page_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 5, page_up_button = self._menu[2], page_down_button = self._menu[5], page_left_button = self._menu[3], page_right_button = self._menu[4]))
		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation.set_enabled(False)

		self._session = OhmSessionComponent(name = 'Session', session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.set_enabled(False)
		self._session.clip_launch_layer = AddLayerMode(self._session, Layer(priority = 5,  clip_launch_buttons = self._matrix.submatrix[:7,:5]))
		self._session.scene_launch_layer = AddLayerMode(self._session, Layer(priority = 5,  scene_launch_buttons = self._matrix.submatrix[7,:5]))

		self._session_zoom = SessionOverviewComponent(name = 'Session_Overview', session_ring = self._session_ring, enable_skinning = True)
		self._session_zoom.layer = Layer(priority = 5, button_matrix = self._matrix.submatrix[:7,:5])
		self._session_zoom.set_enabled(False)

		self._session_modes = ModesComponent(name = 'Session_Modes')
		self._session_modes.add_mode('disabled', [self._session, 
														self._session.clip_launch_layer, 
														self._session.scene_launch_layer, 
														self._session_navigation, 
														self._session_navigation.scroll_navigation_layer])
		self._session_modes.add_mode('enabled', [self._session, 
														self._session.scene_launch_layer, 
														self._session_zoom, 
														self._session_navigation, 
														self._session_navigation.page_navigation_layer],  
														behaviour = DefaultedBehaviour())
		self._session_modes.layer = Layer(priority = 5, enabled_button = self._grid[7][7])
		self._session_modes.selected_mode = 'disabled'
		self._session_modes.set_enabled(False)
	

	def _setup_mixer_control(self):
		self._mixer = OhmMixerComponent(name = 'Mixer', tracks_provider = self._session_ring, track_assigner = simple_track_assigner, invert_mute_feedback = True, auto_name = True, enable_skinning = True)
		self._mixer.layer = Layer(priority = 5, volume_controls = self._fader_matrix.submatrix[:7, :], prehear_volume_control = self._dial[15], crossfader_control = self._crossfader)
		self._mixer.master_strip().layer = Layer(priority = 5, volume_control = self._fader[7], select_button = self._button[7])
		self._mixer.mix_layer = AddLayerMode(self._mixer, Layer(priority = 5, mute_buttons = self._matrix.submatrix[:7,5], 
													solo_buttons = self._matrix.submatrix[:7,6], 
													arm_buttons = self._matrix.submatrix[:7,7], 
													send_controls = self._dial_matrix.submatrix[:,:2],
													pan_controls = self._dial_matrix.submatrix[:7,2:],
													track_select_buttons = self._button_matrix.submatrix[:7,:],))
		self._mixer.dj_layer = AddLayerMode(self._mixer, Layer(priority = 5, mute_buttons = self._matrix.submatrix[:7,5],
													crossfade_toggles = self._matrix.submatrix[:7,6],
													end_pan_controls = self._dial_matrix.submatrix[:3,3],
													eq_gain_controls = self._dial_matrix.submatrix[:,:3],
													track_select_buttons = self._button_matrix.submatrix[:7,:],))
		self._mixer.instrument_layer = AddLayerMode(self._mixer, Layer(priority = 5, 
													instrument_send_controls = self._dial_matrix.submatrix[:,2:],
													arming_track_select_buttons = self._button_matrix.submatrix[:7,:]))
	

	def _setup_device_control(self):
		self._device = OhmDeviceComponent(script = self, name = 'Device_Component', device_provider = self._device_provider, device_bank_registry = DeviceBankRegistry())
		self._device.layer = Layer(priority = 5, parameter_controls = self._parameter_controls )
		self._device.set_enabled(False)

		self._device_navigator = DeviceNavigator(self._device_provider, self._mixer, self, name = 'Device_Navigator', )
		self._device_navigator.layer = Layer(priority = 5, prev_button = self._menu[3], next_button = self._menu[4])
		self._device_navigator.set_enabled(False)
	

	def _setup_transport_control(self):
		self._transport = OhmTransportComponent()
		self._transport.name = 'Transport'
		self._transport.layer = Layer(priority = 5, play_button = self._menu[0], stop_button = self._menu[1])
		self._transport.set_enabled(False)
	

	def _setup_drumgroup(self):
		self._drumgroup = MonoDrumGroupComponent(translation_channel = PAGE1_DRUM_CHANNEL, set_pad_translations = self.set_pad_translations)
		self._drumgroup._on_selected_track_changed.subject = None
		self._drumgroup.translation_channel = PAGE1_DRUM_CHANNEL
		self._drumgroup.layer = Layer(priority = 6, matrix = self._matrix.submatrix[:4, :4])
		self._drumgroup.set_enabled(False)
	

	def _setup_keygroup(self):
		self._scale_mode = ModesComponent(name = 'ScaleMode')
		for scale in SCALES:
			debug('making scale mode:', scale, str(scale))
			self._scale_mode.add_mode(str(scale), [])
		self._scale_mode.layer = Layer(priority = 5, 
										ionian_button = self._grid[7][0],
										dorian_button = self._grid[7][1],
										phrygian_button = self._grid[7][2],
										lydian_button = self._grid[7][3],
										mixolydian_button = self._grid[7][4],
										aeolian_button = self._grid[7][5],
										locrian_button = self._grid[7][6],
										major_button = self._grid[7][7])
		self._scale_mode.selected_mode = 'ionian'
		self._scale_mode.set_enabled(False)
		self._on_scale_change.subject = self._scale_mode

		self._octave_offset_component = ScrollingChannelizedSettingsComponent(name = 'NoteOffset', parent_task_group = self._task_group, value_dict = range(104), default_value_index = 36, default_channel = 0, bank_increment = 12, bank_on_color = 'MonoInstrument.OffsetOnValue', bank_off_color = 'MonoInstrument.OffsetOffValue')
		self._octave_offset_component.layer = Layer(priority = 5, bank_up_button = self._menu[2], bank_down_button = self._menu[5])
		self._on_octave_change.subject = self._octave_offset_component

		self._keygroup = OhmKeyGroupComponent()
		self._keygroup._on_selected_track_changed.subject = None
		self._keygroup.translation_channel = PAGE1_KEYS_CHANNEL
		self._keygroup.layer = Layer(priority = 6, matrix = self._matrix.submatrix[:, 4:7])
		self._keygroup.set_enabled(False)
	

	def _setup_bassgroup(self):
		self._bassgroup = OhmBassGroupComponent()
		self._bassgroup._on_selected_track_changed.subject = None
		self._bassgroup.translation_channel = PAGE1_BASS_CHANNEL
		self._bassgroup.layer = Layer(priority = 6, matrix = self._matrix.submatrix[4:, :4])
		self._bassgroup.set_enabled(False)
	

	def _setup_mod(self):
		self.monomodular = get_monomodular(self)
		self.monomodular.name = 'monomodular_switcher'
		self.modhandler = OhmModHandler(self)
		self.modhandler.name = 'ModHandler' 
		self.modhandler.layer = Layer(priority = 5, 
									grid = self._matrix.submatrix[:,:],
									nav_up_button = self._menu[2],
									nav_down_button = self._menu[5],
									nav_left_button = self._menu[3],
									nav_right_button =  self._menu[4],
									shift_button = self._menu[1],
									alt_button = self._menu[0],
									parameter_controls = self._dial_matrix)
		self.modhandler.legacy_shift_mode = AddLayerMode(self.modhandler, Layer(priority = 6,
									channel_buttons = self._matrix.submatrix[:, 1],
									nav_matrix = self._matrix.submatrix[4:8, 2:6]))
		self.modhandler.shift_mode = AddLayerMode(self.modhandler, Layer(priority = 6, 
									device_selector_matrix = self._matrix.submatrix[:, 0],
									lock_button = self._livid,
									key_buttons = self._matrix.submatrix[:, 7]))
									
		self.modhandler.set_enabled(False)
		self.modhandler.set_mod_button(self._livid)
	

	def _setup_modswitcher(self):
		self._modswitcher = ModesComponent(name = 'ModSwitcher')
		self._modswitcher.add_mode('mod', [self.modhandler, DelayMode(self.modhandler.update, delay = .5)])
		self._modswitcher.add_mode('translations', [self._translations])
		self._modswitcher.selected_mode = 'translations'
		self._modswitcher.set_enabled(False)
	

	def _setup_modes(self):

		self._main_modes = ModesComponent(name = 'MainModes')
		self._main_modes.add_mode('disabled', [self._background])
		self._main_modes.add_mode('Mix', [self._session_modes, 
											self._mixer,
											self._mixer.mix_layer,
											self._transport])

		self._main_modes.add_mode('DJ', [self._session_modes,
											self._mixer,
											self._mixer.dj_layer,
											self._dj_translation,
											tuple([self._assign_tempo, self._deassign_tempo])],
											behaviour = DefaultedBehaviour(default_mode = 'Mix'))
											#tuple([ lambda:self._set_tempo_buttons([self._grid[7][5], self._grid[7][6]]), self._set_tempo_buttons([])])],

		self._main_modes.add_mode('Instrument', [self._update_keygroup_colors,
											self._bassgroup,
											self._keygroup,
											self._scale_mode,
											self._octave_offset_component,
											self._device,
											self._device_navigator,
											self._mixer,
											self._mixer.instrument_layer,
											self._drumgroup],
											behaviour = DefaultedBehaviour(default_mode = 'Mix'))

		self._main_modes.add_mode('Mod', [self._modswitcher,
											self._device,
											self._mixer,
											self._mixer.instrument_layer], 
											behaviour = DefaultedBehaviour(default_mode = 'Mix'))
		self._main_modes.layer = Layer(priority = 5, Instrument_button = self._shift_l, DJ_button = self._shift_r, Mod_button = self._livid)
		self._main_modes.selected_mode = 'disabled'
		self._main_modes.set_enabled(True)
	

	def disconnect(self):
		super(OhmModes, self).disconnect()
	

	def strobe(self):
		if self._backlight_type != 'static':
			if self._backlight_type is 'pulse':
				self._backlight = int(math.fabs(self._timer * 16 % 64 - 32) + 32)
			if self._backlight_type is 'up':
				self._backlight = int(self._timer * 8 % 64 + 16)
			if self._backlight_type is 'down':
				self._backlight = int(math.fabs(int(self._timer * 8 % 64 - 64)) + 16)
		self._send_midi(tuple([176, 27, int(self._backlight)]))
		if self._ohm_type != 'static':
			if self._ohm_type is 'pulse':
				self._ohm = int(math.fabs(self._timer * 16 % 64 - 32) + 32)
			if self._ohm_type is 'up':
				self._ohm = int(self._timer * 8 % 64 + 16)
			if self._ohm_type is 'down':
				self._ohm = int(math.fabs(int(self._timer * 8 % 64 - 64)) + 16)
		self._send_midi(tuple([176, 63, int(self._ohm)]))
		self._send_midi(tuple([176, 31, int(self._ohm)]))
	

	def handle_sysex(self, midi_bytes):
		debug('sysex: ', str(midi_bytes))
		if len(midi_bytes) > 14:
			if midi_bytes[:6] == tuple([240, 0, 1, 97, 12, 64]):
				self._register_pad_pressed(midi_bytes[6:14])
			elif midi_bytes[:6] == tuple([240, 0, 1, 97, 17, 64]):
				self._register_pad_pressed(midi_bytes[6:14])
			elif midi_bytes[3:11] == tuple([6, 2, 0, 1, 97, 1, 0]  + [self._sysex_id]) or midi_bytes[3:11] == tuple([6, 2, 0, 1, 97, 1, 0]  + [self._alt_sysex_id]):
				if not self._connected:
					#self._connection_routine.kill()
					self._connected = True
					self._livid_settings.set_model(midi_bytes[11])
					self._initialize_hardware()
					self.schedule_message(1, self._initialize_script)
	

	@listens('device')
	def _on_device_changed(self):  
		self.schedule_message(1, self._update_modswitcher)
		#debug('base on_device_changed')
		self._update_modswitcher()
	

	def _on_selected_track_changed(self):
		super(OhmModes, self)._on_selected_track_changed()
		if not len(self.song.view.selected_track.devices):
			self._update_modswitcher()
	

	def _update_modswitcher(self):
		debug('update modswitcher, mod is:', self.modhandler.active_mod())
		if self.modhandler.active_mod():
			self._modswitcher.selected_mode = 'mod'
		else:
			self._modswitcher.selected_mode = 'translations'
	

	@listens('selected_mode')
	def _on_scale_change(self, mode):
		debug('new scale is:', mode, self._scale_mode.selected_mode)
		self._keygroup.scale = SCALES.index(self._scale_mode.selected_mode)
	

	@listens('value')
	def _on_octave_change(self, value):
		self._keygroup.offset = value
	

	#stupid hack....4 hours wasted on two buttons is too long, so we're doing this instead
	def _update_keygroup_colors(self):
		self._grid[5][7].send_value(2, force = True)
		self._grid[6][7].send_value(2, force = True)
	

	#everything below needs to be consolidated into transport component
	def _assign_tempo(self):
		self._grid[5][7].send_value(4, True)
		self._grid[6][7].send_value(4, True)
		self._tempo_up_value.subject = self._grid[5][7]
		self._tempo_down_value.subject = self._grid[6][7]
	

	def _deassign_tempo(self):
		self._tempo_up_value.subject and self._tempo_up_value.subject.turn_off()
		self._tempo_down_value.subject and self._tempo_down_value.subject.turn_off()
		self._tempo_up_value.subject = None
		self._tempo_down_value.subject = None
	

	@listens('value')
	def _tempo_up_value(self, value):
		if value:
			self.song.tempo = round(min(self.song.tempo + 1, 999))
	

	@listens('value')
	def _tempo_down_value(self, value):
		if value:
			self.song.tempo = round(max(self.song.tempo - 1, 20))
class GuitarWing(LividControlSurface):


	_sysex_id = 20
	_model_name = 'GuitarWing'
	
	def __init__(self, *a, **k):
		super(GuitarWing, self).__init__(*a, **k)
		self._skin = Skin(GuitarWingColors)
		with self.component_guard():
			self._setup_controls()
			self._setup_m4l_interface()
			self._setup_session_control()
			self._setup_mixer_control()
			self._setup_device_control()
			self._setup_transport_control()
			self._setup_view_control()
	

	def _setup_controls(self):
		is_momentary = True
		optimized = True
		resource = PrioritizedResource
		self._button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = BUTTONS[index], name = 'Button_' + str(index), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(10)]
		self._fader = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = SLIDERS[index], name = 'Fader_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(3)]
		self._fader_button = [MonoEncoderElement(msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = SLIDERS[index], name = 'Fader_Button_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(3)]
		self._ccs = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CCS[index], name = 'CCs_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(4)]
		self._pad =  [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = PADS[index], name = 'Pad_' + str(index), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(5)]
		self._padCC = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = PADS[index], name = 'PadCC_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(5)]
		self._accel = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = ACCELS[index], name = 'Accel_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(3)]

		self._parameter_control_matrix = ButtonMatrixElement(rows = [ [ self._fader[0], self._fader[1], self._fader[2], self._accel[2], self._ccs[0], self._ccs[1], self._ccs[2], self._ccs[3] ]])
		self._scene_launch_matrix = ButtonMatrixElement(rows = [self._pad[:4]])
	

	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 1, num_scenes = 4, tracks_to_use = lambda : self.song.visible_tracks + self.song.return_tracks)
		self._session_ring.set_enabled(False)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(scene_launch_buttons = self._scene_launch_matrix)

		self._session_navigation =SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'

		self._session_navigation.layer = Layer(left_button = self._button[1], right_button = self._button[0])
		self._session_navigation.set_enabled(True)
	

	def _setup_mixer_control(self):
		self._mixer = MonoMixerComponent(name = 'Mixer', tracks_provider = self._session_ring, track_assigner = simple_track_assigner, invert_mute_feedback = True, auto_name = True, enable_skinning = True)
		self.song.view.selected_track = self._mixer.channel_strip(0)._track 
	

	def _setup_transport_control(self):
		self._transport = TransportComponent()
		self._transport.layer = Layer(play_button = self._button[6],
										loop_button = self._button[7],
										seek_backward_button = self._button[8],
										record_button = self._button[9])
		self._transport.set_enabled(True)
	

	def _setup_device_control(self):
		self._device = DeviceComponent(name = 'Device_Component', device_provider = self._device_provider, device_bank_registry = DeviceBankRegistry())
		self._device.layer = Layer(parameter_controls = self._parameter_control_matrix)
		self._device.set_enabled(True)
	

	def _setup_m4l_interface(self):
		self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard)
		self.get_control_names = self._m4l_interface.get_control_names
		self.get_control = self._m4l_interface.get_control
		self.grab_control = self._m4l_interface.grab_control
		self.release_control = self._m4l_interface.release_control
	

	def _setup_view_control(self):
		self._view_control = ViewControlComponent()
		self._view_control.layer = Layer(prev_track_button = self._button[1], next_track_button = self._button[0])
	

#	a
Пример #18
0
class OhmModesRay(OhmModes):

    _sysex_id = 2
    _alt_sysex_id = 7
    _model_name = 'Ohm'
    _version_check = 'b996'
    _host_name = 'Ohm'
    device_provider_class = ModDeviceProvider

    def __init__(self, c_instance):
        super(OhmModes, self).__init__(c_instance)
        self._skin = Skin(OhmColors)
        with self.component_guard():
            self._define_sysex()
            self._setup_controls()
            self._setup_background()
            self._setup_m4l_interface()
            #self._setup_translations()
            self._setup_session_control()
            self._setup_mixer_control()
            #self._setup_device_control()
            #self._setup_transport_control()
            #self._setup_drumgroup()
            #self._setup_keygroup()
            #self._setup_bassgroup()
            #self._setup_mod()
            #self._setup_modswitcher()
            self._setup_modes()
        #self._on_device_changed.subject = self._device_provider

    def _setup_session_control(self):
        self._session_ring = SessionRingComponent(num_tracks=7, num_scenes=7)
        self._session_ring.set_enabled(True)

        self._session_navigation = SessionNavigationComponent(
            session_ring=self._session_ring)
        self._session_navigation.scroll_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  up_button=self._menu[1],
                  down_button=self._menu[4],
                  left_button=self._menu[3],
                  right_button=self._menu[5]))
        self._session_navigation.page_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  page_up_button=self._menu[2],
                  page_down_button=self._menu[5],
                  page_left_button=self._menu[3],
                  page_right_button=self._menu[4]))
        self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation.set_enabled(False)

        self._session = SpecialOhmSessionComponent(
            name='Session', session_ring=self._session_ring, auto_name=True)
        self._session.set_enabled(False)
        self._session.clip_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  clip_launch_buttons=self._matrix.submatrix[:7, :7]))
        self._session.scene_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  scene_launch_buttons=self._matrix.submatrix[7, :7]))
        self._session.stop_clips_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  stop_track_clip_buttons=self._matrix.submatrix[:7, 7],
                  stop_all_clips_button=self._grid[7][7]))
        """self._session_zoom = SessionOverviewComponent(name = 'Session_Overview', session_ring = self._session_ring, enable_skinning = True)
		self._session_zoom.layer = Layer(priority = 5, button_matrix = self._matrix.submatrix[:7,:7])
		self._session_zoom.set_enabled(False)

		self._session_modes = ModesComponent(name = 'Session_Modes')
		self._session_modes.add_mode('disabled', [self._session, 
														self._session.clip_launch_layer, 
														self._session.scene_launch_layer, 
														self._session_navigation, 
														self._session_navigation.scroll_navigation_layer])
		self._session_modes.add_mode('enabled', [self._session, 
														self._session.scene_launch_layer, 
														self._session_zoom, 
														self._session_navigation, 
														self._session_navigation.page_navigation_layer],  
														behaviour = DefaultedBehaviour())
		self._session_modes.layer = Layer(priority = 5, enabled_button = self._grid[7][7])
		self._session_modes.selected_mode = 'disabled'
		self._session_modes.set_enabled(False)"""

    def _setup_mixer_control(self):
        self._mixer = OhmMixerComponent(name='Mixer',
                                        tracks_provider=self._session_ring,
                                        track_assigner=simple_track_assigner,
                                        invert_mute_feedback=True,
                                        auto_name=True,
                                        enable_skinning=True)
        #self._mixer.layer = Layer(priority = 5, volume_controls = self._fader_matrix.submatrix[:7, :], prehear_volume_control = self._dial[15], crossfader_control = self._crossfader)
        self._mixer.layer = Layer(
            priority=5, solo_buttons=self._button_matrix.submatrix[:7, :])
        """self._mixer.master_strip().layer = Layer(priority = 5, volume_control = self._fader[7], select_button = self._button[7])
		self._mixer.mix_layer = AddLayerMode(self._mixer, Layer(priority = 5, mute_buttons = self._matrix.submatrix[:7,5], 
													solo_buttons = self._matrix.submatrix[:7,6], 
													arm_buttons = self._matrix.submatrix[:7,7], 
													send_controls = self._dial_matrix.submatrix[:,:2],
													pan_controls = self._dial_matrix.submatrix[:7,2:],
													track_select_buttons = self._button_matrix.submatrix[:7,:],))
		self._mixer.dj_layer = AddLayerMode(self._mixer, Layer(priority = 5, mute_buttons = self._matrix.submatrix[:7,5],
													crossfade_toggles = self._matrix.submatrix[:7,6],
													end_pan_controls = self._dial_matrix.submatrix[:3,3],
													eq_gain_controls = self._dial_matrix.submatrix[:,:3],
													track_select_buttons = self._button_matrix.submatrix[:7,:],))
		self._mixer.instrument_layer = AddLayerMode(self._mixer, Layer(priority = 5, 
													instrument_send_controls = self._dial_matrix.submatrix[:,2:],
													arming_track_select_buttons = self._button_matrix.submatrix[:7,:]))
		"""

    def _setup_modes(self):

        self._main_modes = ModesComponent(name='MainModes')
        self._main_modes.add_mode('disabled', [self._background])
        self._main_modes.add_mode('Mix', [
            self._mixer, self._session, self._session.stop_clips_layer,
            self._session.clip_launch_layer, self._session.scene_launch_layer,
            self._session_navigation,
            self._session_navigation.scroll_navigation_layer
        ])

        self._main_modes.selected_mode = 'disabled'
        self._main_modes.set_enabled(True)
Пример #19
0
class Codec(LividControlSurface):


	_sysex_id = 4
	_model_name = 'Code'
	_host_name = 'Codec'
	_version_check = 'b996'
	monomodular = None

	def __init__(self, c_instance, *a, **k):
		self.log_message = logger.warning
		super(Codec, self).__init__(c_instance, *a, **k)
		self._locked = False
		self._shift_button = None
		self._device_selection_follows_track_selection=FOLLOW
		self._leds_last = 0
		self._shift_latching = LatchingShiftedBehaviour if SHIFT_LATCHING else ShiftedBehaviour
		self._skin = Skin(CodecColors)
		with self.component_guard():
			self._define_sysex()
			self._setup_controls()
			self._setup_background()
			self._setup_mixer_controls()
			self._setup_device_navigator()
			self._setup_device_controls()
			self._setup_special_device_control() 
			self._setup_device_chooser()
			self._setup_device_selector()
			self._setup_send_reset()
			self._setup_default_buttons()
			self._setup_shift_modes()
			self._setup_mod()
			self._setup_modswitcher()
			self._setup_modes() 
			self._setup_m4l_interface()
		self._background.set_enabled(True)
	

	def _initialize_hardware(self):
		super(Codec, self)._initialize_hardware()
	

	def _initialize_script(self):
		super(Codec, self)._initialize_script()
		self._on_device_changed.subject = self._device_provider
		self._main_modes.set_enabled(True)
		self._main_modes.selected_mode = 'mix'
	

	def _define_sysex(self):
		self.fast_encoder_sysex = SendLividSysexMode(livid_settings = self._livid_settings, call = 'set_encoder_speed', message = FAST_ENCODER_MSG)
		self.normal_encoder_sysex = SendLividSysexMode(livid_settings = self._livid_settings, call = 'set_encoder_speed', message = NORMAL_ENCODER_MSG)
		self.slow_encoder_sysex = SendLividSysexMode(livid_settings = self._livid_settings, call = 'set_encoder_speed', message = SLOW_ENCODER_MSG)
	

	def _setup_controls(self):
		is_momentary = True
		optimized = False
		resource = PrioritizedResource
		self._livid = DoublePressElement(MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = LIVID, name = 'Livid_Button', script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge))
		self._dial = [[CodecEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CODE_DIALS[row][column], name = 'Dial_' + str(column) + '_' +	str(row), num = (column + (row*8)), script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge)	for row in range(4)] for column in range(8)]
		self._button = [[MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CODE_BUTTONS[row][column], name = 'Button_' + str(column) + '_' + str(row), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for row in range(4)] for column in range(8)]
		self._column_button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CODE_COLUMN_BUTTONS[index], name = 'Column_Button_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(8)]		
		self._row_button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CODE_ROW_BUTTONS[index], name = 'Row_Button_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(4)]	
		self._code_keys = ButtonMatrixElement(name = 'Code_Keys', rows = [self._column_button])
		self._code_buttons = ButtonMatrixElement(name = 'Code_Buttons', rows = [self._row_button])
		self._encoder_matrix = ButtonMatrixElement(name = 'Encoder_Matrix', rows = [[self._dial[column][row] for column in range(8)] for row in range(4)])
		self._button_matrix = ButtonMatrixElement(name = 'Button_Matrix', rows = [[self._button[column][row] for column in range(8)] for row in range(4)])
	

	def _setup_background(self):
		self._background = BackgroundComponent()
		self._background.layer = Layer(priority = 3, matrix = self._button_matrix, encoders = self._encoder_matrix, livid = self._livid, buttons = self._code_buttons, keys = self._code_keys)
		self._background.set_enabled(False)
	

	def _setup_transport_control(self):
		self._transport = TransportComponent() 
		self._transport.name = 'Transport'
		self._transport.set_enabled(False)
	

	def _setup_mixer_controls(self):
		self._session_ring = SessionRingComponent(name = 'Session_Ring', num_tracks = 8, num_scenes = 0)
		self._session_navigation = SessionNavigationComponent(name = 'Session_Navigation', session_ring = self._session_ring)
		self._session_navigation.layer = Layer(priority = 4, left_button = self._button[6][0], right_button = self._button[7][0])
		self._session_navigation.set_enabled(False)
		#self._session = SessionComponent(name = 'Session', session_ring = self._session_ring)
		self._mixer = CodecMixerComponent(num_returns = 4, name = 'Mixer', tracks_provider = self._session_ring, invert_mute_feedback = True, auto_name = True)
		self._mixer._mix_layer = AddLayerMode(self._mixer, Layer(priority = 4, volume_controls = self._encoder_matrix.submatrix[:8,3],
									pan_controls = self._encoder_matrix.submatrix[:8,2],
									send_controls = self._encoder_matrix.submatrix[:8, :2],
									))
		self._mixer._solo_mute_layer = AddLayerMode(self._mixer, Layer(priority = 4, solo_buttons = self._button_matrix.submatrix[:8,2],
									mute_buttons = self._button_matrix.submatrix[:8,3],
									))
		self._mixer._select_layer = AddLayerMode(self._mixer, Layer(priority = 4, track_select_buttons = self._code_keys))
		self._mixer._sends_layer = AddLayerMode(self._mixer, Layer(priority = 4, send_controls = self._encoder_matrix.submatrix[:, :]))
		self._mixer.set_enabled(False)
	

	def _setup_device_navigator(self):
		self._device_navigator = DeviceNavigator(self._device_provider, self._mixer, self)
		self._device_navigator._dev1_layer = AddLayerMode(self._device_navigator, Layer(priority = 4, prev_button = self._button[4][0], next_button = self._button[5][0], prev_chain_button = self._button[6][0], next_chain_button = self._button[7][0]))
		self._device_navigator._dev2_layer = AddLayerMode(self._device_navigator, Layer(priority = 4, prev_button = self._button[4][1], next_button = self._button[5][1], prev_chain_button = self._button[6][1], next_chain_button = self._button[7][1]))
		self._device_navigator._dev3_layer = AddLayerMode(self._device_navigator, Layer(priority = 4, prev_button = self._button[4][2], next_button = self._button[5][2], prev_chain_button = self._button[6][2], next_chain_button = self._button[7][2]))
		self._device_navigator._dev4_layer = AddLayerMode(self._device_navigator, Layer(priority = 4, prev_button = self._button[4][3], next_button = self._button[5][3], prev_chain_button = self._button[6][3], next_chain_button = self._button[7][3]))
		self._device_navigator.set_enabled(False)
	

	def _setup_device_controls(self):
		self._device = [None for index in range(4)]
		for index in range(4):
			self._device[index] = CodecDeviceComponent(self, index+1, device_bank_registry = DeviceBankRegistry())
			self._device[index].name = 'CodecDevice_Component_' + str(index+1)
			self._device[index].layer = Layer(priority = 4, parameter_controls = self._encoder_matrix.submatrix[:, index],
												on_off_button = self._button[1][index],
												bank_prev_button = self._button[2][index],
												bank_next_button = self._button[3][index],
												)
			self._device[index]._nav_layer = AddLayerMode(self._device[index], Layer(priority = 4, nav_prev_button = self._button[6][index],
																					nav_next_button = self._button[7][index],))
			self._device[index].set_enabled(False)
	

	def _setup_special_device_control(self):
		self._special_device = SpecialCodecDeviceComponent(self, device_bank_registry = DeviceBankRegistry(), device_provider = self._device_provider)
		self._special_device.name = 'SpecialCodecDeviceComponent'
		self._is_active_device = True
		self._special_device.layer = Layer(priority = 4, parameter_controls = self._encoder_matrix.submatrix[:,:],
											on_off_button = self._button[1][0],
											bank_prev_button = self._button[4][0],
											bank_next_button = self._button[5][0],
											)
		self._special_device.set_enabled(False)
	

	def _setup_device_chooser(self):
		self._selected_device = self._device[0]
		self._last_selected_device = self._device[0]

		self._selected_device_modes = ModesComponent()
		self._selected_device_modes.add_mode('disabled', [None])
		self._selected_device_modes.add_mode('device_0', [self._device_navigator._dev1_layer], behaviour = DefaultedBehaviour())
		self._selected_device_modes.add_mode('device_1', [self._device_navigator._dev2_layer], behaviour = DefaultedBehaviour())
		self._selected_device_modes.add_mode('device_2', [self._device_navigator._dev3_layer], behaviour = DefaultedBehaviour())
		self._selected_device_modes.add_mode('device_3', [self._device_navigator._dev4_layer], behaviour = DefaultedBehaviour())
		self._selected_device_modes.layer = Layer(priority = 4, device_0_button = self._button[0][0], device_1_button = self._button[0][1], device_2_button = self._button[0][2], device_3_button = self._button[0][3])
		self._selected_device_modes.selected_mode = 'device_0'
		self._selected_device_modes.set_enabled(False)
		self._on_device_selector_mode_changed.subject = self._selected_device_modes
	

	def _setup_device_selector(self):
		self._device_selector = DeviceSelectorComponent(self)
		self._device_selector.name = 'Device_Selector'
		self._device_selector.layer = Layer(priority = 4, matrix = self._code_keys)
		self._device_selector.set_enabled(False)
	

	def _setup_send_reset(self):
		self._send_reset = CodecResetSendsComponent(self)
		self._send_reset.set_enabled(False)
		#self._send_reset.set_buttons(self._button)
	

	def _setup_default_buttons(self):
		self._value_default = ParameterDefaultComponent(script = self, dials = self._dial)
		self._value_default.layer = Layer(priority = 3, matrix = self._button_matrix)
		self._value_default.set_enabled(False)
	

	def _setup_shift_modes(self):
		self._main_shift_modes = ModesComponent(name = 'MainShiftModes')
		self._main_shift_modes.add_mode('disabled', [self.normal_encoder_sysex], cycle_mode_button_color = 'DefaultButton.Off')
		self._main_shift_modes.add_mode('enabled', [self.slow_encoder_sysex], cycle_mode_button_color = 'DefaultButton.On')  #, self._value_default
		self._main_shift_modes.layer = Layer(priority = 4, cycle_mode_button = self._livid)
		self._main_shift_modes.set_enabled(False)
		self._main_shift_modes.selected_mode = 'disabled'

		self._mod_shift_modes = ModesComponent(name = 'ModShiftModes')
		self._mod_shift_modes.layer = Layer(priority = 4, cycle_mode_button = self._livid)
		self._mod_shift_modes.set_enabled(False)
	

	def _setup_mod(self):
		self.monomodular = get_monomodular(self)
		self.monomodular.name = 'monomodular_switcher'
		self.modhandler = CodecModHandler(script = self, device_provider = self._device_provider)
		self.modhandler.name = 'ModHandler'
		self.modhandler.layer = Layer(priority = 4, code_grid = self._button_matrix.submatrix[:,:], code_encoder_grid = self._encoder_matrix.submatrix[:,:])
		self.modhandler.set_enabled(False)
		self.modhandler.code_buttons_layer = AddLayerMode(self.modhandler, Layer(priority = 5, code_buttons = self._code_buttons))
		self.modhandler.keys_layer = AddLayerMode(self.modhandler, Layer(priority = 5, key_buttons = self._code_keys))
		self.modhandler.code_keys_layer = AddLayerMode(self.modhandler, Layer(priority = 5, code_keys = self._code_buttons))
		self.modhandler.alt_layer = AddLayerMode(self.modhandler, Layer(priority = 4, lock_button = self._livid))
	

	def _setup_modswitcher(self):
		self._modswitcher = ModesComponent(name = 'ModSwitcher')
		self._modswitcher.add_mode('mod', [self.modhandler, self._mod_shift_modes])
		self._modswitcher.add_mode('special_device', [self._special_device, self._mixer, self._mixer._select_layer, self._main_shift_modes])
		self._modswitcher.selected_mode = 'special_device'
		self._modswitcher.set_enabled(False)

		self._mod_shift_modes.add_mode('disabled', [self.modhandler.keys_layer], cycle_mode_button_color = 'Mod.ShiftOff')
		self._mod_shift_modes.add_mode('enabled', [self.modhandler.code_keys_layer, self.modhandler.code_buttons_layer, tuple([self._send_mod_shift, self._release_mod_shift])], cycle_mode_button_color = 'Mod.ShiftOn')
		self._mod_shift_modes.selected_mode = 'disabled'
	

	def _setup_modes(self):
		self._main_modes = ModesComponent(name = 'MainModes')
		self._main_modes.add_mode('disabled', [])
		self._main_modes.add_mode('mix_shifted', [self._mixer, self._mixer._mix_layer, self._mixer._solo_mute_layer, self._device_selector, self._background], groups = ['shifted'], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('mix', [self._mixer, self._mixer._mix_layer, self._mixer._select_layer, self._mixer._solo_mute_layer, self._session_navigation, self._background, self._main_shift_modes], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('sends_shifted', [self._mixer, self._mixer._sends_layer, self._mixer._select_layer, self._device_selector, self._background], groups = ['shifted'], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('sends', [self._mixer, self._mixer._sends_layer, self._mixer._select_layer, self._background, self._main_shift_modes], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('device_shifted', [self._selected_device_modes, self._device_selector, self._device[0], self._device[1], self._device[2], self._device[3], self._device_selector, self._background], groups = ['shifted'], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('device', [self._mixer, self._mixer._select_layer, self._selected_device_modes, self._device[0], self._device[1], self._device[2], self._device[3], self._background, self._mixer._select_layer, self._main_shift_modes], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('special_device_shifted', [self._modswitcher, self._device_selector, self._background], groups = ['shifted'], behaviour = self._shift_latching(color = 'Mode.Main'))
		self._main_modes.add_mode('special_device', [self._modswitcher, self._background], behaviour = self._shift_latching(color = 'Mode.Main'))
		#self._main_modes.add_mode('select', [self.normal_encoder_sysex], behaviour = DelayedExcludingMomentaryBehaviour(excluded_groups = ['shifted']))
		self._main_modes.layer = Layer(priority = 4,
										mix_button = self._row_button[0],
										sends_button = self._row_button[1],
										device_button = self._row_button[2],
										special_device_button = self._row_button[3],
										)
		self._main_modes.selected_mode = 'disabled'
		self._main_modes.set_enabled(False)
	

	def _setup_m4l_interface(self):
		self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard)
		self.get_control_names = self._m4l_interface.get_control_names
		self.get_control = self._m4l_interface.get_control
		self.grab_control = self._m4l_interface.grab_control
		self.release_control = self._m4l_interface.release_control
	

	@listens('selected_mode')
	def _on_device_selector_mode_changed(self, mode):
		if mode == 'disabled':
			for device in self._device:
				device.set_dynamic_device_provider(None)
		elif mode in DEVICE_COMPONENTS:
			active_device = self._device[DEVICE_COMPONENTS.index(self._selected_device_modes.selected_mode)]
			for device in self._device:
				if device is active_device:
					device.set_dynamic_device_provider(self._device_provider)
				else:
					device.set_dynamic_device_provider(None)
			if active_device.find_track(active_device._get_device()) == self.song.view.selected_track:
				active_device.display_device()
	

	@listens('device')
	def _on_device_changed(self):
		self._on_device_name_changed.subject = self._device_provider.device
		self.schedule_message(1, self._update_modswitcher)
	

	@listens('name')
	def _on_device_name_changed(self):
		for device in self._device:
			device.scan_all()
	

	def _on_selected_track_changed(self):
		super(Codec, self)._on_selected_track_changed()
		#self.schedule_message(1, self._update_modswitcher)
		if not len(self.song.view.selected_track.devices):
			self._update_modswitcher()
	

	def _update_modswitcher(self):
		debug('update modswitcher', self.modhandler.active_mod())
		if self.modhandler.active_mod():
			self._modswitcher.selected_mode = 'mod'
		else:
			self._modswitcher.selected_mode = 'special_device'
	

	"""general functionality"""
	def disconnect(self):
		self.log_message('<<<<<<<<<<<<<<<<<<<<<<<<< Codec log closed >>>>>>>>>>>>>>>>>>>>>>>>>')
		super(Codec, self).disconnect()
	

	def update_display(self):
		super(Codec, self).update_display()
		self.modhandler.send_ring_leds()
	

	def restart_monomodular(self):
		#self.log_message('restart monomodular')
		self.modhandler.disconnect()
		with self.component_guard():
			self._setup_mod()
	

	def _send_mod_shift(self):
		self.modhandler._shift_value(1)
	

	def _release_mod_shift(self):
		self.modhandler._shift_value(0)
Пример #20
0
class ATOM(ControlSurface):
    def __init__(self, *a, **k):
        super(ATOM, self).__init__(*a, **k)
        with self.component_guard():
            with inject(skin=const(skin)).everywhere():
                self._elements = Elements()
        with self.component_guard():
            with inject(element_container=const(self._elements)).everywhere():
                self._create_lighting()
                self._create_transport()
                self._create_record_modes()
                self._create_undo()
                self._create_view_toggle()
                self._create_background()
                self._create_session()
                self._create_mixer()
                self._create_encoder_modes()
                self._create_session_navigation_modes()
                self._create_keyboard()
                self._create_drum_group()
                self._create_note_modes()
                self._create_pad_modes()
                self._create_user_assignments_mode()
                self._target_track = ArmedTargetTrackComponent(
                    name=u'Target_Track')
                self.__on_target_track_changed.subject = self._target_track
        self._drum_group_finder = self.register_disconnectable(
            PercussionInstrumentFinder(
                device_parent=self._target_track.target_track))
        self.__on_drum_group_changed.subject = self._drum_group_finder
        self.__on_drum_group_changed()
        self.__on_main_view_changed.subject = self.application.view

    def disconnect(self):
        self._send_midi(midi.NATIVE_MODE_OFF_MESSAGE)
        super(ATOM, self).disconnect()

    def port_settings_changed(self):
        self._send_midi(midi.NATIVE_MODE_ON_MESSAGE)
        super(ATOM, self).port_settings_changed()

    def _create_lighting(self):
        self._lighting = LightingComponent(name=u'Lighting',
                                           is_enabled=False,
                                           layer=Layer(
                                               shift_button=u'shift_button',
                                               zoom_button=u'zoom_button'))
        self._lighting.set_enabled(True)

    def _create_transport(self):
        self._transport = TransportComponent(
            name=u'Transport',
            is_enabled=False,
            layer=Layer(play_button=u'play_button',
                        loop_button=u'play_button_with_shift',
                        stop_button=u'stop_button',
                        metronome_button=u'click_button'))
        self._transport.set_enabled(True)

    def _create_record_modes(self):
        self._session_record = SessionRecordingComponent(
            name=u'Session_Record',
            is_enabled=False,
            layer=Layer(record_button=u'record_button'))
        self._record_modes = ModesComponent(name=u'Record_Modes')
        self._record_modes.add_mode(u'session', self._session_record)
        self._record_modes.add_mode(
            u'arrange',
            AddLayerMode(self._transport,
                         layer=Layer(record_button=u'record_button')))
        self.__on_main_view_changed()

    def _create_undo(self):
        self._undo = UndoRedoComponent(
            name=u'Undo',
            is_enabled=False,
            layer=Layer(undo_button=u'stop_button_with_shift'))
        self._undo.set_enabled(True)

    def _create_view_toggle(self):
        self._view_toggle = ViewToggleComponent(
            name=u'View_Toggle',
            is_enabled=False,
            layer=Layer(detail_view_toggle_button=u'show_hide_button',
                        main_view_toggle_button=u'preset_button'))
        self._view_toggle.set_enabled(True)

    def _create_background(self):
        self._background = BackgroundComponent(
            name=u'Background',
            is_enabled=False,
            add_nop_listeners=True,
            layer=Layer(set_loop_button=u'set_loop_button',
                        nudge_button=u'nudge_button',
                        bank_button=u'bank_button'))
        self._background.set_enabled(True)

    def _create_session(self):
        self._session_ring = SessionRingComponent(name=u'Session_Ring',
                                                  num_tracks=SESSION_WIDTH,
                                                  num_scenes=SESSION_HEIGHT)
        self._session = SessionComponent(name=u'Session',
                                         session_ring=self._session_ring)
        self._session_navigation = SessionNavigationComponent(
            name=u'Session_Navigation',
            is_enabled=False,
            session_ring=self._session_ring,
            layer=Layer(left_button=u'left_button',
                        right_button=u'right_button'))
        self._session_navigation.set_enabled(True)
        self._session_overview = SessionOverviewComponent(
            name=u'Session_Overview',
            is_enabled=False,
            session_ring=self._session_ring,
            enable_skinning=True,
            layer=Layer(button_matrix=u'pads_with_zoom'))

    def _create_mixer(self):
        self._mixer = MixerComponent(
            name=u'Mixer',
            auto_name=True,
            tracks_provider=self._session_ring,
            track_assigner=SimpleTrackAssigner(),
            invert_mute_feedback=True,
            channel_strip_component_type=ChannelStripComponent)

    def _create_encoder_modes(self):
        self._encoder_modes = ModesComponent(name=u'Encoder_Modes',
                                             enable_skinning=True)
        self._encoder_modes.add_mode(
            u'volume',
            AddLayerMode(self._mixer, Layer(volume_controls=u'encoders')))
        self._encoder_modes.add_mode(
            u'pan', AddLayerMode(self._mixer, Layer(pan_controls=u'encoders')))
        self._encoder_modes.add_mode(
            u'send_a',
            AddLayerMode(self._mixer, Layer(send_a_controls=u'encoders')))
        self._encoder_modes.add_mode(
            u'send_b',
            AddLayerMode(self._mixer, Layer(send_b_controls=u'encoders')))
        self._encoder_modes.selected_mode = u'volume'

    def _create_session_navigation_modes(self):
        self._session_navigation_modes = ModesComponent(
            name=u'Session_Navigation_Modes',
            is_enabled=False,
            layer=Layer(cycle_mode_button=u'bank_button'))
        self._session_navigation_modes.add_mode(
            u'default',
            AddLayerMode(self._session_navigation,
                         layer=Layer(up_button=u'up_button',
                                     down_button=u'down_button')),
            cycle_mode_button_color=u'DefaultButton.Off')
        self._session_navigation_modes.add_mode(
            u'paged',
            AddLayerMode(self._session_navigation,
                         layer=Layer(page_up_button=u'up_button',
                                     page_down_button=u'down_button',
                                     page_left_button=u'left_button',
                                     page_right_button=u'right_button')),
            cycle_mode_button_color=u'DefaultButton.On')
        self._session_navigation_modes.selected_mode = u'default'

    def _create_keyboard(self):
        self._keyboard = KeyboardComponent(
            midi.KEYBOARD_CHANNEL,
            name=u'Keyboard',
            is_enabled=False,
            layer=Layer(matrix=u'pads',
                        scroll_up_button=u'up_button',
                        scroll_down_button=u'down_button'))

    def _create_drum_group(self):
        self._drum_group = DrumGroupComponent(
            name=u'Drum_Group',
            is_enabled=False,
            translation_channel=midi.DRUM_CHANNEL,
            layer=Layer(matrix=u'pads',
                        scroll_page_up_button=u'up_button',
                        scroll_page_down_button=u'down_button'))

    def _create_note_modes(self):
        self._note_modes = ModesComponent(name=u'Note_Modes', is_enabled=False)
        self._note_modes.add_mode(u'keyboard', self._keyboard)
        self._note_modes.add_mode(u'drum', self._drum_group)
        self._note_modes.selected_mode = u'keyboard'

    def _create_pad_modes(self):
        self._pad_modes = ModesComponent(
            name=u'Pad_Modes',
            is_enabled=False,
            layer=Layer(session_button=u'full_level_button',
                        note_button=u'note_repeat_button',
                        channel_button=u'select_button',
                        encoder_modes_button=u'setup_button'))
        self._pad_modes.add_mode(
            u'session',
            (AddLayerMode(self._background,
                          Layer(unused_pads=u'pads_with_shift')),
             AddLayerMode(
                 self._session,
                 Layer(clip_launch_buttons=u'pads',
                       scene_launch_buttons=self._elements.pads_with_shift.
                       submatrix[3:, :])), self._session_overview,
             self._session_navigation_modes))
        self._pad_modes.add_mode(u'note', self._note_modes)
        self._pad_modes.add_mode(
            u'channel',
            (self._elements.pads.reset,
             AddLayerMode(
                 self._mixer,
                 Layer(
                     arm_buttons=self._elements.pads.submatrix[:, :1],
                     solo_buttons=self._elements.pads.submatrix[:, 1:2],
                     track_select_buttons=self._elements.pads.submatrix[:,
                                                                        2:3])),
             AddLayerMode(
                 self._session,
                 Layer(stop_track_clip_buttons=self._elements.pads.
                       submatrix[:, 3:])), self._session_navigation_modes))
        self._pad_modes.add_mode(
            u'encoder_modes',
            (LayerMode(
                self._encoder_modes,
                Layer(volume_button=self._elements.pads_raw[0][0],
                      pan_button=self._elements.pads_raw[0][1],
                      send_a_button=self._elements.pads_raw[0][2],
                      send_b_button=self._elements.pads_raw[0][3])),
             AddLayerMode(
                 self._background,
                 Layer(unused_pads=self._elements.pads.submatrix[:, 1:]))),
            behaviour=MomentaryBehaviour())
        self._pad_modes.selected_mode = u'session'
        self._pad_modes.set_enabled(True)

    def _create_user_assignments_mode(self):
        self._translating_background = TranslatingBackgroundComponent(
            midi.USER_CHANNEL,
            name=u'Translating_Background',
            is_enabled=False,
            add_nop_listeners=True,
            layer=Layer(note_repeat_button=u'note_repeat_button',
                        full_level_button=u'full_level_button',
                        bank_button=u'bank_button',
                        preset_button=u'preset_button',
                        show_hide_button=u'show_hide_button',
                        nudge_button=u'nudge_button',
                        set_loop_button=u'set_loop_button',
                        setup_button=u'setup_button',
                        up_button=u'up_button',
                        down_button=u'down_button',
                        left_button=u'left_button',
                        right_button=u'right_button',
                        select_button=u'select_button',
                        click_button=u'click_button',
                        record_button=u'record_button',
                        play_button=u'play_button',
                        stop_button=u'stop_button',
                        pads=u'pads',
                        encoders=u'encoders'))
        self._top_level_modes = ModesComponent(
            name=u'Top_Level_Modes',
            is_enabled=False,
            support_momentary_mode_cycling=False,
            layer=Layer(cycle_mode_button=u'editor_button'))
        self._top_level_modes.add_mode(
            u'default',
            self.refresh_state,
            cycle_mode_button_color=u'DefaultButton.Off')
        self._top_level_modes.add_mode(
            u'user',
            self._translating_background,
            cycle_mode_button_color=u'DefaultButton.On')
        self._top_level_modes.selected_mode = u'default'
        self._top_level_modes.set_enabled(True)

    @listens(u'is_view_visible', u'Session')
    def __on_main_view_changed(self):
        if self.application.view.is_view_visible(u'Session'):
            self._record_modes.selected_mode = u'session'
        else:
            self._record_modes.selected_mode = u'arrange'

    @listens(u'target_track')
    def __on_target_track_changed(self):
        self._drum_group_finder.device_parent = self._target_track.target_track

    @listens(u'instrument')
    def __on_drum_group_changed(self):
        drum_group = self._drum_group_finder.drum_group
        self._drum_group.set_drum_group_device(drum_group)
        self._note_modes.selected_mode = u'drum' if liveobj_valid(
            drum_group) else u'keyboard'
Пример #21
0
class BaseJor(Base):


	def __init__(self, *a, **k):
		super(BaseJor, self).__init__(*a, **k)
	

	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 _setup_translations(self):
		controls = self._pad[:6] + self._pad[8:14] + self._pad[16:22] + self._pad[24:30] + self._fader[:6] + self._pad_CC[:6] + self._pad_CC[8:14] + self._pad_CC[16:22] + self._pad_CC[24:30]
		if CAP_BUTTON_TRANSLATIONS:
			controls = controls + self._touchpad
		self._translations = BaseDisplayingTranslationComponent(controls, USER_OFFSET)
		self._translations.name = 'TranslationComponent'
		self._translations._channel = USER_OFFSET
		self._translations.layer = Layer(priority = 10, channel_selector_buttons = self._nav_buttons, display = self._display)
		self._translations.set_enabled(False)

		controls = [self._pad[6], self._pad[7], self._pad[14], self._pad[15], self._pad[22], self._pad[23], self._pad[30], self._pad[31], self._pad_CC[6], self._pad_CC[7], self._pad_CC[14], self._pad_CC[15], self._pad_CC[22], self._pad_CC[23], self._pad_CC[30], self._pad_CC[31]]
		self._translationsJor = BaseDisplayingTranslationComponent(controls, 15)
		self._translationsJor.name = 'JorTranslationComponent'
		self._translationsJor._channel = 15
		self._translationsJor.set_enabled(False)
	

	def _setup_mixer_control(self):
		self._mixer = MonoMixerComponent(name = 'Mixer', num_returns = 4,tracks_provider = self._session_ring, track_assigner = right_align_return_tracks_track_assigner, invert_mute_feedback = True, auto_name = True, enable_skinning = True)
		self._mixer.master_strip().layer = Layer(priority = 4, volume_control = self._fader[8])
		self._mixer.volume_layer = AddLayerMode(self._mixer, Layer(priority = 4, volume_controls = self._fader_matrix.submatrix[:6, :]))
		self._mixer.select_layer = AddLayerMode(self._mixer, Layer(priority = 4, track_select_buttons = self._touchpad_matrix.submatrix[:6, :]))
		selected_strip = self._mixer.selected_strip()
		selected_strip.set_invert_mute_feedback(True)
		self._mixer.selected_channel_controls_layer = AddLayerMode(selected_strip, Layer(priority = 4, arm_button = self._button[6], solo_button = self._button[5], mute_button = self._button[4], stop_button = self._button[7]))
		self._mixer.selected_sends_layer = AddLayerMode(selected_strip, Layer(priority = 4, send_controls = self._fader_matrix.submatrix[:4, :]))
		self._mixer.returns_layer = AddLayerMode(self._mixer, Layer(priority = 4, return_controls = self._fader_matrix.submatrix[4:6, :]))
		self._mixer.channel_controls_layer = AddLayerMode(self._mixer, Layer(priority = 4, mute_buttons = self._base_grid.submatrix[:6, :1],
																		solo_buttons = self._base_grid.submatrix[:6, 1:2],
																		arm_buttons = self._base_grid.submatrix[:6, 2:3],
																		stop_clip_buttons = self._base_grid.submatrix[:6, 3:4]))
		#self._mixer.navigation_layer = AddLayerMode(self._mixer, Layer(priority = 4, previous_track_button = self._touchpad[6], next_track_button = self._touchpad[7]))
		self._mixer.set_enabled(False)

		self._view_controller = ViewControlComponent()
		self._view_controller.layer = Layer(priority = 4, prev_track_button = self._touchpad[6], next_track_button = self._touchpad[7])
		self._view_controller.set_enabled(False)
	

	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 6, num_scenes = 4, tracks_to_use = tracks_to_use)
		self._session_ring.set_enabled(False)

		self._session_navigation = SessionNavigationComponent(session_ring = self._session_ring)
		self._session_navigation.navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 4, up_button = self._button[4], down_button = self._button[5], left_button = self._button[6], right_button = self._button[7]))
		self._session_navigation.page_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 4, page_up_button = self._button[4], page_down_button = self._button[5], page_left_button = self._button[6], page_right_button = self._button[7]))
		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation.set_enabled(False)

		self._session = BaseSessionComponent(name = 'Session', parent_task_group = self._task_group, session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.cliplaunch_layer = AddLayerMode(self._session, Layer(priority = 4, clip_launch_buttons = self._base_grid.submatrix[:6, :]))
		self._session.overlay_cliplaunch_layer = AddLayerMode(self._session, Layer(priority = 4, clip_launch_buttons = self._base_grid.submatrix[:5, :], scene_launch_buttons = self._base_grid.submatrix[5:6, :]))
		#self._session.clipstop_layer = AddLayerMode(self._session, Layer(priority = 4, stop_track_clip_buttons = self._base_grid.submatrix[:, 3:4]))
		self._session.set_enabled(False)
	

	def _setup_instrument(self):
		self._grid_resolution = GridResolution()

		self._c_instance.playhead.enabled = True
		self._playhead_element = PlayheadElement(self._c_instance.playhead)
		#self._playhead_element.reset()

		quantgrid = ButtonMatrixElement([self._base_grid._orig_buttons[2][4:8], self._base_grid._orig_buttons[3][4:7]])

		self._drum_group_finder = PercussionInstrumentFinder(device_parent=self.song.view.selected_track)

		self._instrument = BaseMonoInstrumentComponent(name = 'InstrumentModes', script = self, skin = self._skin, drum_group_finder = self._drum_group_finder, grid_resolution = self._grid_resolution, settings = DEFAULT_INSTRUMENT_SETTINGS, device_provider = self._device_provider, parent_task_group = self._task_group)
		self._instrument.layer = Layer(priority = 6, base_display = self._display)
		self._instrument.audioloop_layer = LayerMode(self._instrument, Layer(priority = 6, loop_selector_matrix = self._base_grid))

		self._instrument.keypad_options_layer = AddLayerMode(self._instrument, Layer(priority = 6, 
									base_display = self._display,
									scale_up_button = self._touchpad[7], 
									scale_down_button = self._touchpad[6],
									offset_up_button = self._touchpad[5], 
									offset_down_button = self._touchpad[4],
									vertical_offset_up_button = self._touchpad[3],
									vertical_offset_down_button = self._touchpad[2],
									split_button = self._touchpad[0], 
									sequencer_button = self._touchpad[1]))
		self._instrument.drumpad_options_layer = AddLayerMode(self._instrument, Layer(priority = 6, 
									base_display = self._display,
									scale_up_button = self._touchpad[7],
									scale_down_button = self._touchpad[6],
									drum_offset_up_button = self._touchpad[5], 
									drum_offset_down_button = self._touchpad[4],
									drumpad_mute_button = self._touchpad[3],
									drumpad_solo_button = self._touchpad[2],
									split_button = self._touchpad[0], 
									sequencer_button = self._touchpad[1]))

		self._instrument._keypad.octave_toggle_layer = AddLayerMode(self._instrument._keypad, Layer(priority = 7, offset_shift_toggle = self._button[4]))
		self._instrument._drumpad.octave_toggle_layer = AddLayerMode(self._instrument._drumpad, Layer(priority = 7, offset_shift_toggle = self._button[4]))

		self._instrument._keypad.main_layer = LayerMode(self._instrument._keypad, Layer(priority = 6, keypad_matrix = self._base_grid.submatrix[:6,:]))
		self._instrument._keypad.select_layer = LayerMode(self._instrument._keypad, Layer(priority = 6, keypad_select_matrix = self._base_grid.submatrix[:6, :]))
		self._instrument._keypad.split_layer = LayerMode(self._instrument._keypad, Layer(priority = 6, keypad_matrix = self._base_grid.submatrix[:6, 2:4]))
		self._instrument._keypad.split_select_layer = LayerMode(self._instrument._keypad, Layer(priority = 6, keypad_select_matrix = self._base_grid.submatrix[:6, 2:4]))

		self._instrument._keypad.sequencer_layer = AddLayerMode(self._instrument._keypad, Layer(priority = 6, playhead = self._playhead_element, sequencer_matrix = self._base_grid.submatrix[:6, :2]))
		self._instrument._keypad.sequencer_shift_layer = AddLayerMode(self._instrument._keypad, Layer(priority = 6, loop_selector_matrix = self._base_grid.submatrix[:6, :1], quantization_buttons = self._base_grid.submatrix[:7, 1:2], follow_button = self._pad[15]))

		self._instrument._drumpad.main_layer = LayerMode(self._instrument._drumpad, Layer(priority = 6, drumpad_matrix = self._base_grid.submatrix[:6,:]))
		self._instrument._drumpad.select_layer = LayerMode(self._instrument._drumpad, Layer(priority = 6, drumpad_select_matrix = self._base_grid.submatrix[:6,:]))
		self._instrument._drumpad.split_layer = LayerMode(self._instrument._drumpad, Layer(priority = 6, drumpad_matrix = self._base_grid.submatrix[:4, :],))
		self._instrument._drumpad.split_select_layer = LayerMode(self._instrument._drumpad, Layer(priority = 6, drumpad_select_matrix = self._base_grid.submatrix[:4,:]))

		self._instrument._drumpad.sequencer_layer = AddLayerMode(self._instrument._drumpad, Layer(priority = 6, playhead = self._playhead_element, sequencer_matrix = self._base_grid.submatrix[4:6, :]))
		self._instrument._drumpad.sequencer_shift_layer = AddLayerMode(self._instrument._drumpad, Layer(priority = 6, loop_selector_matrix = self._base_grid.submatrix[4:6, :2],)) # quantization_buttons = quantgrid, follow_button = self._pad[31]))

		self._instrument._selected_session._keys_layer = LayerMode(self._instrument._selected_session, Layer(priority = 6, clip_launch_buttons = self._base_grid.submatrix[:6, :2]))
		self._instrument._selected_session._drum_layer = LayerMode(self._instrument._selected_session, Layer(priority = 6, clip_launch_buttons = self._base_grid.submatrix[4:6, :]))

		self._instrument._main_modes = ModesComponent(name = 'InstrumentModes')
		self._instrument._main_modes.add_mode('disabled', [])
		self._instrument._main_modes.add_mode('drumpad', [self._instrument._drumpad, self._instrument._drumpad.main_layer, self.midi_mode_sysex])
		self._instrument._main_modes.add_mode('drumpad_split', [self._instrument._drumpad, self._instrument._drumpad.split_layer, self._instrument._selected_session, self._instrument._selected_session._drum_layer, self.splitvertical_mode_sysex])
		self._instrument._main_modes.add_mode('drumpad_sequencer', [self._instrument._drumpad, self._instrument._drumpad.sequencer_layer, self._instrument._drumpad.split_layer, self.splitvertical_mode_sysex])
		self._instrument._main_modes.add_mode('drumpad_shifted', [self._instrument._drumpad, self._instrument._drumpad.select_layer, self._instrument.drumpad_options_layer, self._instrument._drumpad.octave_toggle_layer, self.midi_mode_sysex])
		self._instrument._main_modes.add_mode('drumpad_split_shifted', [ self._instrument._drumpad, self._instrument._drumpad.split_select_layer, self._instrument.drumpad_options_layer, self._instrument._drumpad.octave_toggle_layer, self._instrument._selected_session, self._instrument._selected_session._drum_layer])
		self._instrument._main_modes.add_mode('drumpad_sequencer_shifted', [self._instrument._drumpad, self._instrument._drumpad.split_select_layer, self._instrument._drumpad.sequencer_shift_layer, self._instrument.drumpad_options_layer, self._instrument._drumpad.octave_toggle_layer, self.splitvertical_mode_sysex])
		self._instrument._main_modes.add_mode('keypad', [self._instrument._keypad, self._instrument._keypad.main_layer, self.midi_mode_sysex])
		self._instrument._main_modes.add_mode('keypad_split', [self._instrument._keypad, self._instrument._keypad.split_layer, self._instrument._selected_session, self._instrument._selected_session._keys_layer, self.splithorizontal_mode_sysex])
		self._instrument._main_modes.add_mode('keypad_sequencer', [self._instrument._keypad, self._instrument._keypad.sequencer_layer, self._instrument._keypad.split_layer, self.splithorizontal_mode_sysex], )
		self._instrument._main_modes.add_mode('keypad_shifted', [self._instrument._keypad, self._instrument._keypad.select_layer, self._instrument.keypad_options_layer, self._instrument._keypad.octave_toggle_layer, self.midi_mode_sysex])
		self._instrument._main_modes.add_mode('keypad_split_shifted', [self._instrument._keypad, self._instrument._keypad.split_select_layer, self._instrument.keypad_options_layer, self._instrument._keypad.octave_toggle_layer, self._instrument._selected_session, self._instrument._selected_session._keys_layer])
		self._instrument._main_modes.add_mode('keypad_sequencer_shifted', [self._instrument._keypad, self._instrument._keypad.split_select_layer, self._instrument._keypad.sequencer_shift_layer, self._instrument.keypad_options_layer, self._instrument._keypad.octave_toggle_layer, self.splithorizontal_mode_sysex])
		self._instrument._main_modes.add_mode('audioloop', [self._instrument.audioloop_layer, self.live_mode_sysex])
		self._instrument.register_component(self._instrument._main_modes)
		self._instrument.set_enabled(False)

	def _setup_main_modes(self):
		self._main_modes = BaseDisplayingModesComponent(name = 'MainModes')
		self._main_modes.add_mode('disabled', [self._background])
		self._main_modes.add_mode('Clips_shifted', [self._mixer, self._mixer.volume_layer, self._mixer.select_layer, self._mixer.channel_controls_layer, self._session_ring, self._session_navigation, self._session_navigation.page_navigation_layer, self.clips_layer_sysex, self.live_mode_sysex, self._translationsJor, self._view_controller], groups = ['shifted'], behaviour = self._shift_latching(color = 'MainModes.Clips'), display_string = MODE_DATA['Clips_shifted'])
		self._main_modes.add_mode('Clips', [self._mixer, self._mixer.volume_layer, self._mixer.select_layer,  self._session_ring, self._session, self._session.cliplaunch_layer, self._session_navigation, self._session_navigation.navigation_layer, self.clips_layer_sysex, self.live_mode_sysex, self._translationsJor, self._view_controller], behaviour = self._shift_latching(color = 'MainModes.Clips'), display_string = MODE_DATA['Clips'])
		self._main_modes.add_mode('Sends_shifted', [self._mixer, self._mixer.returns_layer, self._mixer.selected_sends_layer, self.sends_layer_sysex, self._session_ring, self._recorder, self._recorder.alt_layer, self._instrument, tuple([self._send_instrument_shifted, self._send_instrument_unshifted]), self._translationsJor, self._view_controller], groups = ['shifted'], behaviour = self._shift_latching(color = 'MainModes.Sends'), display_string = MODE_DATA['Sends_shifted'])   #self._instrument,
		self._main_modes.add_mode('Sends', [self._mixer, self._mixer.returns_layer, self._mixer.selected_sends_layer, self.sends_layer_sysex, self._mixer.select_layer,  self._session_ring, self._transport, self._recorder, self._recorder.main_layer, self._instrument, self._translationsJor, self._view_controller], behaviour = self._shift_latching(color = 'MainModes.Sends'), display_string = MODE_DATA['Sends'])
		self._main_modes.add_mode('Device_shifted', [self.device_layer_sysex, self._modswitcher, self._mixer, self._session_ring, tuple([self._send_instrument_shifted, self._send_instrument_unshifted]), self._device, self._device.parameters_layer, self._device_navigator.alt_layer,  self._translationsJor, self._view_controller], groups = ['shifted'], behaviour = self._shift_latching(color = 'MainModes.Device'), display_string = MODE_DATA['Device_shifted'])
		self._main_modes.add_mode('Device', [self.device_layer_sysex, self._modswitcher, self._mixer, self._mixer.select_layer, self._session_ring, self._device, self._device.parameters_layer, self._device.nav_layer, self._device_navigator.main_layer,self._translationsJor, self._view_controller], behaviour = self._shift_latching(color = 'MainModes.Device'), display_string = MODE_DATA['Device'])
		self._main_modes.add_mode('User_shifted', [self._translations, self._mixer, self._mixer.select_layer, self.user_layer_sysex, self.user_mode_sysex, self._translationsJor, self._view_controller ], groups = ['shifted'], behaviour = self._shift_latching(color = 'MainModes.User'), display_string = MODE_DATA['User'])
		self._main_modes.add_mode('User', [self._translations, self._mixer, self._mixer.select_layer, self.user_layer_sysex, self.user_mode_sysex, self._translationsJor, self._view_controller], behaviour = self._shift_latching(color = 'MainModes.User'), display_string = MODE_DATA['User'])
		self._main_modes.add_mode('Select', [self._mixer, self._mixer.volume_layer, self._mixer.selected_channel_controls_layer, self._session_ring, self._session, self._session.overlay_cliplaunch_layer, self.clips_layer_sysex], behaviour = DelayedExcludingMomentaryBehaviour(excluded_groups = ['shifted']), display_string = MODE_DATA['Select'])  #excluded_groups = ['shifted']
		self._main_modes.Select_button._send_current_color = lambda: None  #cant have the multielement updating its button color since it belongs to select buttons, this is the easiest way to deal with it....should probably override in a separate behaviour class
		self._main_modes.layer = Layer(priority = 4, Clips_button=self._button[0], Sends_button=self._button[1], Device_button=self._button[2], User_button=self._button[3], Select_button=self._touchpad_multi, display = self._display)
		self._main_modes.selected_mode = 'disabled'
		self._main_modes.set_enabled(True)
	




#	a
Пример #22
0
class Cntrlr(LividControlSurface):
	__module__ = __name__
	__doc__ = " Monomodular controller script for Livid CNTRLR "


	_sysex_id = 8
	_model_name = 'Cntrlr'
	_host_name = 'Cntrlr'
	monomodular = None

	device_provider_class = ModDeviceProvider

	def __init__(self, *a, **k):
		super(Cntrlr, self).__init__(*a, **k)
		self._skin = Skin(CntrlrColors)
		self._device_selection_follows_track_selection = FOLLOW
		with self.component_guard():
			self._setup_controls()
			self._define_sysex()
			self._setup_background()
			#self._setup_autoarm()
			self._setup_viewcontrol()
			self._setup_session_control()
			self._setup_mixer_control()
			self._setup_transport_control()
			#self._setup_device_control()
			#self._setup_device_selector()
			#self._setup_session_recording_component()
			#self._setup_modes()
			self._setup_m4l_interface()
	

	def _initialize_script(self):
		super(Cntrlr, self)._initialize_script()
		self._connected = True
		#self._main_modes.selected_mode = 'MixMode'

		self._session_ring._update_highlight()
		self._session_ring.track_offset = 0
		if liveobj_valid(self.song.visible_tracks[0]):
			self.song.view.selected_track = self.song.visible_tracks[0]
	

	def _setup_controls(self):
		is_momentary = True
		optimized = True
		resource = PrioritizedResource
		self._fader = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_FADERS[index], name = 'Fader_' + str(index), num = index, script = self,  optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(8)]
		self._dial_left = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_KNOBS_LEFT[index], name = 'Dial_Left_' + str(index), num = CNTRLR_KNOBS_LEFT[index], script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)]
		self._dial_right = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_KNOBS_RIGHT[index], name = 'Dial_Right_' + str(index), num = CNTRLR_KNOBS_RIGHT[index], script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)]
		self._encoder = [CodecEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CNTRLR_DIALS[index], name = 'Encoder_' + str(index), num = CNTRLR_DIALS[index], script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)] 
		self._encoder_button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CNTRLR_DIAL_BUTTONS[index], name = 'Encoder_Button_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(12)]	
		self._grid = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CNTRLR_GRID[index], name = 'Grid_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(16)]
		self._button = [MonoButtonElement(is_momentary = is_momentary,msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = CNTRLR_BUTTONS[index], name = 'Button_' + str(index), script = self, skin = self._skin, color_map = COLOR_MAP, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(32)]
		self._knobs = self._dial_left + self._dial_right

		self._fader_matrix = ButtonMatrixElement(name = 'Fader_Matrix', rows = [self._fader])
		self._matrix = ButtonMatrixElement(name = 'Matrix', rows = [self._grid[index*4:(index*4)+4] for index in range(4)])
		self._knob_left_matrix = ButtonMatrixElement(name = 'Knob_Left_Matrix', rows = [self._dial_left[index*4:(index*4)+4] for index in range(3)])
		self._knob_right_matrix = ButtonMatrixElement(name = 'Knob_Right_Matrix', rows = [self._dial_right[index*4:(index*4)+4] for index in range(3)])
		self._dial_matrix = ButtonMatrixElement(name = 'Dial_Matrix', rows = [self._encoder[index*4:(index*4)+4] for index in range(3)])
		self._dial_button_matrix = ButtonMatrixElement(name = 'Dial_Button_Matrix', rows = [self._encoder_button[index*4:(index*4)+4] for index in range(1,3)])
		self._key_matrix = ButtonMatrixElement(name = 'Key_Matrix', rows = [self._button[0:16], self._button[16:32]])
		
		self._translated_controls = self._fader + self._knobs + self._encoder[4:] + self._grid + self._button
	

	def _setup_background(self):
		self._background = BackgroundComponent(name = 'Background')
		self._background.layer = Layer(priority = 3, matrix = self._matrix.submatrix[:,:], faders = self._fader_matrix.submatrix[:,:], left_knobs = self._knob_left_matrix.submatrix[:,:], right_knobs = self._knob_right_matrix.submatrix[:,:], dials = self._dial_matrix, dial_buttons = self._dial_button_matrix.submatrix[:,:], keys = self._key_matrix.submatrix[:,:])
		self._background.set_enabled(True)
	

	def _define_sysex(self):
		#self.encoder_navigation_on = SendLividSysexMode(livid_settings = self._livid_settings, call = 'set_encoder_encosion_mode', message = [13, 0, 0, 0]) 
		pass
	

	def _setup_transport_control(self):
		self._transport = CntrlrTransportComponent(name = 'Transport') 
		self._transport._play_toggle.view_transform = lambda value: 'Transport.PlayOn' if value else 'Transport.PlayOff'
		self._transport._record_toggle.view_transform = lambda value: 'Transport.RecordOn' if value else 'Transport.RecordOff'
		self._transport._nudge_up_toggle.view_transform = lambda value: 'Transport.NudgeOn' if value else 'Transport.NudgeOff'
		self._transport._nudge_down_toggle.view_transform = lambda value: 'Transport.NudgeOn' if value else 'Transport.NudgeOff'
		self._transport._loop_toggle.view_transform = lambda value: 'Transport.LoopOn' if value else 'Transport.LoopOff'
		self._transport.layer = Layer(priority = 4,
									play_button = self._button[28],
									stop_button = self._button[29],
									record_button = self._button[30],
									tap_tempo_button = self._button[31],
									nudge_up_button = self._button[3],
									nudge_down_button = self._button[19],
									loop_button = self._button[23])
		self._transport.set_enabled(True)
	

	def _setup_autoarm(self):
		self._auto_arm = CntrlrAutoArmComponent(name='Auto_Arm')
		#self._auto_arm._update_notification = lambda a: None
		self._auto_arm.can_auto_arm_track = self._can_auto_arm_track
	

	def _setup_session_recording_component(self):
		self._clip_creator = ClipCreator()
		self._clip_creator.name = 'ClipCreator'
		self._recorder = FixedLengthSessionRecordingComponent(clip_creator = self._clip_creator, view_controller = ViewControlComponent(), name = 'SessionRecorder') # is_enabled = False)
		self._recorder.main_layer = AddLayerMode(self._recorder, Layer(priority = 4, record_button = self._button[29]))
		#self._recorder.shift_layer = AddLayerMode(self._recorder, Layer(priority = 4, automation_button = self._button[29]))
		self._recorder.set_enabled(False)
	

	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 4, num_scenes = 4)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.disabled_color = 'Session.PageNavigationButtonOff'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.disabled_color = 'Session.PageNavigationButtonOff'

		self._session_navigation.layer = Layer(priority = 4,
									down_button = self._button[14],
									up_button = self._button[15],
									left_button = self._button[12],
									right_button = self._button[13])
		self._session_navigation.set_enabled(True)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(priority = 4,
									clip_launch_buttons = self._matrix.submatrix[:,:])
		self._session.set_enabled(True)
	

	def _setup_mixer_control(self):
		self._mixer_session_ring = SessionRingComponent(num_tracks = 4, num_scenes = 4)
		self._mixer = MonoMixerComponent(name = 'Mixer', tracks_provider = self._mixer_session_ring, track_assigner = simple_track_assigner, invert_mute_feedback = True, auto_name = True, enable_skinning = True)

		self._mixer.layer = Layer(priority = 4, 
											solo_buttons = self._key_matrix.submatrix[8:11, 0],
											stop_clip_buttons = self._key_matrix.submatrix[:3, 0],
											track_select_buttons = self._key_matrix.submatrix[4:8, 0],)
		for strip in self._mixer._channel_strips:
			strip._on_select_button_double_clicked = self._toggle_view
		self._mixer.set_enabled(True)
	

	def _toggle_view(self, *a):
		debug('toggle_view')
		debug('Clip is visible:', self.application.view.is_view_visible('Detail/Clip'))
		debug('Device is visible:', self.application.view.is_view_visible('Detail/DeviceChain'))
		if self.application.view.is_view_visible('Detail/Clip'):
			self._view_control.show_view('Detail/DeviceChain')
		else:
			self._view_control.show_view('Detail/Clip')

	def _setup_device_control(self):
		self._device_selection_follows_track_selection = FOLLOW
		self._device = DeviceComponent(name = 'Device_Component', device_provider = self._device_provider, device_bank_registry = DeviceBankRegistry())
		self._device.layer = Layer(priority = 4, parameter_controls = self._dial_matrix.submatrix[:, 1:3],)
		#self._device.mod_layer = AddLayerMode(self._device, Layer(priority = 4, parameter_controls = self._dial_matrix.submatrix[:, 1:3],))
		self._device.main_layer = AddLayerMode(self._device, Layer(priority = 4, parameter_controls = self._dial_matrix.submatrix[:, 1:3], 
												on_off_button = self._encoder_button[4],
												bank_prev_button = self._encoder_button[6],
												bank_next_button = self._encoder_button[7],))
												#lock_button = self._encoder_button[5],
		self._device.set_enabled(False)

		self._device_navigator = DeviceNavigator(self._device_provider, self._mixer, self)
		self._device_navigator.name = 'Device_Navigator'
		self._device_navigator.select_dial_layer = AddLayerMode(self._device_navigator, Layer(priority = 6, device_select_dial = self._encoder[0],))
		self._device_navigator.main_layer = AddLayerMode(self._device_navigator, Layer(priority = 4, 
											prev_chain_button = self._encoder_button[8], 
											next_chain_button = self._encoder_button[9], 
											exit_button = self._encoder_button[10], 
											enter_button = self._encoder_button[11],))
		self._device_navigator.set_enabled(False)
	

	def _setup_device_selector(self):
		self._device_selector = DeviceSelectorComponent(self)
		self._device_selector.name = 'Device_Selector'
		#self._device_selector.select_layer = AddLayerMode(self._device_selector, Layer(priority = 6 , matrix = self._matrix.submatrix[:, :]))
		self._device_selector.select_layer = AddLayerMode(self._device_selector, Layer(priority = 6, matrix = ButtonMatrixElement(rows = [self._grid[:4],self._grid[4:8],self._grid[8:12],self._grid[12:14]])))
		self._device_selector.assign_layer = AddLayerMode(self._device_selector, Layer(priority = 7, assign_button = self._grid[14]))
		self._device_selector.set_enabled(False)
	

	def _setup_viewcontrol(self):
		self._view_control = ViewControlComponent(name='View_Control')
		#self._view_control.main_layer = AddLayerMode(self._view_control, Layer(priority = 5, 
		#																		scene_select_dial = self._encoder[2],
		#																		track_select_dial = self._encoder[3],))
		#self._view_control.main_layer = AddLayerMode(self._view_control, Layer(prev_track_button=self._button[24], 
		#											next_track_button= self._button[25], 
		#											next_scene_button=self._button[27], 
		#											prev_scene_button = self._button[26]))
		self._view_control.set_enabled(True)
	

	def _setup_modes(self):

		common = CompoundMode(self._mixer,
									self._session_ring)
		main_buttons=CompoundMode(self._mixer.main_buttons_layer, 
									self._transport,
									self._recorder,
									self._recorder.main_layer, 
									self._device,)
		shifted_main_buttons=CompoundMode(self._mixer.solo_buttons_layer, 
									self._recorder, 
									self._recorder.shift_layer,
									self._session.scene_launch_layer,
									self._device,)
		main_faders=CompoundMode(self._mixer.main_faders_layer, 
									self._mixer.master_fader_layer)
		main_dials=CompoundMode(self._view_control,
									self._view_control.main_layer,
									self._device_navigator,
									self._device_navigator.select_dial_layer,
									self.encoder_navigation_on)
		shifted_dials=CompoundMode(self._session_navigation,
									self._session_navigation.nav_dial_layer,
									self._device_navigator,
									self._device_navigator.select_dial_layer,
									self.encoder_navigation_on)

		self._modalt_mode = ModesComponent(name = 'ModAltMode')
		self._modalt_mode.add_mode('disabled', None)
		self._modalt_mode.add_mode('enabled', [tuple([self._enable_mod_alt, self._disable_mod_alt])], behaviour = CancellableBehaviourWithRelease(), cycle_mode_button_color = 'Mod.AltOn')
		self._modalt_mode.selected_mode = 'disabled'
		self._modalt_mode.set_enabled(False)
		self._modalt_mode.layer = Layer(priority = 4, enabled_button = self._encoder_button[1])

		self._modswitcher = ModesComponent(name = 'ModSwitcher')
		self._modswitcher.add_mode('mod', [self.modhandler, self._modalt_mode, main_faders, self._mixer.main_knobs_layer, self._device, main_dials, DelayMode(self.modhandler.update, delay = .5, parent_task_group = self._task_group)])
		self._modswitcher.add_mode('instrument', [self._instrument.shift_button_layer, main_buttons, main_faders, self._mixer.main_knobs_layer, self._device, self._device.main_layer, self._device_navigator, self._device_navigator.main_layer, self._device_navigator.select_dial_layer]) #self._instrument.shift_button_layer, self._optional_translations])
		self._modswitcher.selected_mode = 'instrument'
		self._modswitcher.set_enabled(False)

		self._instrument._main_modes = ModesComponent(name = 'InstrumentModes')
		self._instrument._main_modes.add_mode('disabled', [main_buttons, 
																					main_dials, 
																					self._device.main_layer, 
																					self._session, 
																					self._session, 
																					self._session.clip_launch_layer])
		self._instrument._main_modes.add_mode('drumpad', [self._instrument._drumpad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_split', [self._instrument._drumpad.split_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer', [self._instrument._drumpad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_shifted', [self._instrument._drumpad.sequencer_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_split_shifted', [self._instrument._drumpad.split_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer_shifted', [self._instrument._drumpad.sequencer_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad', [self._instrument._keypad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_split', [self._instrument._keypad.split_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer', [self._instrument._keypad.sequencer_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_shifted', [self._instrument._keypad.sequencer_shift_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_split_shifted', [self._instrument._keypad.split_layer, 
																					self._instrument.keypad_shift_layer,
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer_shifted', [self._instrument._keypad.sequencer_shift_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_session', [self._instrument._drumpad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_split_session', [self._instrument._drumpad.split_session_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer_session', [self._instrument._drumpad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session,  
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('drumpad_shifted_session', [self._instrument._drumpad.sequencer_session_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_split_shifted_session', [self._instrument._drumpad.split_session_layer,
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('drumpad_sequencer_shifted_session', [self._instrument._drumpad.sequencer_session_shift_layer, 
																					self._instrument.drumpad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_session', [self._instrument._keypad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session, 
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_split_session', [self._instrument._keypad.split_session_layer,
																					self._instrument._selected_session,
																					main_buttons,
																					self._device.main_layer,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer_session', [self._instrument._keypad.sequencer_session_layer, 
																					main_buttons,
																					self._device.main_layer,
																					self._session, 
																					DelayMode(self._session.clip_launch_layer, delay = .1), 
																					main_dials])
		self._instrument._main_modes.add_mode('keypad_shifted_session', [self._instrument._keypad.sequencer_session_shift_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_split_shifted_session', [self._instrument._keypad.split_session_layer, 
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		self._instrument._main_modes.add_mode('keypad_sequencer_shifted_session', [self._instrument._keypad.sequencer_session_shift_layer,
																					self._instrument.keypad_shift_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])

		self._instrument._main_modes.add_mode('audioloop', [self._instrument.audioloop_layer, 
																					main_buttons,
																					self._device.main_layer,
																					main_dials,
																					self._session,
																					DelayMode(self._session.clip_launch_layer, delay = .1)])
		self._instrument._main_modes.add_mode('audioloop_shifted', [self._instrument.audioloop_layer, 
																					shifted_main_buttons,
																					self._device.main_layer,
																					self._session_zoom, 
																					shifted_dials])
		#self._instrument._main_modes.add_mode('audioloop_shifted_session', [self._instrument.audioloop_layer, self._session, shifted_main_buttons, main_dials, shifted_dials])
		self._instrument.register_component(self._instrument._main_modes)
		self._instrument._main_modes.selected_mode = 'disabled'
		self._instrument.set_enabled(True)

		self._main_modes = ModesComponent(name = 'MainModes')
		self._main_modes.add_mode('disabled', [self._background])
		self._main_modes.add_mode('MixMode', [common, 
													self._instrument, 
													self._instrument.shift_button_layer,
													self._mixer,
													main_faders, 
													self._mixer.main_knobs_layer,
													self._device,
													self._device.main_layer,
													self._device_navigator,
													self._device_navigator.main_layer,
													self._device_navigator.select_dial_layer])
		self._main_modes.add_mode('ModSwitcher', [common,
													main_faders, 
													main_dials, 
													self._mixer.main_knobs_layer,
													self._view_control,
													self._view_control.main_layer,
													self._device_navigator,
													self._device_navigator.select_dial_layer, 
													self.encoder_navigation_on, 
													self._modswitcher, 
													DelayMode(self._update_modswitcher, delay = .1)], 
													behaviour = ColoredCancellableBehaviourWithRelease(color = 'ModeButtons.ModSwitcher', off_color = 'ModeButtons.ModSwitcherDisabled'))
		self._main_modes.add_mode('Translations', [common, 
													main_faders, 
													main_dials,
													self._mixer.main_knobs_layer, 
													self._translations, 
													DelayMode(self._translations.selector_layer, delay = .1)], 
													behaviour = DefaultedBehaviour(default_mode = 'MixMode', color = 'ModeButtons.Translations', off_color = 'ModeButtons.TranslationsDisabled'))
		self._main_modes.add_mode('DeviceSelector', [common,
													self._device_selector,
													DelayMode(self._device_selector.select_layer, delay = .1),
													DelayMode(self.modhandler.lock_layer, delay = .1),
													DelayMode(self._device_selector.assign_layer, delay = .5), 
													main_buttons,
													main_dials, 
													main_faders, 
													self._mixer.main_knobs_layer, 
													self._device.main_layer,
													self._device_navigator,
													self._device_navigator.main_layer,
													self._device_navigator.select_dial_layer], 
													behaviour = ColoredCancellableBehaviourWithRelease(color = 'ModeButtons.DeviceSelector', off_color = 'ModeButtons.DeviceSelectorDisabled'))
		self._main_modes.layer = Layer(priority = 4, ModSwitcher_button = self._encoder_button[2], DeviceSelector_button = self._encoder_button[0], Translations_button = self._encoder_button[3]) #, 
		self._main_modes.selected_mode = 'disabled'
		self._main_modes.set_enabled(True)

		self._test.subject = self._instrument._main_modes
	

	def _setup_modes(self):
		pass
	

	def _setup_m4l_interface(self):
		self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard, priority = 10)
		self._m4l_interface.name = "M4LInterface"
		self.get_control_names = self._m4l_interface.get_control_names
		self.get_control = self._m4l_interface.get_control
		self.grab_control = self._m4l_interface.grab_control
		self.release_control = self._m4l_interface.release_control
	

	def _can_auto_arm_track(self, track):
		routing = track.current_input_routing
		return routing == 'Ext: All Ins' or routing == 'All Ins' or routing.startswith('Cntrlr Input')
	

	def _get_num_tracks(self):
		return self.num_tracks
	



#	a
Пример #23
0
class GuitarWing(LividControlSurface):


	_sysex_id = 20
	_model_name = 'GuitarWing'

	def __init__(self, *a, **k):
		super(GuitarWing, self).__init__(*a, **k)
		self._skin = Skin(GuitarWingColors)
		with self.component_guard():
			self._setup_controls()
			self._setup_m4l_interface()
			self._setup_session_control()
			self._setup_mixer_control()
			self._setup_device_control()
			self._setup_transport_control()
			self._setup_view_control()


	def _setup_controls(self):
		is_momentary = True
		optimized = True
		resource = PrioritizedResource
		self._button = [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = BUTTONS[index], name = 'Button_' + str(index), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(10)]
		self._fader = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = SLIDERS[index], name = 'Fader_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(3)]
		self._fader_button = [MonoEncoderElement(msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = SLIDERS[index], name = 'Fader_Button_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(3)]
		self._ccs = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = CCS[index], name = 'CCs_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(4)]
		self._pad =  [MonoButtonElement(is_momentary = is_momentary, msg_type = MIDI_NOTE_TYPE, channel = CHANNEL, identifier = PADS[index], name = 'Pad_' + str(index), script = self, skin = self._skin, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(5)]
		self._padCC = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = PADS[index], name = 'PadCC_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(5)]
		self._accel = [MonoEncoderElement(msg_type = MIDI_CC_TYPE, channel = CHANNEL, identifier = ACCELS[index], name = 'Accel_' + str(index), num = index, script = self, optimized_send_midi = optimized, resource_type = resource, monobridge = self._monobridge) for index in range(3)]

		self._parameter_control_matrix = ButtonMatrixElement(rows = [ [ self._fader[0], self._fader[1], self._fader[2], self._accel[2], self._ccs[0], self._ccs[1], self._ccs[2], self._ccs[3] ]])
		self._scene_launch_matrix = ButtonMatrixElement(rows = [self._pad[:4]])


	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 1, num_scenes = 4, tracks_to_use = lambda : self.song.visible_tracks + self.song.return_tracks)
		self._session_ring.set_enabled(False)

		self._session = SessionComponent(session_ring = self._session_ring, auto_name = True)
		hasattr(self._session, '_enable_skinning') and self._session._enable_skinning()
		self._session.layer = Layer(scene_launch_buttons = self._scene_launch_matrix)

		self._session_navigation =SessionNavigationComponent(name = 'SessionNavigation', session_ring = self._session_ring)

		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'

		self._session_navigation.layer = Layer(left_button = self._button[1], right_button = self._button[0])
		self._session_navigation.set_enabled(True)


	def _setup_mixer_control(self):
		self._mixer = MonoMixerComponent(name = 'Mixer', tracks_provider = self._session_ring, track_assigner = SimpleTrackAssigner(), invert_mute_feedback = True, auto_name = True, enable_skinning = True, channel_strip_component_type = MonoChannelStripComponent)
		self.song.view.selected_track = self._mixer.channel_strip(0)._track


	def _setup_transport_control(self):
		self._transport = TransportComponent()
		self._transport.layer = Layer(play_button = self._button[6],
										loop_button = self._button[7],
										seek_backward_button = self._button[8],
										record_button = self._button[9])
		self._transport.set_enabled(True)


	def _setup_device_control(self):
		self._device = DeviceComponent(name = 'Device_Component', device_provider = self._device_provider, device_bank_registry = DeviceBankRegistry())
		self._device.layer = Layer(parameter_controls = self._parameter_control_matrix)
		self._device.set_enabled(True)


	def _setup_m4l_interface(self):
		self._m4l_interface = M4LInterfaceComponent(controls=self.controls, component_guard=self.component_guard)
		self.get_control_names = self._m4l_interface.get_control_names
		self.get_control = self._m4l_interface.get_control
		self.grab_control = self._m4l_interface.grab_control
		self.release_control = self._m4l_interface.release_control


	def _setup_view_control(self):
		self._view_control = ViewControlComponent()
		self._view_control.layer = Layer(prev_track_button = self._button[1], next_track_button = self._button[0])
Пример #24
0
class OhmModes(LividControlSurface):

    _sysex_id = 2
    _alt_sysex_id = 7
    _model_name = 'Ohm'
    _version_check = 'b996'
    _host_name = 'Ohm'
    device_provider_class = ModDeviceProvider

    def __init__(self, c_instance):
        super(OhmModes, self).__init__(c_instance)
        self._skin = Skin(OhmColors)
        with self.component_guard():
            self._define_sysex()
            self._setup_controls()
            self._setup_background()
            self._setup_m4l_interface()
            self._setup_translations()
            self._setup_session_control()
            self._setup_mixer_control()
            self._setup_device_control()
            self._setup_transport_control()
            self._setup_drumgroup()
            self._setup_keygroup()
            self._setup_bassgroup()
            self._setup_mod()
            self._setup_modswitcher()
            self._setup_modes()
        self._on_device_changed.subject = self._device_provider

    def _define_sysex(self):
        #self._send_midi(tuple(switchxfader))
        self._reverse_crossfader = SendLividSysexMode(
            self._livid_settings, call='reverse crossfader', message=[1])

    def update_display(self):
        super(OhmModes, self).update_display()
        #self.strobe()

    def _initialize_hardware(self):
        super(OhmModes, self)._initialize_hardware()
        #self._reverse_crossfader.enter_mode()

    def _initialize_script(self):
        super(OhmModes, self)._initialize_script()
        self._main_modes.selected_mode = 'Mix'
        self._session.update()
        self._mixer.update()

    def _setup_controls(self):
        is_momentary = True
        optimized = True
        resource = PrioritizedResource
        self._fader = [
            MonoEncoderElement(msg_type=MIDI_CC_TYPE,
                               channel=CHANNEL,
                               identifier=OHM_FADERS[index],
                               name='Fader_' + str(index),
                               num=index,
                               script=self,
                               optimized_send_midi=optimized,
                               resource_type=resource) for index in range(8)
        ]
        self._button = [
            MonoButtonElement(is_momentary=is_momentary,
                              msg_type=MIDI_NOTE_TYPE,
                              channel=CHANNEL,
                              identifier=OHM_BUTTONS[index],
                              name='Button_' + str(index),
                              script=self,
                              skin=self._skin,
                              optimized_send_midi=optimized,
                              resource_type=resource) for index in range(8)
        ]
        self._dial = [
            MonoEncoderElement(msg_type=MIDI_CC_TYPE,
                               channel=CHANNEL,
                               identifier=OHM_DIALS[index],
                               name='Encoder_' + str(index),
                               num=index,
                               script=self,
                               optimized_send_midi=optimized,
                               resource_type=resource) for index in range(16)
        ]
        self._menu = [
            MonoButtonElement(is_momentary=is_momentary,
                              msg_type=MIDI_NOTE_TYPE,
                              channel=CHANNEL,
                              identifier=OHM_MENU[index],
                              name='Menu_' + str(index),
                              script=self,
                              skin=self._skin,
                              optimized_send_midi=optimized,
                              resource_type=resource) for index in range(6)
        ]
        self._crossfader = MonoEncoderElement(msg_type=MIDI_CC_TYPE,
                                              channel=CHANNEL,
                                              identifier=CROSSFADER,
                                              name='Crossfader',
                                              script=self,
                                              optimized_send_midi=optimized,
                                              resource_type=resource)
        self._livid = MonoButtonElement(is_momentary=is_momentary,
                                        msg_type=MIDI_NOTE_TYPE,
                                        channel=CHANNEL,
                                        identifier=LIVID,
                                        name='Livid_Button',
                                        skin=self._skin,
                                        script=self,
                                        optimized_send_midi=optimized,
                                        resource_type=resource)
        self._shift_l = MonoButtonElement(is_momentary=is_momentary,
                                          msg_type=MIDI_NOTE_TYPE,
                                          channel=CHANNEL,
                                          identifier=SHIFT_L,
                                          name='Page_Button_Left',
                                          script=self,
                                          skin=self._skin,
                                          optimized_send_midi=optimized,
                                          resource_type=resource)
        self._shift_r = MonoButtonElement(is_momentary=is_momentary,
                                          msg_type=MIDI_NOTE_TYPE,
                                          channel=CHANNEL,
                                          identifier=SHIFT_R,
                                          name='Page_Button_Right',
                                          script=self,
                                          skin=self._skin,
                                          optimized_send_midi=optimized,
                                          resource_type=resource)
        self._grid = [[
            MonoButtonElement(is_momentary=is_momentary,
                              msg_type=MIDI_NOTE_TYPE,
                              channel=CHANNEL,
                              identifier=column * 8 + row,
                              name='Grid_' + str(column + (row * 8)),
                              script=self,
                              skin=self._skin,
                              optimized_send_midi=optimized,
                              resource_type=resource) for column in range(8)
        ] for row in range(8)]
        self._matrix = ButtonMatrixElement(
            name='Matrix',
            rows=[[self._grid[row][column] for column in range(8)]
                  for row in range(8)])
        self._dial_matrix = ButtonMatrixElement(
            name='DialMatrix',
            rows=[self._dial[index * 4:(index * 4) + 4] for index in range(4)])
        self._menu_matrix = ButtonMatrixElement(name='MenuMatrix',
                                                rows=[self._menu])
        self._fader_matrix = ButtonMatrixElement(name='FaderMatrix',
                                                 rows=[self._fader])
        self._button_matrix = ButtonMatrixElement(name='ButtonMatrix',
                                                  rows=[self._button])

        self._parameter_controls = ButtonMatrixElement(
            rows=[self._dial[:4], self._dial[4:8]])

    def _setup_background(self):
        self._background = BackgroundComponent(name='Background')
        self._background.layer = Layer(
            priority=3,
            matrix=self._matrix.submatrix[:, :],
            livid_button=self._livid,
            shift_l_button=self._shift_l,
            shift_r_button=self._shift_r,
            crossfader=self._crossfader,
            dial_matrix=self._dial_matrix.submatrix[:, :],
            menu_matrix=self._menu_matrix.submatrix[:, :],
            fader_matrix=self._fader_matrix.submatrix[:, :],
            button_matrix=self._button_matrix.submatrix[:, :])
        self._background.set_enabled(False)

    def _setup_m4l_interface(self):
        self._m4l_interface = M4LInterfaceComponent(
            controls=self.controls, component_guard=self.component_guard)
        self.get_control_names = self._m4l_interface.get_control_names
        self.get_control = self._m4l_interface.get_control
        self.grab_control = self._m4l_interface.grab_control
        self.release_control = self._m4l_interface.release_control

    def _setup_translations(self):
        controls = []
        for array in self._grid:
            for button in array:
                controls.append(button)
        if FADER_BANKING:
            controls = controls + self._dial
        if DIAL_BANKING:
            controls = controls + self._dial
        self._translations = TranslationComponent(
            controls=controls, user_channel_offset=USER_CHANNEL, channel=8)
        self._translations.layer = Layer(
            priority=5,
            channel_selector_buttons=self._menu_matrix.submatrix[:, :])
        self._translations.set_enabled(False)

        dj_controls = [self._grid[7][index] for index in range(7)]
        self._dj_translation = TranslationComponent(controls=dj_controls,
                                                    channel=12)

    def _setup_session_control(self):
        self._session_ring = SessionRingComponent(num_tracks=7, num_scenes=5)
        self._session_ring.set_enabled(True)

        self._session_navigation = SessionNavigationComponent(
            session_ring=self._session_ring)
        self._session_navigation.scroll_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  up_button=self._menu[2],
                  down_button=self._menu[5],
                  left_button=self._menu[3],
                  right_button=self._menu[4]))
        self._session_navigation.page_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  page_up_button=self._menu[2],
                  page_down_button=self._menu[5],
                  page_left_button=self._menu[3],
                  page_right_button=self._menu[4]))
        self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation.set_enabled(False)

        self._session = OhmSessionComponent(name='Session',
                                            session_ring=self._session_ring,
                                            auto_name=True)
        hasattr(self._session,
                '_enable_skinning') and self._session._enable_skinning()
        self._session.set_enabled(False)
        self._session.clip_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  clip_launch_buttons=self._matrix.submatrix[:7, :5]))
        self._session.scene_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  scene_launch_buttons=self._matrix.submatrix[7, :5]))

        self._session_zoom = SessionOverviewComponent(
            name='Session_Overview',
            session_ring=self._session_ring,
            enable_skinning=True)
        self._session_zoom.layer = Layer(
            priority=5, button_matrix=self._matrix.submatrix[:7, :5])
        self._session_zoom.set_enabled(False)

        self._session_modes = ModesComponent(name='Session_Modes')
        self._session_modes.add_mode('disabled', [
            self._session, self._session.clip_launch_layer,
            self._session.scene_launch_layer, self._session_navigation,
            self._session_navigation.scroll_navigation_layer
        ])
        self._session_modes.add_mode('enabled', [
            self._session, self._session.scene_launch_layer,
            self._session_zoom, self._session_navigation,
            self._session_navigation.page_navigation_layer
        ],
                                     behaviour=DefaultedBehaviour())
        self._session_modes.layer = Layer(priority=5,
                                          enabled_button=self._grid[7][7])
        self._session_modes.selected_mode = 'disabled'
        self._session_modes.set_enabled(False)

    def _setup_mixer_control(self):
        self._mixer = OhmMixerComponent(
            name='Mixer',
            tracks_provider=self._session_ring,
            track_assigner=SimpleTrackAssigner(),
            invert_mute_feedback=True,
            auto_name=True,
            enable_skinning=True,
            channel_strip_component_type=MonoChannelStripComponent)
        self._mixer.layer = Layer(
            priority=5,
            volume_controls=self._fader_matrix.submatrix[:7, :],
            prehear_volume_control=self._dial[15],
            crossfader_control=self._crossfader)
        self._mixer.master_strip().layer = Layer(priority=5,
                                                 volume_control=self._fader[7],
                                                 select_button=self._button[7])
        self._mixer.mix_layer = AddLayerMode(
            self._mixer,
            Layer(
                priority=5,
                mute_buttons=self._matrix.submatrix[:7, 5],
                solo_buttons=self._matrix.submatrix[:7, 6],
                arm_buttons=self._matrix.submatrix[:7, 7],
                send_controls=self._dial_matrix.submatrix[:, :2],
                pan_controls=self._dial_matrix.submatrix[:7, 2:],
                track_select_buttons=self._button_matrix.submatrix[:7, :],
            ))
        self._mixer.dj_layer = AddLayerMode(
            self._mixer,
            Layer(
                priority=5,
                mute_buttons=self._matrix.submatrix[:7, 5],
                crossfade_toggles=self._matrix.submatrix[:7, 6],
                end_pan_controls=self._dial_matrix.submatrix[:3, 3],
                eq_gain_controls=self._dial_matrix.submatrix[:, :3],
                track_select_buttons=self._button_matrix.submatrix[:7, :],
            ))
        self._mixer.instrument_layer = AddLayerMode(
            self._mixer,
            Layer(priority=5,
                  instrument_send_controls=self._dial_matrix.submatrix[:, 2:],
                  arming_track_select_buttons=self._button_matrix.
                  submatrix[:7, :]))

    def _setup_device_control(self):
        self._device = OhmDeviceComponent(
            script=self,
            name='Device_Component',
            device_provider=self._device_provider,
            device_bank_registry=DeviceBankRegistry())
        self._device.layer = Layer(priority=5,
                                   parameter_controls=self._parameter_controls)
        self._device.set_enabled(False)

        self._device_navigator = DeviceNavigator(
            self._device_provider,
            self._mixer,
            self,
            name='Device_Navigator',
        )
        self._device_navigator.layer = Layer(priority=5,
                                             prev_button=self._menu[3],
                                             next_button=self._menu[4])
        self._device_navigator.set_enabled(False)

    def _setup_transport_control(self):
        self._transport = OhmTransportComponent()
        self._transport.name = 'Transport'
        self._transport.layer = Layer(priority=5,
                                      play_button=self._menu[0],
                                      stop_button=self._menu[1])
        self._transport.set_enabled(False)

    def _setup_drumgroup(self):
        self._drumgroup = MonoDrumGroupComponent(
            translation_channel=PAGE1_DRUM_CHANNEL,
            set_pad_translations=self.set_pad_translations)
        self._drumgroup._on_selected_track_changed.subject = None
        self._drumgroup.translation_channel = PAGE1_DRUM_CHANNEL
        self._drumgroup.layer = Layer(priority=6,
                                      matrix=self._matrix.submatrix[:4, :4])
        self._drumgroup.set_enabled(False)

    def _setup_keygroup(self):
        self._scale_mode = ModesComponent(name='ScaleMode')
        for scale in SCALES:
            debug('making scale mode:', scale, str(scale))
            self._scale_mode.add_mode(str(scale), [])
        self._scale_mode.layer = Layer(priority=5,
                                       ionian_button=self._grid[7][0],
                                       dorian_button=self._grid[7][1],
                                       phrygian_button=self._grid[7][2],
                                       lydian_button=self._grid[7][3],
                                       mixolydian_button=self._grid[7][4],
                                       aeolian_button=self._grid[7][5],
                                       locrian_button=self._grid[7][6],
                                       major_button=self._grid[7][7])
        self._scale_mode.selected_mode = 'ionian'
        self._scale_mode.set_enabled(False)
        self._on_scale_change.subject = self._scale_mode

        self._octave_offset_component = ScrollingChannelizedSettingsComponent(
            name='NoteOffset',
            parent_task_group=self._task_group,
            value_dict=range(104),
            default_value_index=36,
            default_channel=0,
            bank_increment=12,
            bank_on_color='MonoInstrument.OffsetOnValue',
            bank_off_color='MonoInstrument.OffsetOffValue')
        self._octave_offset_component.layer = Layer(
            priority=5,
            bank_up_button=self._menu[2],
            bank_down_button=self._menu[5])
        self._on_octave_change.subject = self._octave_offset_component

        self._keygroup = OhmKeyGroupComponent()
        self._keygroup._on_selected_track_changed.subject = None
        self._keygroup.translation_channel = PAGE1_KEYS_CHANNEL
        self._keygroup.layer = Layer(priority=6,
                                     matrix=self._matrix.submatrix[:, 4:7])
        self._keygroup.set_enabled(False)

    def _setup_bassgroup(self):
        self._bassgroup = OhmBassGroupComponent()
        self._bassgroup._on_selected_track_changed.subject = None
        self._bassgroup.translation_channel = PAGE1_BASS_CHANNEL
        self._bassgroup.layer = Layer(priority=6,
                                      matrix=self._matrix.submatrix[4:, :4])
        self._bassgroup.set_enabled(False)

    def _setup_mod(self):
        self.monomodular = get_monomodular(self)
        self.monomodular.name = 'monomodular_switcher'
        self.modhandler = OhmModHandler(script=self,
                                        device_provider=self._device_provider)
        self.modhandler.name = 'ModHandler'
        self.modhandler.layer = Layer(
            priority=5,
            grid=self._matrix.submatrix[:, :],
            nav_up_button=self._menu[2],
            nav_down_button=self._menu[5],
            nav_left_button=self._menu[3],
            nav_right_button=self._menu[4],
            shift_button=self._menu[1],
            alt_button=self._menu[0],
        )
        #parameter_controls = self._dial_matrix)
        self.modhandler.legacy_shift_mode = AddLayerMode(
            self.modhandler,
            Layer(priority=6,
                  channel_buttons=self._matrix.submatrix[:, 1],
                  nav_matrix=self._matrix.submatrix[4:8, 2:6]))
        self.modhandler.shift_mode = AddLayerMode(
            self.modhandler,
            Layer(priority=6,
                  device_selector_matrix=self._matrix.submatrix[:, 0],
                  lock_button=self._livid,
                  key_buttons=self._matrix.submatrix[:, 7]))

        self.modhandler.set_enabled(False)
        self.modhandler.set_mod_button(self._livid)

    def _setup_modswitcher(self):
        self._modswitcher = ModesComponent(name='ModSwitcher')
        self._modswitcher.add_mode('mod', [
            self.modhandler, self._device,
            DelayMode(self.modhandler.update, delay=.5)
        ])
        self._modswitcher.add_mode('translations', [self._translations])
        self._modswitcher.selected_mode = 'translations'
        self._modswitcher.set_enabled(False)

    def _setup_modes(self):

        self._main_modes = ModesComponent(name='MainModes')
        self._main_modes.add_mode('disabled', [self._background])
        self._main_modes.add_mode('Mix', [
            self._session_modes, self._mixer, self._mixer.mix_layer,
            self._transport
        ])

        self._main_modes.add_mode(
            'DJ', [
                self._session_modes, self._mixer, self._mixer.dj_layer,
                self._dj_translation,
                tuple([self._assign_tempo, self._deassign_tempo])
            ],
            behaviour=DefaultedBehaviour(default_mode='Mix'))
        #tuple([ lambda:self._set_tempo_buttons([self._grid[7][5], self._grid[7][6]]), self._set_tempo_buttons([])])],

        self._main_modes.add_mode(
            'Instrument', [
                self._update_keygroup_colors, self._bassgroup, self._keygroup,
                self._scale_mode, self._octave_offset_component, self._device,
                self._device_navigator, self._mixer,
                self._mixer.instrument_layer, self._drumgroup
            ],
            behaviour=DefaultedBehaviour(default_mode='Mix'))

        self._main_modes.add_mode(
            'Mod', [
                self._modswitcher, self._device, self._mixer,
                self._mixer.instrument_layer
            ],
            behaviour=DefaultedBehaviour(default_mode='Mix'))
        self._main_modes.layer = Layer(priority=5,
                                       Instrument_button=self._shift_l,
                                       DJ_button=self._shift_r,
                                       Mod_button=self._livid)
        self._main_modes.selected_mode = 'disabled'
        self._main_modes.set_enabled(True)

    def disconnect(self):
        super(OhmModes, self).disconnect()

    def strobe(self):
        if self._backlight_type != 'static':
            if self._backlight_type is 'pulse':
                self._backlight = int(
                    math.fabs(self._timer * 16 % 64 - 32) + 32)
            if self._backlight_type is 'up':
                self._backlight = int(self._timer * 8 % 64 + 16)
            if self._backlight_type is 'down':
                self._backlight = int(
                    math.fabs(int(self._timer * 8 % 64 - 64)) + 16)
        self._send_midi(tuple([176, 27, int(self._backlight)]))
        if self._ohm_type != 'static':
            if self._ohm_type is 'pulse':
                self._ohm = int(math.fabs(self._timer * 16 % 64 - 32) + 32)
            if self._ohm_type is 'up':
                self._ohm = int(self._timer * 8 % 64 + 16)
            if self._ohm_type is 'down':
                self._ohm = int(math.fabs(int(self._timer * 8 % 64 - 64)) + 16)
        self._send_midi(tuple([176, 63, int(self._ohm)]))
        self._send_midi(tuple([176, 31, int(self._ohm)]))

    def handle_sysex(self, midi_bytes):
        debug('sysex: ', str(midi_bytes))
        if len(midi_bytes) > 14:
            if midi_bytes[:6] == tuple([240, 0, 1, 97, 12, 64]):
                self._register_pad_pressed(midi_bytes[6:14])
            elif midi_bytes[:6] == tuple([240, 0, 1, 97, 17, 64]):
                self._register_pad_pressed(midi_bytes[6:14])
            elif midi_bytes[3:11] == tuple(
                [6, 2, 0, 1, 97, 1, 0] +
                [self._sysex_id]) or midi_bytes[3:11] == tuple(
                    [6, 2, 0, 1, 97, 1, 0] + [self._alt_sysex_id]):
                if not self._connected:
                    #self._connection_routine.kill()
                    self._connected = True
                    self._livid_settings.set_model(midi_bytes[11])
                    self._initialize_hardware()
                    self.schedule_message(1, self._initialize_script)

    @listens('device')
    def _on_device_changed(self):
        self.schedule_message(1, self._update_modswitcher)
        #debug('base on_device_changed')
        self._update_modswitcher()

    def _on_selected_track_changed(self):
        super(OhmModes, self)._on_selected_track_changed()
        if not len(self.song.view.selected_track.devices):
            self._update_modswitcher()

    def _update_modswitcher(self):
        debug('update modswitcher, mod is:', self.modhandler.active_mod())
        if self.modhandler.active_mod():
            self._modswitcher.selected_mode = 'mod'
        else:
            self._modswitcher.selected_mode = 'translations'

    @listens('selected_mode')
    def _on_scale_change(self, mode):
        debug('new scale is:', mode, self._scale_mode.selected_mode)
        self._keygroup.scale = SCALES.index(self._scale_mode.selected_mode)

    @listens('value')
    def _on_octave_change(self, value):
        self._keygroup.offset = value

    #stupid hack....4 hours wasted on two buttons is too long, so we're doing this instead
    def _update_keygroup_colors(self):
        self._grid[5][7].send_value(2, force=True)
        self._grid[6][7].send_value(2, force=True)

    #everything below needs to be consolidated into transport component
    def _assign_tempo(self):
        self._grid[5][7].send_value(4, True)
        self._grid[6][7].send_value(4, True)
        self._tempo_up_value.subject = self._grid[5][7]
        self._tempo_down_value.subject = self._grid[6][7]

    def _deassign_tempo(self):
        self._tempo_up_value.subject and self._tempo_up_value.subject.turn_off(
        )
        self._tempo_down_value.subject and self._tempo_down_value.subject.turn_off(
        )
        self._tempo_up_value.subject = None
        self._tempo_down_value.subject = None

    @listens('value')
    def _tempo_up_value(self, value):
        if value:
            self.song.tempo = round(min(self.song.tempo + 1, 999))

    @listens('value')
    def _tempo_down_value(self, value):
        if value:
            self.song.tempo = round(max(self.song.tempo - 1, 20))
Пример #25
0
 def _create_navigation(self):
     self._session_navigation = SessionNavigationComponent(
         session_ring=self._session_ring, name=u'Session_Navigation')
Пример #26
0
    def _setup_session_control(self):
        self._session_ring = SessionRingComponent(num_tracks=7, num_scenes=5)
        self._session_ring.set_enabled(True)

        self._session_navigation = SessionNavigationComponent(
            session_ring=self._session_ring)
        self._session_navigation.scroll_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  up_button=self._menu[2],
                  down_button=self._menu[5],
                  left_button=self._menu[3],
                  right_button=self._menu[4]))
        self._session_navigation.page_navigation_layer = AddLayerMode(
            self._session_navigation,
            Layer(priority=5,
                  page_up_button=self._menu[2],
                  page_down_button=self._menu[5],
                  page_left_button=self._menu[3],
                  page_right_button=self._menu[4]))
        self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
        self._session_navigation.set_enabled(False)

        self._session = OhmSessionComponent(name='Session',
                                            session_ring=self._session_ring,
                                            auto_name=True)
        hasattr(self._session,
                '_enable_skinning') and self._session._enable_skinning()
        self._session.set_enabled(False)
        self._session.clip_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  clip_launch_buttons=self._matrix.submatrix[:7, :5]))
        self._session.scene_launch_layer = AddLayerMode(
            self._session,
            Layer(priority=5,
                  scene_launch_buttons=self._matrix.submatrix[7, :5]))

        self._session_zoom = SessionOverviewComponent(
            name='Session_Overview',
            session_ring=self._session_ring,
            enable_skinning=True)
        self._session_zoom.layer = Layer(
            priority=5, button_matrix=self._matrix.submatrix[:7, :5])
        self._session_zoom.set_enabled(False)

        self._session_modes = ModesComponent(name='Session_Modes')
        self._session_modes.add_mode('disabled', [
            self._session, self._session.clip_launch_layer,
            self._session.scene_launch_layer, self._session_navigation,
            self._session_navigation.scroll_navigation_layer
        ])
        self._session_modes.add_mode('enabled', [
            self._session, self._session.scene_launch_layer,
            self._session_zoom, self._session_navigation,
            self._session_navigation.page_navigation_layer
        ],
                                     behaviour=DefaultedBehaviour())
        self._session_modes.layer = Layer(priority=5,
                                          enabled_button=self._grid[7][7])
        self._session_modes.selected_mode = 'disabled'
        self._session_modes.set_enabled(False)
Пример #27
0
class OhmModesRay(OhmModes):


	_sysex_id = 2
	_alt_sysex_id = 7
	_model_name = 'Ohm'
	_version_check = 'b996'
	_host_name = 'Ohm'
	device_provider_class = ModDeviceProvider

	def __init__(self, c_instance):
		super(OhmModes, self).__init__(c_instance)
		self._skin = Skin(OhmColors)
		with self.component_guard():
			self._define_sysex()
			self._setup_controls()
			self._setup_background()
			self._setup_m4l_interface()
			#self._setup_translations()
			self._setup_session_control()
			self._setup_mixer_control()
			self._setup_instrument()
			#self._setup_device_control()
			#self._setup_transport_control()
			#self._setup_drumgroup()
			#self._setup_keygroup()
			#self._setup_bassgroup()
			#self._setup_mod()
			#self._setup_modswitcher()
			self._setup_modes()
		self._on_device_changed.subject = self._device_provider
		self.set_feedback_channels(FEEDBACK_CHANNELS)
		self._session_ring._update_highlight()


	def set_feedback_channels(self, channels, *a, **k):
		super(OhmModes, self).set_feedback_channels(channels, *a, **k)



	def _setup_session_control(self):
		self._session_ring = SessionRingComponent(num_tracks = 7, num_scenes = 7)
		self._session_ring.set_enabled(True)

		self._session_navigation = SessionNavigationComponent(session_ring = self._session_ring)
		self._session_navigation.scroll_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 5, up_button = self._menu[1], down_button = self._menu[4], left_button = self._menu[3], right_button = self._menu[5]))
		self._session_navigation.page_navigation_layer = AddLayerMode(self._session_navigation, Layer(priority = 5, page_up_button = self._menu[2], page_down_button = self._menu[5], page_left_button = self._menu[3], page_right_button = self._menu[4]))
		self._session_navigation._vertical_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_up_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._horizontal_banking.scroll_down_button.color = 'Session.NavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._vertical_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_up_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation._horizontal_paginator.scroll_down_button.color = 'Session.PageNavigationButtonOn'
		self._session_navigation.set_enabled(False)

		self._session = SpecialOhmSessionComponent(name = 'Session', session_ring = self._session_ring, auto_name = True)
		self._session.set_enabled(False)
		self._session.clip_launch_layer = AddLayerMode(self._session, Layer(priority = 5,  clip_launch_buttons = self._matrix.submatrix[:7,:7]))
		self._session.scene_launch_layer = AddLayerMode(self._session, Layer(priority = 5,  scene_launch_buttons = self._matrix.submatrix[7,:7]))
		self._session.stop_clips_layer = AddLayerMode(self._session, Layer(priority = 5,  stop_track_clip_buttons = self._matrix.submatrix[:7,7], stop_all_clips_button = self._grid[7][7]))

		"""self._session_zoom = SessionOverviewComponent(name = 'Session_Overview', session_ring = self._session_ring, enable_skinning = True)
		self._session_zoom.layer = Layer(priority = 5, button_matrix = self._matrix.submatrix[:7,:7])
		self._session_zoom.set_enabled(False)

		self._session_modes = ModesComponent(name = 'Session_Modes')
		self._session_modes.add_mode('disabled', [self._session,
														self._session.clip_launch_layer,
														self._session.scene_launch_layer,
														self._session_navigation,
														self._session_navigation.scroll_navigation_layer])
		self._session_modes.add_mode('enabled', [self._session,
														self._session.scene_launch_layer,
														self._session_zoom,
														self._session_navigation,
														self._session_navigation.page_navigation_layer],
														behaviour = DefaultedBehaviour())
		self._session_modes.layer = Layer(priority = 5, enabled_button = self._grid[7][7])
		self._session_modes.selected_mode = 'disabled'
		self._session_modes.set_enabled(False)"""



	def _setup_mixer_control(self):
		self._mixer = OhmMixerComponent(name = 'Mixer', tracks_provider = self._session_ring, track_assigner = SimpleTrackAssigner(), invert_mute_feedback = True, auto_name = True, enable_skinning = True)
		#self._mixer.layer = Layer(priority = 5, volume_controls = self._fader_matrix.submatrix[:7, :], prehear_volume_control = self._dial[15], crossfader_control = self._crossfader)
		self._mixer.layer = Layer(priority = 5, solo_buttons = self._button_matrix.submatrix[:7,:])
		"""self._mixer.master_strip().layer = Layer(priority = 5, volume_control = self._fader[7], select_button = self._button[7])
		self._mixer.mix_layer = AddLayerMode(self._mixer, Layer(priority = 5, mute_buttons = self._matrix.submatrix[:7,5],
													solo_buttons = self._matrix.submatrix[:7,6],
													arm_buttons = self._matrix.submatrix[:7,7],
													send_controls = self._dial_matrix.submatrix[:,:2],
													pan_controls = self._dial_matrix.submatrix[:7,2:],
													track_select_buttons = self._button_matrix.submatrix[:7,:],))
		self._mixer.dj_layer = AddLayerMode(self._mixer, Layer(priority = 5, mute_buttons = self._matrix.submatrix[:7,5],
													crossfade_toggles = self._matrix.submatrix[:7,6],
													end_pan_controls = self._dial_matrix.submatrix[:3,3],
													eq_gain_controls = self._dial_matrix.submatrix[:,:3],
													track_select_buttons = self._button_matrix.submatrix[:7,:],))
		self._mixer.instrument_layer = AddLayerMode(self._mixer, Layer(priority = 5,
													instrument_send_controls = self._dial_matrix.submatrix[:,2:],
													arming_track_select_buttons = self._button_matrix.submatrix[:7,:]))
		"""


	def _setup_instrument(self):
		self._grid_resolution = GridResolution()

		self._c_instance.playhead.enabled = True
		self._playhead_element = PlayheadElement(self._c_instance.playhead)
		#self._playhead_element.reset()

		#quantgrid = ButtonMatrixElement([self._base_grid._orig_buttons[2][4:8], self._base_grid._orig_buttons[3][4:7]])

		self._drum_group_finder = PercussionInstrumentFinder(device_parent=self.song.view.selected_track)

		self._instrument = OhmMonoInstrumentComponent(name = 'InstrumentModes', script = self, skin = self._skin, drum_group_finder = self._drum_group_finder, grid_resolution = self._grid_resolution, settings = DEFAULT_INSTRUMENT_SETTINGS, device_provider = self._device_provider, parent_task_group = self._task_group)
		self._instrument.layer = Layer(priority = 5, shift_button = self._livid)
		self._instrument.audioloop_layer = LayerMode(self._instrument, Layer(priority = 5, loop_selector_matrix = self._matrix))

		self._instrument.keypad_options_layer = AddLayerMode(self._instrument, Layer(priority = 5,
									scale_up_button = self._menu[0],
									scale_down_button = self._menu[3],
									offset_up_button = self._menu[1],
									offset_down_button = self._menu[4],
									vertical_offset_up_button = self._menu[2],
									vertical_offset_down_button = self._menu[5],))
		self._instrument.drumpad_options_layer = AddLayerMode(self._instrument, Layer(priority = 5,
									scale_up_button = self._menu[0],
									scale_down_button = self._menu[3],
									drum_offset_up_button = self._menu[1],
									drum_offset_down_button = self._menu[4],
									drumpad_mute_button = self._menu[2],
									drumpad_solo_button = self._menu[5],))

		self._instrument._keypad.octave_toggle_layer = AddLayerMode(self._instrument._keypad, Layer(priority = 5)) #, offset_shift_toggle = self._livid))
		self._instrument._drumpad.octave_toggle_layer = AddLayerMode(self._instrument._drumpad, Layer(priority = 5)) #, offset_shift_toggle = self._livid))

		self._instrument._keypad.main_layer = LayerMode(self._instrument._keypad, Layer(priority = 5, keypad_matrix = self._matrix.submatrix[:,:]))
		self._instrument._keypad.select_layer = LayerMode(self._instrument._keypad, Layer(priority = 5, keypad_select_matrix = self._matrix.submatrix[:, :]))
		self._instrument._keypad.split_layer = LayerMode(self._instrument._keypad, Layer(priority = 5, keypad_matrix = self._matrix.submatrix[:, 2:4]))
		self._instrument._keypad.split_select_layer = LayerMode(self._instrument._keypad, Layer(priority = 5, keypad_select_matrix = self._matrix.submatrix[:, 2:4]))

		self._instrument._keypad.sequencer_layer = AddLayerMode(self._instrument._keypad, Layer(priority = 5, playhead = self._playhead_element, sequencer_matrix = self._matrix.submatrix[:, :4]))
		self._instrument._keypad.sequencer_shift_layer = AddLayerMode(self._instrument._keypad, Layer(priority = 5, loop_selector_matrix = self._matrix.submatrix[:, :4], quantization_buttons = self._matrix.submatrix[:8, 1:2],)) #follow_button = self._pad[15]))

		self._instrument._drumpad.main_layer = LayerMode(self._instrument._drumpad, Layer(priority = 5, drumpad_matrix = self._matrix.submatrix[:,4:], sequencer_matrix = self._matrix.submatrix[:, :2], loop_selector_matrix = self._matrix.submatrix[:, 3:4], playhead = self._playhead_element, quantization_buttons = self._matrix.submatrix[:, 2:3]))
		self._instrument._drumpad.select_layer = LayerMode(self._instrument._drumpad, Layer(priority = 5, drumpad_select_matrix = self._matrix.submatrix[:,4:],  sequencer_matrix = self._matrix.submatrix[:, :2], loop_selector_matrix = self._matrix.submatrix[:, 3:4], playhead = self._playhead_element, quantization_buttons = self._matrix.submatrix[:, 2:3]))
		self._instrument._drumpad.split_layer = LayerMode(self._instrument._drumpad, Layer(priority = 5, drumpad_matrix = self._matrix.submatrix[:4, 4:],))
		self._instrument._drumpad.split_select_layer = LayerMode(self._instrument._drumpad, Layer(priority = 5, drumpad_select_matrix = self._matrix.submatrix[:4,4:]))

		self._instrument._drumpad.sequencer_layer = AddLayerMode(self._instrument._drumpad, Layer(priority = 5, playhead = self._playhead_element, sequencer_matrix = self._matrix.submatrix[:, :4]))
		self._instrument._drumpad.sequencer_shift_layer = AddLayerMode(self._instrument._drumpad, Layer(priority = 5, loop_selector_matrix = self._matrix.submatrix[4:8, :2], quantization_buttons = self._matrix.submatrix[4:8, 2:],)) #follow_button = self._pad[31]))

		self._instrument._selected_session._keys_layer = LayerMode(self._instrument._selected_session, Layer(priority = 5, clip_launch_buttons = self._matrix.submatrix[:, :2]))
		self._instrument._selected_session._drum_layer = LayerMode(self._instrument._selected_session, Layer(priority = 5, clip_launch_buttons = self._matrix.submatrix[4:8, :]))

		self._instrument._main_modes = ModesComponent(parent = self._instrument, name = 'InstrumentModes')
		self._instrument._main_modes.add_mode('disabled', [])
		self._instrument._main_modes.add_mode('drumpad', [self._instrument._drumpad, self._instrument._drumpad.main_layer, self._instrument.drumpad_options_layer])
		self._instrument._main_modes.add_mode('drumpad_split', [self._instrument._drumpad, self._instrument._drumpad.split_layer, self._instrument._selected_session, self._instrument._selected_session._drum_layer])
		self._instrument._main_modes.add_mode('drumpad_sequencer', [self._instrument._drumpad, self._instrument._drumpad.sequencer_layer, self._instrument._drumpad.split_layer])
		self._instrument._main_modes.add_mode('drumpad_shifted', [self._instrument._drumpad, self._instrument._drumpad.select_layer, self._instrument.drumpad_options_layer, self._instrument._drumpad.octave_toggle_layer])
		self._instrument._main_modes.add_mode('drumpad_split_shifted', [ self._instrument._drumpad, self._instrument._drumpad.split_select_layer, self._instrument.drumpad_options_layer, self._instrument._drumpad.octave_toggle_layer, self._instrument._selected_session, self._instrument._selected_session._drum_layer])
		self._instrument._main_modes.add_mode('drumpad_sequencer_shifted', [self._instrument._drumpad, self._instrument._drumpad.split_select_layer, self._instrument._drumpad.sequencer_shift_layer, self._instrument.drumpad_options_layer, self._instrument._drumpad.octave_toggle_layer])
		self._instrument._main_modes.add_mode('keypad', [self._instrument._keypad, self._instrument._keypad.main_layer, self._instrument.keypad_options_layer])
		self._instrument._main_modes.add_mode('keypad_split', [self._instrument._keypad, self._instrument._keypad.split_layer, self._instrument._selected_session, self._instrument._selected_session._keys_layer])
		self._instrument._main_modes.add_mode('keypad_sequencer', [self._instrument._keypad, self._instrument._keypad.sequencer_layer, self._instrument._keypad.split_layer], )
		self._instrument._main_modes.add_mode('keypad_shifted', [self._instrument._keypad, self._instrument._keypad.select_layer, self._instrument.keypad_options_layer, self._instrument._keypad.octave_toggle_layer])
		self._instrument._main_modes.add_mode('keypad_split_shifted', [self._instrument._keypad, self._instrument._keypad.split_select_layer, self._instrument.keypad_options_layer, self._instrument._keypad.octave_toggle_layer, self._instrument._selected_session, self._instrument._selected_session._keys_layer])
		self._instrument._main_modes.add_mode('keypad_sequencer_shifted', [self._instrument._keypad, self._instrument._keypad.split_select_layer, self._instrument._keypad.sequencer_shift_layer, self._instrument.keypad_options_layer, self._instrument._keypad.octave_toggle_layer])
		self._instrument._main_modes.add_mode('audioloop', [self._instrument.audioloop_layer])
		#self._instrument.register_component(self._instrument._main_modes)
		self._instrument.set_enabled(False)




	def _setup_modes(self):

		self._main_modes = ModesComponent(name = 'MainModes')
		self._main_modes.add_mode('disabled', [self._background])
		self._main_modes.add_mode('Mix', [self._mixer, self._session, self._session.stop_clips_layer, self._session.clip_launch_layer, self._session.scene_launch_layer, self._session_navigation, self._session_navigation.scroll_navigation_layer])
		self._main_modes.add_mode('Instrument', [self._instrument])
		self._main_modes.selected_mode = 'disabled'
		self._main_modes.layer = Layer(priority = 5, Mix_button = self._shift_l, Instrument_button = self._shift_r)
		self._main_modes.set_enabled(True)


	def reset_controlled_track(self, track = None, *a):
		if not track:
			track = self.song.view.selected_track
		self.set_controlled_track(track)


	def set_controlled_track(self, track = None, *a):
		if isinstance(track, Live.Track.Track):
			super(OhmModes, self).set_controlled_track(track)
		else:
			self.release_controlled_track()

	@listens('device')
	def _on_device_changed(self):
		debug('_on_device_changed')
		self.update()

	def update(self):
		self.reset_controlled_track()
		self.set_feedback_channels(FEEDBACK_CHANNELS)
		super(OhmModes, self).update()
class Oxygen_Pro(ControlSurface):
    def __init__(self, *a, **k):
        super(Oxygen_Pro, self).__init__(*a, **k)
        with self.component_guard():
            self._elements = Elements()
            with inject(element_container=const(self._elements)).everywhere():
                self._create_transport()
                self._create_undo_redo()
                self._create_device_parameters()
                self._create_session()
                self._create_mixer()
                self._create_record_modes()
        self.__on_main_view_changed.subject = self.application.view

    def _create_transport(self):
        self._transport = TransportComponent(name=u'Transport',
                                             is_enabled=False,
                                             layer=Layer(
                                                 loop_button=u'loop_button',
                                                 stop_button=u'stop_button',
                                                 play_button=u'play_button'))
        self._transport.set_enabled(True)

    def _create_undo_redo(self):
        self._undo_redo = UndoRedoComponent(
            name=u'Undo_Redo',
            is_enabled=False,
            layer=Layer(undo_button=u'back_button'))
        self._undo_redo.set_enabled(True)

    def _create_device_parameters(self):
        self._device_parameters = SimpleDeviceParameterComponent(
            name=u'Device_Parameters',
            is_enabled=False,
            layer=Layer(parameter_controls=u'knobs'))
        self._device_parameters.set_enabled(True)

    def _create_session(self):
        self._session_ring = SessionRingComponent(name=u'Session_Ring',
                                                  num_tracks=SESSION_WIDTH,
                                                  num_scenes=SESSION_HEIGHT)
        self._session = SessionComponent(
            name=u'Session',
            is_enabled=False,
            session_ring=self._session_ring,
            layer=Layer(clip_launch_buttons=u'pads',
                        scene_launch_buttons=u'scene_launch_buttons',
                        scene_encoder=u'encoder'))
        self._session.selected_scene().set_launch_button(
            self._elements.encoder_push_button)
        self._session.set_enabled(True)
        self._session_navigation = SessionNavigationComponent(
            name=u'Session_Navigation',
            is_enabled=False,
            session_ring=self._session_ring,
            layer=Layer(left_button=u'bank_left_button',
                        right_button=u'bank_right_button'))
        self._session_navigation.set_up_button(self._elements.rewind_button)
        self._session_navigation.set_down_button(
            self._elements.fastforward_button)
        self._session_navigation.set_enabled(True)

    def _create_mixer(self):
        self._mixer = MixerComponent(name=u'Mixer',
                                     is_enabled=False,
                                     auto_name=True,
                                     tracks_provider=self._session_ring,
                                     track_assigner=SimpleTrackAssigner(),
                                     layer=Layer(volume_controls=u'faders',
                                                 arm_buttons=u'fader_buttons'))
        self._mixer.master_strip().set_volume_control(
            self._elements.master_fader)
        self._mixer.set_enabled(True)

    def _create_record_modes(self):
        self._session_record = SessionRecordingComponent(
            name=u'Session_Record',
            is_enabled=False,
            layer=Layer(record_button=u'record_button'))
        self._record_modes = ModesComponent(name=u'Record_Modes')
        self._record_modes.add_mode(u'session',
                                    EnablingMode(self._session_record))
        self._record_modes.add_mode(
            u'arrange',
            AddLayerMode(self._transport,
                         layer=Layer(record_button=u'record_button')))
        self.__on_main_view_changed()

    @listens(u'is_view_visible', u'Session')
    def __on_main_view_changed(self):
        if self.application.view.is_view_visible(u'Session'):
            self._record_modes.selected_mode = u'session'
        else:
            self._record_modes.selected_mode = u'arrange'