Пример #1
0
 def disconnect(self):
     self._do_uncombine()
     if LC2Sysex.l9():
         task = self._tasks.find(self._on_time_changed)
         self._tasks.remove(task)
     else:
         self._unregister_timer_callback(self._on_time_changed)
     self.song().remove_tempo_listener(self._on_tempo_changed)
     ControlSurface.disconnect(self)
     LC2Sysex.release_attributes()
     LC2SessionBank.release_attributes()
 def __init__(self, num_tracks, num_scenes):
     self._scene_count = LC2Sysex.l9() and -1 or 0
     self._num_tracks = num_tracks
     self._height = num_scenes
     self._width = num_tracks
     self._snapshot_bank = LC2SessionBank()
     SessionComponent.__init__(self, num_tracks, num_scenes)
     LC2SceneComponent.set_get_offsets(self._get_offset)
     LC2ChannelStripComponent.set_get_offsets(self._get_offset)
     LC2ClipSlotComponent.set_get_offsets(self._get_offset)
     LC2ChannelStripComponent.set_playing_slot_changed(self._playing_slot_changed)
Пример #3
0
    def do_setup(self):
        if LC2Sysex.l9():
            self._set_suppress_rebuild_requests(True)
        else:
            self.set_suppress_rebuild_requests(True)
        self._suppress_session_highlight = True
        self._suppress_send_midi = True
        LC2Sysex.set_midi_callback(self._send_midi)
        LC2SessionBank.set_song(self.song)
        LC2SessionBank.set_timer_callback(self.schedule_message)
        self._session = LC2SessionComponent(8, 12)
        self._mixer = LC2MixerComponent(8)
        self._session.set_mixer(self._mixer)
        if LC2Sysex.l9():
            self.set_highlighting_session_component(self._session)
        bank_buttons = [ ButtonElement(False, MIDI_NOTE_TYPE, 0, 40 + i) for i in range(4) ]
        self._session.set_scene_bank_buttons(bank_buttons[0], bank_buttons[1])
        self._session.set_track_bank_buttons(bank_buttons[2], bank_buttons[3])
        mixer_controls = [ SliderElement(MIDI_CC_TYPE, 0, i) for i in range(24) ]
        mixer_d_controls = [ LC2ParameterElement(MIDI_CC_TYPE, 0, i + 64) for i in range(32) ]
        toggle_controls = [ ButtonElement(True, MIDI_NOTE_TYPE, 0, i + 1) for i in range(24) ]
        cf = [ ButtonElement(True, MIDI_NOTE_TYPE, 0, i + 30) for i in range(8) ]
        mt = [ ButtonElement(True, MIDI_NOTE_TYPE, 0, i + 50) for i in range(8) ]
        self._mixer.master_strip().set_volume_control(SliderElement(MIDI_CC_TYPE, 0, 33))
        self._mixer.master_strip().set_pan_control(SliderElement(MIDI_CC_TYPE, 0, 34))
        self._mixer.set_prehear_volume_control(SliderElement(MIDI_CC_TYPE, 0, 35))
        self._mixer.set_crossfader_control(SliderElement(MIDI_CC_TYPE, 0, 40))
        for i in range(8):
            idx = i * 3
            ch = self._mixer.channel_strip(i)
            ch.set_invert_mute_feedback(True)
            ch.set_mute_button(toggle_controls[idx])
            ch.set_solo_button(toggle_controls[idx + 1])
            ch.set_arm_button(toggle_controls[idx + 2])
            ch.set_volume_control(mixer_controls[idx])
            ch.set_pan_control(mixer_controls[idx + 1])
            ch.set_send_control(mixer_controls[idx + 2])
            ch.set_crossfade_toggle(cf[i])
            ch.set_monitor_toggle(mt[i])
            ch.set_device_controls(tuple(mixer_d_controls[i * 4:i * 4 + 4]))

        self._modulator = LC2Modulator()
        self.set_device_component(self._modulator)
        device_controls = [ LC2ParameterElement(MIDI_CC_TYPE, 1, i, True) for i in range(16) ]
        self._modulator.set_parameter_controls(tuple(device_controls))
        device_buttons = [ ButtonElement(False, MIDI_NOTE_TYPE, 1, i) for i in range(4) ]
        self._modulator.set_on_off_button(device_buttons[0])
        self._modulator.set_lock_button(device_buttons[1])
        self._modulator.set_bank_nav_buttons(device_buttons[2], device_buttons[3])
        self._sequencer = LC2Sequencer()
        self._session.set_sequencer(self._sequencer)
        self._transport = LC2TransportComponent()
        tbuttons = [ ButtonElement(True, MIDI_NOTE_TYPE, 0, 110 + i) for i in range(12) ]
        self._transport.set_stop_button(tbuttons[0])
        self._transport.set_play_button(tbuttons[1])
        self._transport.set_record_button(tbuttons[2])
        self._transport.set_overdub_button(tbuttons[3])
        self._transport.set_back_to_arranger_button(tbuttons[4])
        self._transport.set_follow_button(tbuttons[5])
        self._transport.set_metronome_button(tbuttons[6])
        self._transport.set_tap_tempo_button(tbuttons[7])
        self._transport.set_tempo_buttons(tbuttons[9], tbuttons[8])
        self._transport.set_launch_quant_button(SliderElement(MIDI_CC_TYPE, 0, 120))
        self._transport.set_record_quant_button(SliderElement(MIDI_CC_TYPE, 0, 121))
        self._last_time = ''
        if LC2Sysex.l9():

            def wrapper(delta):
                self._on_time_changed()
                return Task.RUNNING

            self._tasks.add(Task.FuncTask(wrapper, self._on_time_changed))
        else:
            self._register_timer_callback(self._on_time_changed)
        self.song().add_tempo_listener(self._on_tempo_changed)
        for component in self.components:
            component.set_enabled(False)

        if LC2Sysex.l9():
            self._set_suppress_rebuild_requests(False)
        else:
            self.set_suppress_rebuild_requests(False)