def __init__(self, set_session_highlight = nop, *a, **k):
     self._decorator_factory = TrackDecoratorFactory()
     super(SessionRingTrackProvider, self).__init__(set_session_highlight=partial(set_session_highlight, include_rack_chains=True), tracks_to_use=self._decorated_tracks_to_use, *a, **k)
     self._artificially_selected_item = None
     self._selected_item_when_item_artificially_selected = None
     self._update_listeners()
     self._selected_track = self.register_disconnectable(SelectedMixerTrackProvider())
     self._on_selected_item_changed.subject = self._selected_track
     self._track_assigner = RightAlignTracksTrackAssigner(song=self.song)
 def _create_mixer(self):
     self._mixer = MixerComponent(
         name=u'Mixer',
         is_enabled=False,
         auto_name=True,
         tracks_provider=self._session_ring,
         track_assigner=RightAlignTracksTrackAssigner(
             song=self.song, include_master_track=True),
         invert_mute_feedback=True,
         layer=Layer(volume_controls=u'sliders',
                     volume_leds=u'slider_leds'))
     self._mixer.set_enabled(True)
     self._mixer_button_modes = DisplayingNavigatableModesComponent(
         name=u'Mixer_Button_Modes')
     self._mixer_button_modes.add_mode(
         u'mute_solo',
         AddLayerMode(
             self._mixer,
             Layer(mute_buttons=u'mixer_soft_button_row_0',
                   solo_buttons=u'mixer_soft_button_row_1')))
     self._mixer_button_modes.add_mode(
         u'monitor_arm',
         AddLayerMode(
             self._mixer,
             Layer(monitoring_state_buttons=u'mixer_soft_button_row_0',
                   arm_buttons=u'mixer_soft_button_row_1')))
     self._mixer_button_modes.layer = Layer(
         prev_mode_button=u'mixer_up_button',
         next_mode_button=u'mixer_down_button',
         display_1=u'mixer_display_1',
         display_2=u'mixer_display_2',
         color_field_1=u'mixer_color_field_1',
         color_field_2=u'mixer_color_field_2')
     self._mixer_button_modes.selected_mode = u'mute_solo'
Example #3
0
 def _create_mixer(self):
     self._session_ring = SessionRingComponent(
         is_enabled=False,
         num_tracks=NUM_TRACK_CONTROLS,
         num_scenes=NUM_SCENE_CONTROLS,
         tracks_to_use=lambda: tuple(self.song.visible_tracks) + tuple(
             self.song.return_tracks) + (self.song.master_track, ),
         name=b'Session_Ring')
     self._mixer = MixerComponent(
         is_enabled=False,
         tracks_provider=self._session_ring,
         track_assigner=RightAlignTracksTrackAssigner(
             song=self.song, include_master_track=True),
         channel_strip_component_type=ChannelStripComponent,
         name=b'Mixer',
         layer=Layer(volume_controls=b'volume_sliders',
                     pan_controls=b'pan_sliders',
                     solo_buttons=b'solo_buttons',
                     mute_buttons=b'mute_buttons',
                     arm_buttons=b'arm_buttons',
                     send_controls=b'send_encoders',
                     track_type_controls=b'track_type_controls',
                     output_meter_left_controls=b'meter_controls_left',
                     output_meter_right_controls=b'meter_controls_right',
                     track_select_buttons=b'track_select_buttons',
                     track_name_displays=b'track_name_displays',
                     num_sends_control=b'num_sends_control',
                     track_color_controls=b'tui_track_color_controls',
                     oled_display_style_controls=
                     b'oled_display_style_controls_bank_1',
                     track_name_or_volume_value_displays=
                     b'track_name_or_volume_value_displays',
                     crossfade_assign_controls=b'crossfade_assign_controls',
                     crossfader_control=b'crossfader',
                     solo_mute_buttons=b'solo_mute_buttons',
                     volume_value_displays=b'volume_value_displays',
                     pan_value_displays=b'pan_value_displays',
                     send_value_displays=b'send_value_displays'))
     if not self.is_force:
         self._mixer.layer += Layer(
             selected_track_arm_button=b'selected_track_arm_button',
             selected_track_mute_button=b'selected_track_mute_button',
             selected_track_solo_button=b'selected_track_solo_button')
     else:
         self._mixer.layer += Layer(
             master_button=b'master_button',
             physical_track_color_controls=b'physical_track_color_controls')
Example #4
0
class SessionRingTrackProvider(SessionRingComponent, ItemProvider):
    @depends(set_session_highlight=const(nop))
    def __init__(self, set_session_highlight=nop, *a, **k):
        self._decorator_factory = TrackDecoratorFactory()
        super(SessionRingTrackProvider, self).__init__(
            set_session_highlight=partial(set_session_highlight,
                                          include_rack_chains=True),
            tracks_to_use=self._decorated_tracks_to_use,
            *a,
            **k)
        self._artificially_selected_item = None
        self._selected_item_when_item_artificially_selected = None
        self._update_listeners()
        self._selected_track = self.register_disconnectable(
            SelectedMixerTrackProvider())
        self._on_selected_item_changed.subject = self._selected_track
        self._track_assigner = RightAlignTracksTrackAssigner(song=self.song)
        return

    def scroll_into_view(self, mixable):
        mixable_index = self.tracks_to_use().index(mixable)
        new_offset = self.track_offset
        if mixable_index >= self.track_offset + self.num_tracks:
            new_offset = mixable_index - self.num_tracks + 1
        elif mixable_index < self.track_offset:
            new_offset = mixable_index
        self.track_offset = new_offset

    def _get_selected_item(self):
        track_or_chain = self._selected_track.selected_mixer_track
        if liveobj_valid(self._artificially_selected_item):
            track_or_chain = self._artificially_selected_item
        return self._decorator_factory.decorated_objects.get(
            track_or_chain, track_or_chain)

    def _set_selected_item(self, item):
        self._artificially_selected_item = None
        self._selected_track.selected_mixer_track = item
        self.notify_selected_item()
        return

    selected_item = property(_get_selected_item, _set_selected_item)

    @property
    def items(self):
        return self._track_assigner.tracks(self)

    def move(self, tracks, scenes):
        super(SessionRingTrackProvider, self).move(tracks, scenes)
        if tracks != 0:
            self._ensure_valid_track_offset()
            self.notify_items()

    def _update_track_list(self):
        super(SessionRingTrackProvider, self)._update_track_list()
        self._ensure_valid_track_offset()
        self.notify_items()
        self._update_listeners()

    def _decorated_tracks_to_use(self):
        return self._decorator_factory.decorate_all_mixer_tracks(
            get_all_mixer_tracks(self.song))

    def controlled_tracks(self):
        return [
            getattr(track, b'proxied_object', track) for track in self.items
        ]

    def set_selected_item_without_updating_view(self, item):
        all_tracks = get_all_mixer_tracks(self.song)
        if item in all_tracks:
            self._artificially_selected_item = item
            self._selected_item_when_item_artificially_selected = self.song.view.selected_track
            self.notify_selected_item()

    def synchronize_selection_with_live_view(self):
        """
        Makes sure the currently selected item is also selected in Live.
        """
        if self._artificially_selected_item:
            self.selected_item = self._artificially_selected_item

    @listens_group(b'is_showing_chains')
    def _on_is_showing_chains_changed(self, _):
        self._update_track_list()

    @listens_group(b'chains')
    def _on_chains_changed(self, _):
        if not self.song.view.selected_track.can_show_chains:
            self.selected_item = self.song.view.selected_track
        self._update_track_list()

    @listens_group(b'devices')
    def _on_devices_changed(self, _):
        self._update_track_list()

    def _update_listeners(self):
        def flattened_list_of_instruments(instruments):
            return list(flatten(instruments))

        tracks = self.song.tracks
        self._on_devices_changed.replace_subjects(tracks)
        chain_listenable_tracks = [
            track for track in tracks
            if isinstance(track, Live.Track.Track) and track
        ]
        instruments_with_chains = flattened_list_of_instruments([
            get_racks_recursive(track) for track in chain_listenable_tracks
            if track
        ])
        tracks_and_chains = chain_listenable_tracks + instruments_with_chains
        self._on_is_showing_chains_changed.replace_subjects(tracks_and_chains)
        self._on_chains_changed.replace_subjects(instruments_with_chains)
        self._on_instrument_return_chains_changed.replace_subjects(
            instruments_with_chains)

    def _ensure_valid_track_offset(self):
        max_index = len(self.tracks_to_use()) - 1
        clamped_offset = min(self.track_offset, max_index)
        if clamped_offset != self.track_offset:
            self.track_offset = clamped_offset

    @listens_group(b'return_chains')
    def _on_instrument_return_chains_changed(self, _):
        self._update_track_list()

    @listens(b'selected_mixer_track')
    def _on_selected_item_changed(self, _):
        if liveobj_changed(self._selected_item_when_item_artificially_selected,
                           self.song.view.selected_track):
            self._artificially_selected_item = None
        self.notify_selected_item()
        return