コード例 #1
0
ファイル: ohm64.py プロジェクト: Adamdma/monomodular
	def _setup_transport_control(self):
		is_momentary = True # We'll only be using momentary buttons here
		transport = TransportComponent() #Instantiate a Transport Component
		"""set up the buttons"""
		transport.set_play_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 69)) #ButtonElement(is_momentary, msg_type, channel, identifier) Note that the MIDI_NOTE_TYPE constant is defined in the InputControlElement module
		transport.set_stop_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 70))
		#transport.set_record_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 66))
		#transport.set_overdub_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 68))
		#transport.set_nudge_buttons(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80), ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 73)) #(up_button, down_button)
		#transport.set_tap_tempo_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80))
		#transport.set_metronome_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80)) #For some reason, in Ver 7.x.x this method's name has no trailing "e" , and must be called as "set_metronom_button()"...
		#transport.set_loop_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 82))
		#transport.set_punch_buttons(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 85), ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 87)) #(in_button, out_button)
		#transport.set_seek_buttons(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 90), ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 92)) # (ffwd_button, rwd_button)
		#"""set up the sliders"""
		#transport.set_tempo_control(SliderElement(MIDI_CC_TYPE, CHANNEL, 26), SliderElement(MIDI_CC_TYPE, CHANNEL, 25)) #(control, fine_control)
		#transport.set_song_position_control(SliderElement(MIDI_CC_TYPE, CHANNEL, 24))
		
		device_param_controls = []
		effects_knob_cc = [17,16,9,8,19,18,11,10]
		device = DeviceComponent()
		for index in range(8):
			device_param_controls.append(EncoderElement(MIDI_CC_TYPE, 0, effects_knob_cc[index], Live.MidiMap.MapMode.absolute))
		device.set_parameter_controls(tuple(device_param_controls))
		self.set_device_component(device)
コード例 #2
0
 def __init__(self, *a, **k):
     super(MPK225, self).__init__(*a, **k)
     with self.component_guard():
         midimap = MidiMap()
         drum_rack = DrumRackComponent(name="Drum_Rack", is_enabled=False, layer=Layer(pads=midimap["Drum_Pads"]))
         drum_rack.set_enabled(True)
         transport = TransportComponent(
             name="Transport",
             is_enabled=False,
             layer=Layer(
                 play_button=midimap["Play"],
                 record_button=midimap["Record"],
                 stop_button=midimap["Stop"],
                 seek_forward_button=midimap["Forward"],
                 seek_backward_button=midimap["Backward"],
                 loop_button=midimap["Loop"],
             ),
         )
         transport.set_enabled(True)
         device = DeviceComponent(
             name="Device", is_enabled=False, layer=Layer(parameter_controls=midimap["Encoders"])
         )
         device.set_enabled(True)
         self.set_device_component(device)
         self._device_selection_follows_track_selection = True
コード例 #3
0
    def disconnect(self):
        self._unregister_timer_callback(self._on_custom_timer)
        TransportComponent.disconnect(self)

        self.song().remove_is_playing_listener(self._on_playing_status_changed)
        self.song().remove_record_mode_listener(self._on_record_status_changed)
        self.song().remove_session_record_listener(self._on_session_record_status_changed)
        self.song().remove_session_record_status_listener(self._on_session_record_status_changed)
        self.song().remove_session_automation_record_listener(self._on_record_automation_changed)
        self.song().remove_loop_listener(self._on_loop_status_changed)
        self.song().remove_midi_recording_quantization_listener(self._on_rec_quantisation_changed)
        self.song().remove_metronome_listener(self._on_metronome_changed)
        self.song().remove_current_song_time_listener(self._on_song_time_changed)
        self.song().remove_nudge_down_listener(self._on_nudge_down_changed)
        self.song().remove_nudge_up_listener(self._on_nudge_up_changed)        
        
        self.set_shift_button(None)
        self.set_main_view_button(None)
        self.set_detail_view_button(None)
        self.set_undo_button(None)
        self.set_metronome_button(None)
        self.set_tap_tempo_button(None)
        self.set_quant_toggle_button(None)
        self.set_nudge_buttons(None, None)
        self.set_stop_button(None, None)
        self.set_play_button(None, None)
        self.set_loop_button(None, None)
        self.set_record_button(None, None)
        self.set_session_record_button(None)
        self.set_record_automation_button(None)
        self.set_dummy1_button(None)
        self.set_dummy2_button(None)
        self.set_dummy7_button(None)
        self.set_dummy8_button(None)
コード例 #4
0
ファイル: MiniCommand.py プロジェクト: jmamma/mididuino
 def __init__(self, c_instance):
     ControlSurface.__init__(self, c_instance)
     transport = TransportComponent()
     transport.set_play_button(ButtonElement(True, 0, ABLETON["GENERAL_CHANNEL"], ABLETON["START_NOTE"]))
     transport.set_stop_button(ButtonElement(True, 0, ABLETON["GENERAL_CHANNEL"], ABLETON["STOP_NOTE"]))
     self.log_message("MiniCommand surface")
     self.get_track_name(0)
コード例 #5
0
ファイル: AumPC20.py プロジェクト: Adamdma/monomodular
	def _setup_custom_components(self):
		is_momentary = True
		master_select_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 80)
		self._master_select_button = master_select_button
		master_select_button.name = 'Master_Select_Button'
		select_buttons = []
		self._select_buttons = []
		arm_buttons = []
		sliders = []
		for track in range(8):
			select_buttons.append(FlashingButtonElement(is_momentary, MIDI_NOTE_TYPE, track, 51, self))
			self._select_buttons.append(select_buttons[track])
			arm_buttons.append(ButtonElement(is_momentary, MIDI_NOTE_TYPE, track, 48))
			if track is 7:
				self._user3 = arm_buttons[track]
			sliders.append(MonoEncoderElement2(MIDI_CC_TYPE, track, 7, Live.MidiMap.MapMode.absolute, 'Slider_' + str(track), track, self))
			#sliders.append(MonoEncoderElement2(MIDI_CC_TYPE, track, 7))
			select_buttons[-1].name = str(track) + '_Select_Button'
			arm_buttons[-1].name = str(track) + '_Arm_Button'
			#sliders[-1].name = str(track) + '_Volume_Control'
		transport = TransportComponent()
		transport.name = 'Transport'
		slider_modes = SliderModesComponent(self._mixer, tuple(sliders))
		slider_modes.name = 'Slider_Modes'
		self._shift_modes = ShiftableSelectorComponent(tuple(select_buttons), master_select_button, tuple(arm_buttons), self._matrix, self._session, self._session_zoom, self._mixer, transport, slider_modes, self._send_introduction_message, self)
		self._shift_modes.name = 'Shift_Modes'
		self._shift_modes.set_mode_toggle(self._shift_button)
 def _rwd_value(self, value):
     if not self._rwd_button != None:
         raise AssertionError
         raise value in range(128) or AssertionError
         self.song().current_song_time = self._shift_pressed and 0.0
     else:
         TransportComponent._rwd_value(self, value)
コード例 #7
0
 def __init__(self, sl_surface, display):
     self._support_mkII = False
     self._ts_locked = False
     TransportComponent.__init__(self)
     self._sl = sl_surface
     self._shift_button = None
     self._shift_pressed = False
     self._display = display
     self._stop_button = None
     self._stop_button_pressed = False
     self._stop_button_pressed_time = 0
     self._stop_button_blink = False
     #self._stop_button_double_press = 0
     self._play_button = None
     self._loop_button = None
     self._record_button = None
     self._session_record_button = None
     self._record_automation_button = None
     
     self._nudge_up_button = None
     self._nudge_down_button = None
     
     self._main_view_button = None
     self._detail_view_button = None
     self._detail_view_button_pressed = False
     self._detail_view_button_pressed_time = 0
     
     self._metronome_button = None
     self._led_metronome = False
     self._last_beat = 5
     self._quant_toggle_button = None
     self._last_quant_value = Live.Song.RecordingQuantization.rec_q_eight
     self._clip_quant_values = QUAINTIZATION_TO_BEAT
     self._quant_names = ['Disabled', '1/4', '1/8', '1/8T', '1/8+T', '1/16', '1/16T', '1/16+T', '1/32']
     self._undo_button = None
     self._stop_button_feedback = None
     self._play_button_feedback = None
     self._loop_button_feedback = None  
     self._record_button_feedback = None
     self._dummy1_button = None
     self._dummy2_button = None
     self._dummy7_button = None
     self._dummy8_button = None
     self.song().add_is_playing_listener(self._on_playing_status_changed)
     self.song().add_record_mode_listener(self._on_record_status_changed)
     self.song().add_session_record_listener(self._on_session_record_status_changed)
     self.song().add_session_record_status_listener(self._on_session_record_status_changed)
     self.song().add_session_automation_record_listener(self._on_record_automation_changed)
     self.song().add_loop_listener(self._on_loop_status_changed)
     self.song().add_midi_recording_quantization_listener(self._on_rec_quantisation_changed)
     self.song().add_metronome_listener(self._on_metronome_changed)
     #self.song().add_clip_trigger_quantization_listener(self._on_clip_trigger_quantization_changed)
     self.song().add_current_song_time_listener(self._on_song_time_changed)
     self.song().add_nudge_down_listener(self._on_nudge_down_changed)
     self.song().add_nudge_up_listener(self._on_nudge_up_changed)        
     self._on_rec_quantisation_changed()
     self._update_undo_button_delay = 0
     self._register_timer_callback(self._on_custom_timer)
     return None        
コード例 #8
0
 def _ffwd_value(self, value):
     if not self._shift_pressed:
         TransportComponent._ffwd_value(self, value)
     elif self._ffwd_button.is_momentary():
         self._ffwd_task.kill()
         if value and self.song().can_jump_to_next_cue:
             self.song().jump_to_next_cue()                  
     self.show_transport_values()
 def __init__(self):
     TransportComponent.__init__(self)
     self._shift_button = None
     self._quant_toggle_button = None
     self._shift_pressed = False
     self._last_quant_value = Live.Song.RecordingQuantization.rec_q_eight
     self.song().add_midi_recording_quantization_listener(self._on_quantisation_changed)
     self._on_quantisation_changed()
コード例 #10
0
ファイル: Alesis_VI.py プロジェクト: aumhaa/livepy_diff
 def __init__(self, *a, **k):
     super(Alesis_VI, self).__init__(*a, **k)
     with self.component_guard():
         midimap = MidiMap()
         transport = TransportComponent(name='Transport', is_enabled=False, layer=Layer(play_button=midimap['Play'], stop_button=midimap['Stop'], loop_button=midimap['Loop'], record_button=midimap['Record'], seek_forward_button=midimap['Forward'], seek_backward_button=midimap['Backward']))
         mixer_size = len(midimap['Volume_Encoders'])
         mixer = MixerComponent(mixer_size, name='Mixer', is_enabled=False, layer=Layer(volume_controls=midimap['Volume_Encoders']))
         transport.set_enabled(True)
         mixer.set_enabled(True)
	def disconnect(self):
		TransportComponent.disconnect(self)
		if self._shift_button != None:
			self._shift_button.remove_value_listener(self._shift_value)
			self._shift_button = None
		if self._quant_toggle_button != None:
			self._quant_toggle_button.remove_value_listener(self._quant_toggle_value)
			self._quant_toggle_button = None
		self.song().remove_midi_recording_quantization_listener(self._on_quantisation_changed)
コード例 #12
0
    def __init__(self, parent):
        TransportComponent.__init__(self)
        self.__mainscript__ = parent
        self.tempo_up_button = None
        self.tempo_down_button = None
        self._quant_toggle_button = None

        for index in range(13):
            if self.__mainscript__.song().clip_trigger_quantization is Live.Song.Quantization.values[index]:
                self.quant_index = index
 def __init__(self):
     TransportComponent.__init__(self)
     self._quant_toggle_button = None
     self._last_quant_value = Live.Song.RecordingQuantization.rec_q_eight
     self.song().add_midi_recording_quantization_listener(self._on_quantisation_changed)
     self._on_quantisation_changed()
     self._undo_button = None
     self._redo_button = None
     self._tempo_encoder_control = None
     return None
	def __init__(self, parent):
		TransportComponent.__init__(self)
		self._parent = parent
		self._parent.song().view.add_selected_track_listener(self.get_current_track)
		self.current_track = 0
		self._trackEncoders = []
		self.newTrackEncoder_encoder = None
		self.newDeviceEncoder_encoder = None
		self._tempo_encoder_control = None #added
		self.savedValueToggle = False
コード例 #15
0
ファイル: MPK225.py プロジェクト: aumhaa/livepy_diff
 def __init__(self, *a, **k):
     super(MPK225, self).__init__(*a, **k)
     with self.component_guard():
         midimap = MidiMap()
         drum_rack = DrumRackComponent(name='Drum_Rack', is_enabled=False, layer=Layer(pads=midimap['Drum_Pads']))
         drum_rack.set_enabled(True)
         transport = TransportComponent(name='Transport', is_enabled=False, layer=Layer(play_button=midimap['Play'], record_button=midimap['Record'], stop_button=midimap['Stop'], seek_forward_button=midimap['Forward'], seek_backward_button=midimap['Backward'], loop_button=midimap['Loop']))
         transport.set_enabled(True)
         device = DeviceComponent(name='Device', is_enabled=False, layer=Layer(parameter_controls=midimap['Encoders']), device_selection_follows_track_selection=True)
         device.set_enabled(True)
         self.set_device_component(device)
コード例 #16
0
class BeatStep(ArturiaControlSurface):

    def __init__(self, *a, **k):
        super(BeatStep, self).__init__(*a, **k)
        self._skin = Skin(Colors)
        with self.component_guard():
            self._create_controls()
            self._create_device()
            self._create_session()
            self._create_mixer()
            self._create_transport()

    def _create_controls(self):
        self._device_encoders = ButtonMatrixElement(rows=[ [ EncoderElement(MIDI_CC_TYPE, 0, identifier, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Encoder_%d_%d' % (column_index, row_index)) for column_index, identifier in enumerate(row) ] for row_index, row in enumerate((ENCODER_MSG_IDS[:4], ENCODER_MSG_IDS[8:12])) ])
        self._horizontal_scroll_encoder = EncoderElement(MIDI_CC_TYPE, 0, 75, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Horizontal_Scroll_Encoder')
        self._vertical_scroll_encoder = EncoderElement(MIDI_CC_TYPE, 0, 72, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Vertical_Scroll_Encoder')
        self._volume_encoder = EncoderElement(MIDI_CC_TYPE, 0, 91, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Volume_Encoder')
        self._pan_encoder = EncoderElement(MIDI_CC_TYPE, 0, 17, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Pan_Encoder')
        self._send_a_encoder = EncoderElement(MIDI_CC_TYPE, 0, 77, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Send_A_Encoder')
        self._send_b_encoder = EncoderElement(MIDI_CC_TYPE, 0, 93, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Send_B_Encoder')
        self._send_encoders = ButtonMatrixElement(rows=[[self._send_a_encoder, self._send_b_encoder]])
        self._return_a_encoder = EncoderElement(MIDI_CC_TYPE, 0, 73, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Return_A_Encoder')
        self._return_b_encoder = EncoderElement(MIDI_CC_TYPE, 0, 79, Live.MidiMap.MapMode.relative_smooth_two_compliment, name='Return_B_Encoder')
        self._return_encoders = ButtonMatrixElement(rows=[[self._return_a_encoder, self._return_b_encoder]])
        self._pads = ButtonMatrixElement(rows=[ [ ButtonElement(True, MIDI_NOTE_TYPE, PAD_CHANNEL, identifier, name='Pad_%d_%d' % (col_index, row_index), skin=self._skin) for col_index, identifier in enumerate(row) ] for row_index, row in enumerate(PAD_MSG_IDS) ])
        self._stop_button = ButtonElement(True, MIDI_CC_TYPE, 0, 1, name='Stop_Button')
        self._play_button = ButtonElement(True, MIDI_CC_TYPE, 0, 2, name='Play_Button')

    def _create_device(self):
        self._device = DeviceComponent(name='Device', is_enabled=False, layer=Layer(parameter_controls=self._device_encoders))
        self._device.set_enabled(True)
        self.set_device_component(self._device)
        self._device_selection_follows_track_selection = True

    def _create_session(self):
        self._session = SessionComponent(name='Session', is_enabled=False, num_tracks=self._pads.width(), num_scenes=self._pads.height(), enable_skinning=True, layer=Layer(clip_launch_buttons=self._pads, scene_select_control=self._vertical_scroll_encoder))
        self._session.set_enabled(True)

    def _create_mixer(self):
        self._mixer = MixerComponent(name='Mixer', is_enabled=False, num_returns=2, layer=Layer(track_select_encoder=self._horizontal_scroll_encoder, selected_track_volume_control=self._volume_encoder, selected_track_pan_control=self._pan_encoder, selected_track_send_controls=self._send_encoders, return_volume_controls=self._return_encoders))
        self._mixer.set_enabled(True)

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

    def _collect_setup_messages(self):
        for identifier, hardware_id in izip(ENCODER_MSG_IDS, HARDWARE_ENCODER_IDS):
            self._setup_hardware_encoder(hardware_id, identifier)

        self._setup_hardware_button(HARDWARE_STOP_BUTTON_ID, 1, msg_type='cc')
        self._setup_hardware_button(HARDWARE_PLAY_BUTTON_ID, 2, msg_type='cc')
        for hardware_id, identifier in izip(HARDWARE_PAD_IDS, chain(*PAD_MSG_IDS)):
            self._setup_hardware_button(hardware_id, identifier, PAD_CHANNEL, msg_type='note')
 def disconnect(self):
     TransportComponent.disconnect(self)
     if self._tempo_encoder_control != None:
         self._tempo_encoder_control.remove_value_listener(self._tempo_encoder_value)
         self._tempo_encoder_control = None
     if self._tempo_down_button != None:
         self._tempo_down_button.remove_value_listener(self._tempo_down_value)
         self._tempo_down_button = None
     if self._tempo_up_button != None:
         self._tempo_up_button.remove_value_listener(self._tempo_up_value)
         self._tempo_up_button = None
 def disconnect(self):
     TransportComponent.disconnect(self)
     if self._undo_button != None:
         self._undo_button.remove_value_listener(self._undo_value)
         self._undo_button = None
     if self._redo_button != None:
         self._redo_button.remove_value_listener(self._redo_value)
         self._redo_button = None
     if self._bts_button != None:
         self._bts_button.remove_value_listener(self._bts_value)
         self._bts_button = None
コード例 #19
0
 def __init__(self, *a, **k):
     super(MPK249, self).__init__(*a, **k)
     with self.component_guard():
         midimap = MidiMap()
         drum_rack = DrumRackComponent(name='Drum_Rack', is_enabled=False, layer=Layer(pads=midimap['Drum_Pads']))
         drum_rack.set_enabled(True)
         transport = TransportComponent(name='Transport', is_enabled=False, layer=Layer(play_button=midimap['Play'], record_button=midimap['Record'], stop_button=midimap['Stop'], seek_forward_button=midimap['Forward'], seek_backward_button=midimap['Backward'], loop_button=midimap['Loop']))
         transport.set_enabled(True)
         mixer_size = len(midimap['Sliders'])
         mixer = MixerComponent(mixer_size, name='Mixer', is_enabled=False, layer=Layer(volume_controls=midimap['Sliders'], pan_controls=midimap['Encoders'], arm_buttons=midimap['Arm_Buttons']))
         mixer.set_enabled(True)
コード例 #20
0
 def update(self):
     TransportComponent.update(self)
     if self.is_enabled():
         self._on_playing_status_changed()
         self._on_record_status_changed()
         self._on_loop_status_changed()
         
         self._on_metronome_changed()
         self._on_session_record_status_changed()
 
         self._on_rec_quantisation_changed()
    def __init__(self, c_instance, session, parent):
        TransportComponent.__init__(self)
        self.c_instance = c_instance
        self._shift_pressed = False
        self._mixer9_button = None
        self._play_button = None
        self._record_button = None
        self._session = session
        self._parent = parent
        song = self.song()
#        self._automation_toggle= self.register_component(ToggleComponent('session_automation_record', song))
        self._automation_toggle, self._re_enable_automation_toggle, self._delete_automation = self.register_components(ToggleComponent('session_automation_record', song), ToggleComponent('re_enable_automation_enabled', song, read_only=True), ToggleComponent('has_envelopes', None, read_only=True))
コード例 #22
0
ファイル: MPK_mini_hero.py プロジェクト: jhrdina/mpk-mini
    def _setup_components(self):
        
        # Session

        self._session = SessionComponent(8, len(self._scene_launch_buttons))
        self._session.name = 'Session_Control'
        self._session.selected_scene().name = 'Selected_Scene'
        self._session.selected_scene().set_launch_button(self._scene_launch_button)
        self._session.set_stop_all_clips_button(self._scene_stop_button)

        for index in range(8):
            clip_slot = self._session.selected_scene().clip_slot(index)
            clip_slot.set_launch_button(self._clip_launch_buttons[index])
            clip_slot.name = 'Selected_Clip_Slot_' + str(index)

        self._session.set_stop_track_clip_buttons(tuple(self._clip_stop_buttons))

        # Undo

        self._do_undo.subject = self._clip_undo_button;

        # Transport

        transport = TransportComponent()
        transport.name = 'Transport'
        transport.set_stop_button(self._stop_button)
        transport.set_play_button(self._play_button)
        transport.set_record_button(self._rec_button)
        transport.set_loop_button(self._loop_button)

        self._transport_view_modes = TransportViewModeSelector(transport, self._session, self._ffwd_button, self._rwd_button)
        self._transport_view_modes.name = 'Transport_View_Modes'

        session_recording = SessionRecordingComponent(ClipCreator(), ViewControlComponent(), name='Session_Recording', is_enabled=False, layer=Layer(record_button=self._overdub_button))

        # Device

        # device = DeviceComponent()
        # device.name = 'Device_Component'
        # self.set_device_component(device)
        # device.set_parameter_controls(self._encoders)

        # Navigation

        self._session_navigation = SessionNavigationComponent(name='Session_Navigation')
        self._session_navigation.set_next_track_button(self._next_track_button)
        self._session_navigation.set_prev_track_button(self._prev_track_button)

        # Playing
        # self._session.set_scene_launch_buttons(tuple(self._scene_launch_buttons))
        for index in range(len(self._scene_launch_buttons)):
            scene = self._session.scene(index)
            scene.set_launch_button(self._scene_launch_buttons[index])
コード例 #23
0
 def __init__(self):
     self._launch_quant_button = None
     self._record_quant_button = None
     self._back_to_arranger_button = None
     self._follow_button = None
     self._tempo_up_button = None
     self._tempo_down_button = None
     TransportComponent.__init__(self)
     self.song().add_midi_recording_quantization_listener(self._on_record_quantisation_changed)
     self.song().add_clip_trigger_quantization_listener(self._on_launch_quantisation_changed)
     self.song().add_back_to_arranger_listener(self._on_back_to_arranger_changed)
     self.song().view.add_follow_song_listener(self._on_follow_changed)
     self.send_init()
コード例 #24
0
  def __init__(self, play = None, stop = None, bpm_down = None, bpm_up = None, **kwargs):
    TransportComponent.__init__(self)
    Elementary.__init__(self, **kwargs)

    if play is not None:
      self.play_button = self.button(play, off_color = PURPLE) 
      self.set_play_button(self.play_button)
    if stop is not None:
      self.stop_button = self.button(stop, on_color = RED, off_color = RED) 
      self.set_stop_button(self.stop_button)

    
    self.setup_bpm_control(bpm_up, bpm_down)
コード例 #25
0
 def __init__(self):
     TransportComponent.__init__(self)
     self._shift_button = None
     self._quant_toggle_button = None
     self._shift_pressed = False
     self._last_quant_value = Live.Song.RecordingQuantization.rec_q_eight
     self.song().add_midi_recording_quantization_listener(self._on_quantisation_changed)
     self._on_quantisation_changed()
     self._undo_button = None #added from OpenLabs SpecialTransportComponent script
     self._redo_button = None #added from OpenLabs SpecialTransportComponent script
     self._bts_button = None #added from OpenLabs SpecialTransportComponent script
     self._tempo_encoder_control = None #new addition
     return None
 def _rwd_value(self, value):
     self.log("rwd handler main")
     if not self._rwd_button != None:
         raise AssertionError
     if not value in range(128):
         raise AssertionError
     else:
         if self._shift_pressed:
             self.song().current_song_time = self._shift_pressed and 0.0
             self.log("rwd shifted handler")
         else:
             self.log("rwd normal handler")
             TransportComponent._rwd_value(self, value)
コード例 #27
0
 def __init__(self, c_instance):
     ControlSurface.__init__(self, c_instance)
     with self.component_guard():
         self._suggested_input_port = 'HyperControl'
         self._suggested_output_port = 'HyperControl'
         self._device_selection_follows_track_selection = True
         self.set_pad_translations(PAD_TRANSLATIONS)
         stop_button = make_button(116)
         play_button = make_button(117)
         record_button = make_button(118)
         select_button = make_button(98)
         nav_left_button = make_button(99)
         nav_right_button = make_button(100)
         nav_up_button = make_button(101)
         nav_down_button = make_button(102)
         mixer_modes_toggle = make_button(58)
         mixer_or_device_toggle = make_button(59)
         hypercontrol_mode_toggle = make_button(60)
         encoders = tuple([ make_encoder(33 + index) for index in range(8) ])
         transport = TransportComponent()
         transport.set_stop_button(stop_button)
         transport.set_play_button(play_button)
         transport.set_record_button(record_button)
         session = SessionComponent(8, 0)
         device = BestBankDeviceComponent()
         self.set_device_component(device)
         device_nav = DeviceNavComponent()
         mixer = SpecialMixerComponent(NUM_TRACKS)
         session.set_mixer(mixer)
         mixer_encoder_modes = EncoderMixerModeSelector(mixer)
         mixer_encoder_modes.set_mode_toggle(mixer_modes_toggle)
         mixer_or_device = MixerOrDeviceModeSelector(encoders, select_button, nav_up_button, nav_down_button, nav_left_button, nav_right_button, mixer, session, device, mixer_encoder_modes, device_nav)
         mixer_or_device.set_mode_buttons((mixer_modes_toggle, mixer_or_device_toggle, hypercontrol_mode_toggle))
コード例 #28
0
  def __init__(self):
    TransportComponent.__init__(self)
    
    self._tempo_up_button = None
    self._tempo_down_button = None

    self.set_play_button(self.button(PAD_CHANNEL, PLAY))
    self.set_record_button(self.button(PAD_CHANNEL, REC))
    self.set_stop_button(self.button(PAD_CHANNEL, STOP))
    self.set_overdub_button(self.button(PAD_CHANNEL, OVERDUB))
    self.set_metronome_button(self.button(PAD_CHANNEL, METRONOME))
    self.set_tempo_buttons(
        self.button(PAD_CHANNEL, TEMPO_UP), 
        self.button(PAD_CHANNEL, TEMPO_DOWN))
コード例 #29
0
 def __init__(self):
     self._launch_quant_button = None
     self._record_quant_button = None
     self._back_to_arranger_button = None
     self._follow_button = None
     self._tempo_up_button = None
     self._tempo_down_button = None
     TransportComponent.__init__(self)
     self.song().add_midi_recording_quantization_listener(self._on_record_quantisation_changed)
     self.song().add_clip_trigger_quantization_listener(self._on_launch_quantisation_changed)
     self.song().add_back_to_arranger_listener(self._on_back_to_arranger_changed)
     self.song().view.add_follow_song_listener(self._on_follow_changed)
     self.send_init()
     return
コード例 #30
0
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        with self.component_guard():
            is_momentary = True
            self._suggested_input_port = 'Oxygen'
            self._suggested_output_port = 'Oxygen'
            self._has_slider_section = True
            self._device_selection_follows_track_selection = True
            self._shift_button = ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 57)
            self._shift_button.add_value_listener(self._shift_value)
            self._mixer = SpecialMixerComponent(NUM_TRACKS)
            self._mute_solo_buttons = []
            self._track_up_button = ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 111)
            self._track_down_button = ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 110)
            self._master_slider = SliderElement(MIDI_CC_TYPE, GLOBAL_CHANNEL, 41)
            for index in range(NUM_TRACKS):
                self._mute_solo_buttons.append(ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 49 + index))
                self._mixer.channel_strip(index).set_volume_control(SliderElement(MIDI_CC_TYPE, GLOBAL_CHANNEL, 33 + index))

            self._shift_value(0)
            self._mixer.master_strip().set_volume_control(self._master_slider)
            self._mixer.selected_strip().set_volume_control(None)
            device = DeviceComponent()
            device.set_parameter_controls(tuple([ EncoderElement(MIDI_CC_TYPE, GLOBAL_CHANNEL, 17 + index, Live.MidiMap.MapMode.absolute) for index in range(8) ]))
            self.set_device_component(device)
            ffwd_button = ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 115)
            rwd_button = ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 114)
            loop_button = ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 113)
            transport = TransportComponent()
            transport.set_stop_button(ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 116))
            transport.set_play_button(ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 117))
            transport.set_record_button(ButtonElement(is_momentary, MIDI_CC_TYPE, GLOBAL_CHANNEL, 118))
            session = SessionComponent(0, 0)
            transport_view_modes = TransportViewModeSelector(transport, session, ffwd_button, rwd_button, loop_button)
コード例 #31
0
 def _setup_transport(self):
     rwd_button = make_button(112, "Rwd_Button")
     ffwd_button = make_button(113, "FFwd_Button")
     stop_button = make_button(114, "Stop_Button")
     play_button = make_button(115, "Play_Button")
     loop_button = make_button(116, "Loop_Button")
     rec_button = make_button(117, "Record_Button")
     transport = TransportComponent()
     transport.name = "Transport"
     transport.set_stop_button(stop_button)
     transport.set_play_button(play_button)
     transport.set_record_button(rec_button)
     transport.set_loop_button(loop_button)
     self._transport_view_modes = TransportViewModeSelector(transport, self._session, ffwd_button, rwd_button)
     self._transport_view_modes.name = "Transport_View_Modes"
コード例 #32
0
 def _ffwd_value(self, value):
     self.log("ffwd handler main")
     if not self._ffwd_button != None:
         raise AssertionError
     if not value in range(128):
         raise AssertionError
     else:
         if self._shift_pressed:
             self.log("ffwd shifted handler")
             self.song(
             ).current_song_time = self._shift_pressed and self.song(
             ).last_event_time
         else:
             self.log("ffwd normal handler")
             TransportComponent._ffwd_value(self, value)
コード例 #33
0
ファイル: Launchkey.py プロジェクト: cce/buttons
 def _setup_transport(self):
     rwd_button = make_button(112, 'Rwd_Button')
     ffwd_button = make_button(113, 'FFwd_Button')
     stop_button = make_button(114, 'Stop_Button')
     play_button = make_button(115, 'Play_Button')
     loop_button = make_button(116, 'Loop_Button')
     rec_button = make_button(117, 'Record_Button')
     transport = TransportComponent()
     transport.name = 'Transport'
     transport.set_stop_button(stop_button)
     transport.set_play_button(play_button)
     transport.set_record_button(rec_button)
     transport.set_loop_button(loop_button)
     self._transport_view_modes = TransportViewModeSelector(transport, self._session, ffwd_button, rwd_button)
     self._transport_view_modes.name = 'Transport_View_Modes'
コード例 #34
0
 def __init__(self):
     TransportComponent.__init__(self)
     self._shift_button = None
     self._pedal = None
     self._shift_pressed = False
     self._pedal_pressed = False #added
     self._quant_toggle_button = None
     self._last_quant_value = Live.Song.RecordingQuantization.rec_q_eight
     self.song().add_midi_recording_quantization_listener(self._on_quantisation_changed)
     self._on_quantisation_changed()
     self._undo_button = None #added from OpenLabs SpecialTransportComponent script
     self._redo_button = None #added from OpenLabs SpecialTransportComponent script
     self._bts_button = None #added from OpenLabs SpecialTransportComponent script
     self._tempo_encoder_control = None #new addition
     return None
コード例 #35
0
 def _rwd_value(self, value):
     self.log("rwd handler main" + str(value))
     if not self._rwd_button != None:
         raise AssertionError
     if not value in range(128):
         raise AssertionError
     else:
         if self._parent.shift_pressed:
             self.log("rwd shifted handler")
             #                    self.song().current_song_time = 0.0
             if value == 1:
                 self._scroll_device_chain(NavDirection.left)
         else:
             self.log("rwd normal handler")
             TransportComponent._rwd_value(self, value)
コード例 #36
0
    def _rwd_value(self, value):
        self.log("rwd handler main" + str(value))
        if not self._rwd_button != None:
            raise AssertionError
        if not value in range(128):
            raise AssertionError
        else:
            if self._shift_pressed:
                self.log("rwd shifted handler")
#                    self.song().current_song_time = 0.0
                if value == 1:
                    self._scroll_device_chain(NavDirection.left)
            else:
                self.log("rwd normal handler")
                TransportComponent._rwd_value(self, value)
コード例 #37
0
 def disconnect(self):
     TransportComponent.disconnect(self)
     if self._quant_toggle_button != None:
         self._quant_toggle_button.remove_value_listener(self._quant_toggle_value)
         self._quant_toggle_button = None
     self.song().remove_midi_recording_quantization_listener(self._on_quantisation_changed)
     if (self._undo_button != None): 
         self._undo_button.remove_value_listener(self._undo_value)
         self._undo_button = None
     if (self._redo_button != None): 
         self._redo_button.remove_value_listener(self._redo_value)
         self._redo_button = None
     if (self._tempo_encoder_control != None):
         self._tempo_encoder_control.remove_value_listener(self._tempo_encoder_value)
         self._tempo_encoder_control = None
     return None
コード例 #38
0
 def __init__(self, *a, **k):
     super(Advance, self).__init__(*a, **k)
     with self.component_guard():
         encoders = ButtonMatrixElement(rows=[[ make_encoder(index + 22, 'Encoder_%d' % index) for index in xrange(8) ]])
         pads = ButtonMatrixElement(rows=[ [ make_button(identifier, 'Pad_%d_%d' % (col, row)) for col, identifier in enumerate(row_ids) ] for row, row_ids in enumerate(PAD_IDS) ])
         device = DeviceComponent(is_enabled=False, layer=Layer(parameter_controls=encoders), device_selection_follows_track_selection=True)
         device.set_enabled(True)
         self.set_device_component(device)
         drums = DrumRackComponent(is_enabled=False, layer=Layer(pads=pads))
         drums.set_enabled(True)
         play_button = make_button(118, 'Play_Button', MIDI_CC_TYPE, 0)
         stop_button = make_button(117, 'Stop_Button', MIDI_CC_TYPE, 0)
         record_button = make_button(119, 'Record_Button', MIDI_CC_TYPE, 0)
         loop_button = make_button(114, 'Loop_Button', MIDI_CC_TYPE, 0)
         transport = TransportComponent(is_enabled=False, layer=Layer(play_button=play_button, stop_button=stop_button, record_button=record_button, loop_button=loop_button))
         transport.set_enabled(True)
コード例 #39
0
ファイル: Transport.py プロジェクト: m-nny/remote-scripts
 def _create_transport(self):
     self._transport = TransportComponent(
         is_enabled=True,
         name='Transport')  #Instantiate a Transport Component
     self._transport.layer = Layer(play_button=self._play_button,
                                   stop_button=self._stop_button,
                                   record_button=self._record_button)
     self.log_message("Captain's log stardate 2/2")
コード例 #40
0
 def __init__(self, c_instance, session, parent):
     TransportComponent.__init__(self)
     self.c_instance = c_instance
     self._shift_pressed = False
     self._mixer9_button = None
     self._play_button = None
     self._record_button = None
     self._session = session
     self._parent = parent
     song = self.song()
     #        self._automation_toggle= self.register_component(ToggleComponent('session_automation_record', song))
     self._automation_toggle, self._re_enable_automation_toggle, self._delete_automation = self.register_components(
         ToggleComponent('session_automation_record', song),
         ToggleComponent('re_enable_automation_enabled',
                         song,
                         read_only=True),
         ToggleComponent('has_envelopes', None, read_only=True))
コード例 #41
0
ファイル: APC_Key_25.py プロジェクト: aumhaa/livepy_diff_ten
    def _create_transport(self):

        def play_toggle_model_transform(value):
            if self._shift_button.is_pressed():
                return False
            return value

        return TransportComponent(name=u'Transport', is_enabled=False, play_toggle_model_transform=play_toggle_model_transform, layer=Layer(play_button=self._play_button, record_button=self._record_button))
コード例 #42
0
    def disconnect(self):
        self.song().remove_midi_recording_quantization_listener(self._on_record_quantisation_changed)
        self.song().remove_clip_trigger_quantization_listener(self._on_launch_quantisation_changed)
        self.song().remove_back_to_arranger_listener(self._on_back_to_arranger_changed)
        self.song().view.remove_follow_song_listener(self._on_follow_changed)


        if self._record_quant_slider != None:
            self._record_quant_slider.remove_value_listener(self._record_quant_value)
            self._record_quant_slider = None
        if self._launch_quant_slider != None:
            self._launch_quant_slider.remove_value_listener(self._launch_quant_value)
            self._launch_quant_slider = None
        if self._back_to_arranger_button != None:
            self._back_to_arranger_button.remove_value_listener(self._back_to_arranger_value)
            self._back_to_arranger_button = None
        if self._follow_button != None:
            self._follow_button.remove_value_listener(self._follow_value)        
            self._follow_button = None


        if self._undo_button != None:
            self._undo_button.remove_value_listener(self._undo_value)
            self._undo_button = None
        if self._redo_button != None:
            self._redo_button.remove_value_listener(self._redo_value)
            self._redo_button = None
        if self._bts_button != None:
            self._bts_button.remove_value_listener(self._bts_value)
            self._bts_button = None           
            
        if self._tempo_encoder_control != None:
            self._tempo_encoder_control.remove_value_listener(self._tempo_encoder_value)
            self._tempo_encoder_control = None
        if self._tempo_down_button != None:
            self._tempo_down_button.remove_value_listener(self._tempo_down_value)
            self._tempo_down_button = None
        if self._tempo_up_button != None:
            self._tempo_up_button.remove_value_listener(self._tempo_up_value)
            self._tempo_up_button = None            
        if self._shift_button != None:
            self._shift_button.remove_value_listener(self._shift_value)
            self._shift_button = None             
        TransportComponentBase.disconnect(self)
 def __init__(self, c_instance):
     ControlSurface.__init__(self, c_instance)
     with self.component_guard():
         global mixer
         global transport
         track_count = 256  # Allegedly unlimited in Live Suite...
         return_count = 24  # Maximum of 12 Sends and 12 Returns
         mixer = MixerComponent(track_count, return_count)
         transport = TransportComponent()
         self._mainCtrl()
コード例 #44
0
 def _setup_transport(self):
     is_momentary = True
     transport = TransportComponent()
     self.__play_button = StateButton(is_momentary,
                                      MIDI_CC_TYPE,
                                      BASE_CONTROL_CHANNEL,
                                      CC_PLAY_BUTTON,
                                      name='Play_Button')
     self.__restart_button = StateButton(True, MIDI_CC_TYPE,
                                         BASE_CONTROL_CHANNEL,
                                         CC_RESTART_BUTTON)
     stop_button = StateButton(not is_momentary,
                               MIDI_CC_TYPE,
                               BASE_CONTROL_CHANNEL,
                               CC_STOP_BUTTON,
                               name='Stop_Button')
     self._rec_button = StateButton(is_momentary,
                                    MIDI_CC_TYPE,
                                    BASE_CONTROL_CHANNEL,
                                    CC_RECORD_BUTTON,
                                    name='Record_Button')
     metrononme_button = StateButton(is_momentary,
                                     MIDI_CC_TYPE,
                                     BASE_CONTROL_CHANNEL,
                                     CC_METRONOME_BUTTON,
                                     name='Metronome_Button')
     self._song_follow_button = StateButton(is_momentary,
                                            MIDI_CC_TYPE,
                                            BASE_CONTROL_CHANNEL,
                                            CC_FOLLOW_BUTTON,
                                            name='Follow_Button')
     self._do_rec_button.subject = self._rec_button
     if self._has_stop_button:
         transport.set_play_button(self.__play_button)
         transport.set_stop_button(stop_button)
     else:
         self._hand_play_pressed.subject = self.__play_button
         self._listen_playing.subject = self.song()
     self._stopall_button = StateButton(True, MIDI_CC_TYPE, 0,
                                        CC_ALL_BUTTON)
     self._do_stop_all.subject = self._stopall_button
     self._auto_button = StateButton(True,
                                     MIDI_CC_TYPE,
                                     0,
                                     CC_AUTO_BUTTON,
                                     name='Auto_Button')
     self._handle_automation_record.subject = self._auto_button
     self._listen_automation_record.subject = self.song()
     self._handle_restart_button.subject = self.__restart_button
     self._handle_follows_button.subject = self._song_follow_button
     self._follow_song_changed.subject = self.song().view
     transport.set_metronome_button(metrononme_button)
     self._listen_overdub.subject = self.song()
コード例 #45
0
 def _setup_transport(self):
     self._transport = TransportComponent()
     self._transport.layer = Layer(
         play_button=self._play_button,
         stop_button=self._stop_button,
         seek_forward_button=self._forward_button,
         seek_backward_button=self._backward_button,
         tap_tempo_button=self._loop_button)
     self._session_record = SessionRecordingComponentEx()
     self._session_record.layer = Layer(record_button=self._record_button)
コード例 #46
0
    def _setup_transport(self):
        """ Build component and layers used by the transport """
        layer = Layer(play_button=self.play_button,
                      stop_button=self.stop_button,
                      seek_forward_button=self.forward_button,
                      seek_backward_button=self.backward_button,
                      loop_button=self.loop_button)

        self.transport = TransportComponent()
        self.transport.layer = layer
コード例 #47
0
 def __init__(self, *a, **k):
     super(Alesis_VI, self).__init__(*a, **k)
     with self.component_guard():
         midimap = MidiMap()
         transport = TransportComponent(
             name='Transport',
             is_enabled=False,
             layer=Layer(play_button=midimap['Play'],
                         stop_button=midimap['Stop'],
                         loop_button=midimap['Loop'],
                         record_button=midimap['Record'],
                         seek_forward_button=midimap['Forward'],
                         seek_backward_button=midimap['Backward']))
         mixer_size = len(midimap['Volume_Encoders'])
         mixer = MixerComponent(
             mixer_size,
             name='Mixer',
             is_enabled=False,
             layer=Layer(volume_controls=midimap['Volume_Encoders']))
         transport.set_enabled(True)
         mixer.set_enabled(True)
コード例 #48
0
    def _MG_setup(self):
        mixer = MixerComponent(8)
        mixer.set_track_offset(
            0)  #Sets start point for mixer strip (offset from left)
        transport = TransportComponent()
        mixer.set_track_offset(0)

        for i in xrange(len(KNOBS)):  #set the functions of the knobs
            volume_knob = SliderElement(MIDI_CC_TYPE, 0, KNOBS[i])
            pan_knob = SliderElement(MIDI_CC_TYPE, 1, KNOBS[i])

            send_a = SliderElement(MIDI_CC_TYPE, 2, KNOBS[i])
            send_b = SliderElement(MIDI_CC_TYPE, 3, KNOBS[i])
            send_c = SliderElement(MIDI_CC_TYPE, 4, KNOBS[i])
            send_d = SliderElement(MIDI_CC_TYPE, 5, KNOBS[i])
            send_e = SliderElement(MIDI_CC_TYPE, 6, KNOBS[i])
            send_f = SliderElement(MIDI_CC_TYPE, 7, KNOBS[i])

            mixer.channel_strip(i).set_volume_control(volume_knob)
            mixer.channel_strip(i).set_pan_control(pan_knob)
            mixer.channel_strip(i).set_send_controls(
                [send_a, send_b, send_c, send_d, send_e, send_f])

        # scenes are locked to channel 14
        transport.set_overdub_button(
            ButtonElement(False, MIDI_CC_TYPE, 0, SCENES[0]))
        transport.set_stop_button(
            ButtonElement(False, MIDI_CC_TYPE, 0, SCENES[1]))
コード例 #49
0
ファイル: Block.py プロジェクト: spiralune/monomodular
	def _setup_transport_control(self):
		is_momentary = True # We'll only be using momentary buttons here
		transport = TransportComponent() #Instantiate a Transport Component
		"""set up the buttons"""
		transport.set_play_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 69)) #ButtonElement(is_momentary, msg_type, channel, identifier) Note that the MIDI_NOTE_TYPE constant is defined in the InputControlElement module
		transport.set_stop_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 70))
		#transport.set_record_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 66))
		#transport.set_overdub_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 68))
		#transport.set_nudge_buttons(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80), ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 73)) #(up_button, down_button)
		#transport.set_tap_tempo_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80))
		#transport.set_metronome_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80)) #For some reason, in Ver 7.x.x this method's name has no trailing "e" , and must be called as "set_metronom_button()"...
		#transport.set_loop_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 82))
		#transport.set_punch_buttons(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 85), ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 87)) #(in_button, out_button)
		#transport.set_seek_buttons(ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 90), ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 92)) # (ffwd_button, rwd_button)
		#"""set up the sliders"""
		#transport.set_tempo_control(SliderElement(MIDI_CC_TYPE, CHANNEL, 26), SliderElement(MIDI_CC_TYPE, CHANNEL, 25)) #(control, fine_control)
		#transport.set_song_position_control(SliderElement(MIDI_CC_TYPE, CHANNEL, 24))
		
		device_param_controls = []
		effects_knob_cc = [17,16,9,8,19,18,11,10]
		device = DeviceComponent()
		for index in range(8):
			device_param_controls.append(EncoderElement(MIDI_CC_TYPE, 0, effects_knob_cc[index], Live.MidiMap.MapMode.absolute))
		device.set_parameter_controls(tuple(device_param_controls))
		self.set_device_component(device)
コード例 #50
0
 def disconnect(self):
     TransportComponent.disconnect(self)
     if self._shift_button != None:
         self._shift_button.remove_value_listener(self._shift_value)
         self._shift_button = None
     if self._quant_toggle_button != None:
         self._quant_toggle_button.remove_value_listener(self._quant_toggle_value)
         self._quant_toggle_button = None
     self.song().remove_midi_recording_quantization_listener(self._on_quantisation_changed)
     if (self._undo_button != None): #added from OpenLabs SpecialTransportComponent script
         self._undo_button.remove_value_listener(self._undo_value)
         self._undo_button = None
     if (self._redo_button != None): #added from OpenLabs SpecialTransportComponent script
         self._redo_button.remove_value_listener(self._redo_value)
         self._redo_button = None
     if (self._bts_button != None): #added from OpenLabs SpecialTransportComponent script
         self._bts_button.remove_value_listener(self._bts_value)
         self._bts_button = None
     if (self._tempo_encoder_control != None): #new addition
         self._tempo_encoder_control.remove_value_listener(self._tempo_encoder_value)
         self._tempo_encoder_control = None
     return None
コード例 #51
0
    def _setup_mixer_control(self):
        num_tracks = GRIDSIZE[
            1]  # Here we define the mixer width in tracks (a mixer has only one dimension)
        global mixer  # We want to instantiate the global mixer as a MixerComponent object (it was a global "None" type up until now...)
        mixer = MixerComponent(
            num_tracks)  #(num_tracks, num_returns, with_eqs, with_filters)
        mixer.set_track_offset(
            0)  #Sets start point for mixer strip (offset from left)
        """set up the mixer buttons"""
        self.song().view.selected_track = mixer.channel_strip(0)._track
        #master_volume_control = SliderElement(MIDI_CC_TYPE, 1, 17)
        for index in range(GRIDSIZE[1]):
            mixer.channel_strip(index).set_volume_control(
                SliderElement(MIDI_CC_TYPE, CHANNEL, MIX_FADERS[index]))

            mixer.channel_strip(index).set_arm_button(
                ButtonElement(True, MIDI_NOTE_TYPE, CHANNEL,
                              ARM_BUTTONS[index]))  #sets the record arm button
            mixer.channel_strip(index).set_solo_button(
                ButtonElement(True, MIDI_NOTE_TYPE, CHANNEL,
                              SOLO_BUTTONS[index]))
            mixer.channel_strip(index).set_mute_button(
                ButtonElement(True, MIDI_NOTE_TYPE, CHANNEL,
                              MUTE_BUTTONS[index]))
            mixer.channel_strip(index).set_select_button(
                ButtonElement(True, MIDI_NOTE_TYPE, CHANNEL,
                              TRACK_SELECTS[index]))
        """TRANSPORT CONTROLS"""
        stop_button = ButtonElement(False, MIDI_CC_TYPE, 0, STOP_BUTTON)
        play_button = ButtonElement(False, MIDI_CC_TYPE, 0, PLAY_BUTTON)
        record_button = ButtonElement(False, MIDI_CC_TYPE, 0, RECORD_BUTTON)
        transport = TransportComponent()
        transport.set_stop_button(stop_button)
        transport.set_play_button(play_button)
        transport.set_overdub_button(record_button)
        transport.set_overdub_button(record_button)
        transport.set_seek_buttons(
            ButtonElement(False, MIDI_CC_TYPE, 0, SEEK_LEFT),
            ButtonElement(False, MIDI_CC_TYPE, 0, SEEK_RIGHT))
コード例 #52
0
    def disconnect(self):
        self._unregister_timer_callback(self._on_custom_timer)
        TransportComponent.disconnect(self)

        self.song().remove_is_playing_listener(self._on_playing_status_changed)
        self.song().remove_record_mode_listener(self._on_record_status_changed)
        self.song().remove_session_record_listener(
            self._on_session_record_status_changed)
        self.song().remove_session_record_status_listener(
            self._on_session_record_status_changed)
        self.song().remove_session_automation_record_listener(
            self._on_record_automation_changed)
        self.song().remove_loop_listener(self._on_loop_status_changed)
        self.song().remove_midi_recording_quantization_listener(
            self._on_rec_quantisation_changed)
        self.song().remove_metronome_listener(self._on_metronome_changed)
        self.song().remove_current_song_time_listener(
            self._on_song_time_changed)
        self.song().remove_nudge_down_listener(self._on_nudge_down_changed)
        self.song().remove_nudge_up_listener(self._on_nudge_up_changed)

        self.set_shift_button(None)
        self.set_main_view_button(None)
        self.set_detail_view_button(None)
        self.set_undo_button(None)
        self.set_metronome_button(None)
        self.set_tap_tempo_button(None)
        self.set_quant_toggle_button(None)
        self.set_nudge_buttons(None, None)
        self.set_stop_button(None, None)
        self.set_play_button(None, None)
        self.set_loop_button(None, None)
        self.set_record_button(None, None)
        self.set_session_record_button(None)
        self.set_record_automation_button(None)
        self.set_dummy1_button(None)
        self.set_dummy2_button(None)
        self.set_dummy7_button(None)
        self.set_dummy8_button(None)
コード例 #53
0
    def _init_transport_component(self, transport_controls, global_channel):

        def make_transport_button(control, name, is_momentary=True):
            return ButtonElement(is_momentary, MIDI_CC_TYPE, global_channel, transport_controls[control], name=name)

        if transport_controls:
            momentary_seek = 'NORELEASE' not in transport_controls.keys()
            layer_specs = {}
            if has_specification_for('STOP', transport_controls):
                layer_specs['stop_button'] = make_transport_button('STOP', 'Stop_Button')
            if has_specification_for('PLAY', transport_controls):
                layer_specs['play_button'] = make_transport_button('PLAY', 'Play_Button')
            if has_specification_for('REC', transport_controls):
                layer_specs['record_button'] = make_transport_button('REC', 'Record_Button')
            if has_specification_for('LOOP', transport_controls):
                layer_specs['loop_button'] = make_transport_button('LOOP', 'Loop_Button')
            if has_specification_for('FFWD', transport_controls):
                layer_specs['seek_forward_button'] = make_transport_button('FFWD', 'FFwd_Button', is_momentary=momentary_seek)
            if has_specification_for('RWD', transport_controls):
                layer_specs['seek_backward_button'] = make_transport_button('RWD', 'Rwd_Button', is_momentary=momentary_seek)
            transport = TransportComponent(name='Transport')
            transport.layer = Layer(**layer_specs)
コード例 #54
0
ファイル: ProjectX.py プロジェクト: m-nny/remote-scripts
    def _create_transport_control(self):
        is_momentary = True

        self._transport = TransportComponent(is_enabled=True, name='Transport')
        """set up the buttons"""
        self._transport.set_play_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 61))
        self._transport.set_stop_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 63))
        self._transport.set_record_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 66))
        self._transport.set_overdub_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 68))
        self._transport.set_nudge_buttons(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 75),
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 73))
        self._transport.set_tap_tempo_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 78))
        self._transport.set_metronome_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 80))
        self._transport.set_loop_button(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 82))
        self._transport.set_punch_buttons(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 85),
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 87))
        self._transport.set_seek_buttons(
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 90),
            ButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL, 92))
        """set up the sliders"""
        self._transport.set_tempo_control(
            SliderElement(MIDI_CC_TYPE, CHANNEL, 26),
            SliderElement(MIDI_CC_TYPE, CHANNEL, 25))
        self._transport.set_song_position_control(
            SliderElement(MIDI_CC_TYPE, CHANNEL, 24))

        self.log_message("Captain's log stardate 1")
コード例 #55
0
ファイル: OhmOne.py プロジェクト: hoefkensj/OhmOne
 def _setup_transport_control(self):
     transport_button = [
         ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, CHANNEL,
                                   TRANSPORT_BUTTONS[index])
         for index in range(4)
     ]
     #transport_button.set_on_off_values(LED_ON, LED_OFF)
     transport = TransportComponent()
     transport.set_play_button(transport_button[0])
     transport.set_stop_button(transport_button[1])
コード例 #56
0
 def __init__(self, c_instance):
     ControlSurface.__init__(self, c_instance)
     transport = TransportComponent()
     transport.set_play_button(
         ButtonElement(True, 0, ABLETON["GENERAL_CHANNEL"],
                       ABLETON["START_NOTE"]))
     transport.set_stop_button(
         ButtonElement(True, 0, ABLETON["GENERAL_CHANNEL"],
                       ABLETON["STOP_NOTE"]))
     self.log_message("MiniCommand surface")
     self.get_track_name(0)
コード例 #57
0
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        with self.component_guard():
            self._suppress_send_midi = True
            self._suppress_session_highlight = True
            self._control_is_with_automap = False
            is_momentary = True
            self._suggested_input_port = 'Akai MPD26'
            self._suggested_output_port = 'Akai MPD26'

            """SESSION ViEW"""
            session = SessionComponent(4,4)
            session.name = 'Session_Control'
            matrix = ButtonMatrixElement()
            matrix.name = 'Button_Matrix'
            up_button = ButtonElement(False, MIDI_CC_TYPE, 0, 115)
            down_button = ButtonElement(False, MIDI_CC_TYPE, 0, 116)
            up_button.name = 'Bank_Select_Up_Button'
            down_button.name = 'Bank_Select_Down_Button'
            session.set_scene_bank_buttons(down_button, up_button)
            for row in range(4):
                button_row = []
                button_notes = [48, 44, 40, 36]
                scene = session.scene(row)
                scene.name = 'Scene_' + str(row)
                for column in range(4):
                    button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, button_notes[row] +  column )
                    button.name = str(column) + '_Clip_' + str(row) + '_Button'
                    button_row.append(button)
                    clip_slot = scene.clip_slot(column)
                    clip_slot.name = str(column) + '_Clip_Slot_' + str(row)
                    clip_slot.set_launch_button(button)
                matrix.add_row(tuple(button_row))

            self._suppress_session_highlight = False
            self._suppress_send_midi = False
            self.set_highlighting_session_component(session)
            #self._set_session_highlight(0,session._scene_offset,4,4,False)
            
            """TRANSPORT CONTROLS"""
            stop_button = ButtonElement(False, MIDI_CC_TYPE, 0, 117)
            play_button = ButtonElement(False, MIDI_CC_TYPE, 0, 118)
            transport = TransportComponent()
            transport.set_stop_button(stop_button)
            transport.set_play_button(play_button)
コード例 #58
0
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        self.c_instance = c_instance

        self.retries_count = 0
        self.device_connected = False

        self.clip_color_callbacks = {}
        self.slot_callbacks = {}

        self.text_start_sequence = (0xf0, 0x0, 0x20, 0x76, 0x00, 0x03)
        self.text_end_sequence = (0xf7, )
        self.enable_sequence = (0xf0, 0x00, 0x20, 0x76, 0x00, 0x01, 0x02, 0xf7)
        self.disable_sequence = (0xf0, 0x00, 0x20, 0x76, 0x00, 0x01, 0x00,
                                 0xf7)

        self.id_sequence = (0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7)

        self.text_color_start_sequence = (0xf0, 0x0, 0x20, 0x76, 0x00, 0x04)

        self.log('INITIALIZING')

        self.app = Live.Application.get_application()

        #maj = self.app.get_major_version()
        #min = self.app.get_minor_version()
        #bug = self.app.get_bugfix_version()
        #self.show_message(str(1) + "." + str(0) + "." + str(9))

        self.show_message("Version " + VERSION)

        # reseting text
        self.write_text(' ')

        # reset display clips
        self.reset_display_clips()

        # getting browser visible state
        self.session_browser_visible = self.app.view.is_view_visible("Browser")

        # getting browser visible state
        self.arrange_browser_visible = self.app.view.is_view_visible("Browser")

        # getting session view visible state
        self.session_visible = self.app.view.is_view_visible("Session")

        # getting arrange view visible state
        self.arrange_visible = self.app.view.is_view_visible("Arranger")

        # getting detail view visible state
        self.detail_visible = self.app.view.is_view_visible("Detail")

        # getting back to arranger state
        self.back_to_arranger_state = self.song().back_to_arranger

        # initializing channel strip to null
        self._channel_strip = None

        # initializing transport component
        self._transport = TransportComponent()

        # initializing mixer component
        self._mixer = MixerComponent(NUM_TRACKS, 2)

        # initializing session component
        self._session = SessionComponent(NUM_TRACKS, NUM_ROWS)
        self._session.add_offset_listener(self.session_offset_changed)

        # configuring operation mode selector buttons
        self._operation_mode_buttons = ButtonElement(
            True, MIDI_CC_TYPE, CHANNEL, OP1_MODE_1_BUTTON), ButtonElement(
                True, MIDI_CC_TYPE, CHANNEL, OP1_MODE_2_BUTTON), ButtonElement(
                    True, MIDI_CC_TYPE, CHANNEL,
                    OP1_MODE_3_BUTTON), ButtonElement(True, MIDI_CC_TYPE,
                                                      CHANNEL,
                                                      OP1_MODE_4_BUTTON),

        # initializing operation mode selector
        self._operation_mode_selector = OP1ModeSelectorComponent(
            self, self._transport, self._mixer, self._session)

        # setting operation mode selector buttons
        self._operation_mode_selector.set_mode_buttons(
            self._operation_mode_buttons)

        # adding value listener for operation mode index
        self._operation_mode_selector.add_mode_index_listener(
            self.mode_index_changed)

        # setting global transport assignments
        self._transport.set_record_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_REC_BUTTON))
        self._transport.set_play_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_PLAY_BUTTON))
        self._transport.set_stop_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_STOP_BUTTON))
        self._transport.set_metronome_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_METRONOME_BUTTON))
        self._transport.set_tap_tempo_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_HELP_BUTTON))
        self._transport.set_punch_buttons(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS1_BUTTON),
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS2_BUTTON))
        self._transport.set_loop_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS3_BUTTON))
        self._transport.set_overdub_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS4_BUTTON))

        # setting global session assignments
        self._session.set_scene_bank_buttons(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_COM),
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_MICRO))

        # setting misc listeners
        self.browser_toggle_button = ButtonElement(False, MIDI_CC_TYPE,
                                                   CHANNEL, 15)
        self.browser_toggle_button.add_value_listener(
            self.browser_toggle_button_callback)

        self.mainview_toggle_button = ButtonElement(False, MIDI_CC_TYPE,
                                                    CHANNEL, 16)
        self.mainview_toggle_button.add_value_listener(
            self.mainview_toggle_button_callback)

        self.detailview_toggle_button = ButtonElement(False, MIDI_CC_TYPE,
                                                      CHANNEL, 17)
        self.detailview_toggle_button.add_value_listener(
            self.detailview_toggle_button_callback)

        self.clear_track_button = ButtonElement(True, MIDI_CC_TYPE, CHANNEL,
                                                25)
        self.clear_track_button.add_value_listener(
            self.clear_track_button_callback)

        self.back_to_arranger_button = ButtonElement(True, MIDI_CC_TYPE,
                                                     CHANNEL, 26)
        self.back_to_arranger_button.add_value_listener(
            self.back_to_arranger_button_callback)

        # adding value listener for selected track change
        self.song().view.add_selected_track_listener(
            self.selected_track_changed)

        # adding value listener for selected scene change
        self.song().view.add_selected_scene_listener(
            self.selected_scene_changed)

        # setting assignments for currently selected track
        self.selected_track_changed()

        # setting assignments for currently selected scene
        self.selected_scene_changed()
コード例 #59
0
class OP1(ControlSurface):
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        self.c_instance = c_instance

        self.retries_count = 0
        self.device_connected = False

        self.clip_color_callbacks = {}
        self.slot_callbacks = {}

        self.text_start_sequence = (0xf0, 0x0, 0x20, 0x76, 0x00, 0x03)
        self.text_end_sequence = (0xf7, )
        self.enable_sequence = (0xf0, 0x00, 0x20, 0x76, 0x00, 0x01, 0x02, 0xf7)
        self.disable_sequence = (0xf0, 0x00, 0x20, 0x76, 0x00, 0x01, 0x00,
                                 0xf7)

        self.id_sequence = (0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7)

        self.text_color_start_sequence = (0xf0, 0x0, 0x20, 0x76, 0x00, 0x04)

        self.log('INITIALIZING')

        self.app = Live.Application.get_application()

        #maj = self.app.get_major_version()
        #min = self.app.get_minor_version()
        #bug = self.app.get_bugfix_version()
        #self.show_message(str(1) + "." + str(0) + "." + str(9))

        self.show_message("Version " + VERSION)

        # reseting text
        self.write_text(' ')

        # reset display clips
        self.reset_display_clips()

        # getting browser visible state
        self.session_browser_visible = self.app.view.is_view_visible("Browser")

        # getting browser visible state
        self.arrange_browser_visible = self.app.view.is_view_visible("Browser")

        # getting session view visible state
        self.session_visible = self.app.view.is_view_visible("Session")

        # getting arrange view visible state
        self.arrange_visible = self.app.view.is_view_visible("Arranger")

        # getting detail view visible state
        self.detail_visible = self.app.view.is_view_visible("Detail")

        # getting back to arranger state
        self.back_to_arranger_state = self.song().back_to_arranger

        # initializing channel strip to null
        self._channel_strip = None

        # initializing transport component
        self._transport = TransportComponent()

        # initializing mixer component
        self._mixer = MixerComponent(NUM_TRACKS, 2)

        # initializing session component
        self._session = SessionComponent(NUM_TRACKS, NUM_ROWS)
        self._session.add_offset_listener(self.session_offset_changed)

        # configuring operation mode selector buttons
        self._operation_mode_buttons = ButtonElement(
            True, MIDI_CC_TYPE, CHANNEL, OP1_MODE_1_BUTTON), ButtonElement(
                True, MIDI_CC_TYPE, CHANNEL, OP1_MODE_2_BUTTON), ButtonElement(
                    True, MIDI_CC_TYPE, CHANNEL,
                    OP1_MODE_3_BUTTON), ButtonElement(True, MIDI_CC_TYPE,
                                                      CHANNEL,
                                                      OP1_MODE_4_BUTTON),

        # initializing operation mode selector
        self._operation_mode_selector = OP1ModeSelectorComponent(
            self, self._transport, self._mixer, self._session)

        # setting operation mode selector buttons
        self._operation_mode_selector.set_mode_buttons(
            self._operation_mode_buttons)

        # adding value listener for operation mode index
        self._operation_mode_selector.add_mode_index_listener(
            self.mode_index_changed)

        # setting global transport assignments
        self._transport.set_record_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_REC_BUTTON))
        self._transport.set_play_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_PLAY_BUTTON))
        self._transport.set_stop_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_STOP_BUTTON))
        self._transport.set_metronome_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_METRONOME_BUTTON))
        self._transport.set_tap_tempo_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_HELP_BUTTON))
        self._transport.set_punch_buttons(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS1_BUTTON),
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS2_BUTTON))
        self._transport.set_loop_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS3_BUTTON))
        self._transport.set_overdub_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS4_BUTTON))

        # setting global session assignments
        self._session.set_scene_bank_buttons(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_COM),
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_MICRO))

        # setting misc listeners
        self.browser_toggle_button = ButtonElement(False, MIDI_CC_TYPE,
                                                   CHANNEL, 15)
        self.browser_toggle_button.add_value_listener(
            self.browser_toggle_button_callback)

        self.mainview_toggle_button = ButtonElement(False, MIDI_CC_TYPE,
                                                    CHANNEL, 16)
        self.mainview_toggle_button.add_value_listener(
            self.mainview_toggle_button_callback)

        self.detailview_toggle_button = ButtonElement(False, MIDI_CC_TYPE,
                                                      CHANNEL, 17)
        self.detailview_toggle_button.add_value_listener(
            self.detailview_toggle_button_callback)

        self.clear_track_button = ButtonElement(True, MIDI_CC_TYPE, CHANNEL,
                                                25)
        self.clear_track_button.add_value_listener(
            self.clear_track_button_callback)

        self.back_to_arranger_button = ButtonElement(True, MIDI_CC_TYPE,
                                                     CHANNEL, 26)
        self.back_to_arranger_button.add_value_listener(
            self.back_to_arranger_button_callback)

        # adding value listener for selected track change
        self.song().view.add_selected_track_listener(
            self.selected_track_changed)

        # adding value listener for selected scene change
        self.song().view.add_selected_scene_listener(
            self.selected_scene_changed)

        # setting assignments for currently selected track
        self.selected_track_changed()

        # setting assignments for currently selected scene
        self.selected_scene_changed()

    def handle_sysex(self, midi_bytes):
        if ((midi_bytes[6] == 32) and (midi_bytes[7] == 118)):
            self.device_connected = True
            self.log("OP-1 CONNECTED. SENDING ABLETON LIVE MODE INIT SEQUENCE")
            self._send_midi(self.enable_sequence)

    def add_clip_slot_listeners(self):
        #self.log('ADDING CLIP SLOT LISTENERS')

        # creating an empty list for all clip slots
        clip_slots = []

        # getting a reference to all tracks
        tracks = self.song().tracks

        # appending all tracks clip slots to clip_slots
        for track in tracks:
            clip_slots.append(track.clip_slots)

        # iterating over all clip slots
        for t in range(len(clip_slots)):
            for c in range(len(clip_slots[t])):
                clip_slot = clip_slots[t][c]

                # adding has clip listener to clip slot
                self.add_slot_listener(clip_slot)

                # if clip slot has clip
                if clip_slot.has_clip:
                    # adding clip listeners
                    self.add_clip_listener(clip_slot.clip)

    def rem_clip_slot_listeners(self):
        #self.log('REMOVING CLIP SLOT LISTENERS')

        # iterate over all clip color change callbacks
        for c in self.clip_color_callbacks:
            # if clip still exists
            if c != None:
                # and it has a has clip listener
                if c.color_has_listener(self.clip_color_callbacks[c]) == 1:
                    # remove it
                    c.remove_color_listener(self.clip_color_callbacks[c])

        # iterate over all clip slot callbacks
        for cs in self.slot_callbacks:
            # if clip slot still exists
            if cs != None:
                # and it has a has clip listener
                if cs.has_clip_has_listener(self.slot_callbacks[cs]) == 1:
                    # remove it
                    cs.remove_has_clip_listener(self.slot_callbacks[cs])

    def add_slot_listener(self, cs):
        # setting has clip listener
        callback = lambda: self.has_clip_listener(cs)

        # if we don't have a clip slot has clip listener for this clip slot yet
        if not (self.slot_callbacks.has_key(cs)):
            # adding has clip callback to clip slot
            cs.add_has_clip_listener(callback)

            # saving callback for future release
            self.slot_callbacks[cs] = callback

    def add_clip_listener(self, clip):
        # setting callback for clip color change
        color_callback = lambda: self.update_display_clips()

        # if we don't have a clip color change callback for this clip yet
        if not (self.clip_color_callbacks.has_key(clip)):
            # adding clip color change callback
            clip.add_color_listener(color_callback)

            # saving callback for future release
            self.clip_color_callbacks[clip] = color_callback

    def has_clip_listener(self, cs):
        # clip slot has clip listener callback
        if cs.has_clip:
            # add clip listener
            self.add_clip_listener(cs.clip)
        else:
            # update display if clip slot was removed
            self.update_display_clips()

    def session_offset_changed(self):
        # if session component offset changes, update display
        self.update_display_clips()

    def selected_scene_changed(self):
        # if on clip mode update display
        if (self._operation_mode_selector.mode_index == OP1_MODE_CLIP):
            self.update_display_clip_mode()

    def mode_index_changed(self):
        # update display to current mode info
        if (self._operation_mode_selector.mode_index == OP1_MODE_PERFORM):
            self.update_display_perform_mode()
        elif (self._operation_mode_selector.mode_index == OP1_MODE_CLIP):
            self.update_display_clip_mode()
        elif (self._operation_mode_selector.mode_index == OP1_MODE_TRANSPORT):
            self.update_display_transport_mode()
        elif (self._operation_mode_selector.mode_index == OP1_MODE_MIXER):
            self.update_display_mixer_mode()

    def clear_track_button_callback(self, value):
        # if clear track button was called, reset track
        if (value == 127):
            for i in range(len(self.song().tracks)):
                self.song().tracks[i].arm = 0
                self.song().tracks[i].solo = 0
                self.song().tracks[i].mute = 0

            for i in range(len(self.song().return_tracks)):
                self.song().tracks[i].solo = 0
                self.song().tracks[i].mute = 0

    def clear_return_track_assignment(self, strip):
        # clear return track assingments
        strip.set_volume_control(None)
        strip.set_pan_control(None)
        strip.set_mute_button(None)
        strip.set_solo_button(None)

    def clear_track_assignment(self, strip):
        # clear track assignments
        strip.set_volume_control(None)
        strip.set_pan_control(None)
        strip.set_mute_button(None)
        strip.set_solo_button(None)
        strip.set_arm_button(None)

    def clear_tracks_assigments(self):
        # for all normal tracks, clear assignments
        for i in range(NUM_TRACKS):
            strip = self._mixer.channel_strip(i)
            if (strip != None):
                self.clear_track_assignment(strip)

        # for all return tracks, clear assignments
        for i in range(2):
            return_strip = self._mixer.return_strip(i)
            if (return_strip != None):
                self.clear_return_track_assignment(return_strip)

    def selected_track_changed(self):
        # if on mixer mode update display
        if (self._operation_mode_selector.mode_index == OP1_MODE_MIXER):
            self.update_display_mixer_mode()

        # clear track assignments
        self.clear_tracks_assigments()

        # getting selected strip
        self._channel_strip = self._mixer.selected_strip()

        # perform track assignments
        self._channel_strip.set_volume_control(
            EncoderElement(MIDI_CC_TYPE, CHANNEL, OP1_ENCODER_1,
                           Live.MidiMap.MapMode.relative_two_compliment))
        self._channel_strip.set_pan_control(
            EncoderElement(MIDI_CC_TYPE, CHANNEL, OP1_ENCODER_2,
                           Live.MidiMap.MapMode.relative_two_compliment))

        # setting a tuple of encoders to control sends
        send_controls = EncoderElement(
            MIDI_CC_TYPE, CHANNEL, OP1_ENCODER_3,
            Live.MidiMap.MapMode.relative_two_compliment), EncoderElement(
                MIDI_CC_TYPE, CHANNEL, OP1_ENCODER_4,
                Live.MidiMap.MapMode.relative_two_compliment),

        # setting send encoders
        self._channel_strip.set_send_controls(tuple(send_controls))

        # setting solo button
        self._channel_strip.set_solo_button(
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS6_BUTTON))

        # if track can be armed, set arm button
        if (self._channel_strip._track.can_be_armed):
            self._channel_strip.set_arm_button(
                ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS7_BUTTON))

        # if track is no master, set mute button
        if (self._channel_strip._track != self.song().master_track):
            self._channel_strip.set_mute_button(
                ButtonElement(True, MIDI_CC_TYPE, CHANNEL, OP1_SS5_BUTTON))

    def browser_toggle_button_callback(self, value):
        if (value == 127):
            if (self.session_visible):
                if (self.session_browser_visible == True):
                    self.session_browser_visible = False
                    self.app.view.hide_view("Browser")
                else:
                    self.session_browser_visible = True
                    self.app.view.show_view("Browser")

            if (self.arrange_visible):
                if (self.arrange_browser_visible == True):
                    self.arrange_browser_visible = False
                    self.app.view.hide_view("Browser")
                else:
                    self.arrange_browser_visible = True
                    self.app.view.show_view("Browser")

    def back_to_arranger_button_callback(self, value):
        if (value == 127):
            self.song().back_to_arranger = False

    def mainview_toggle_button_callback(self, value):
        if (value == 127):
            if (self.session_visible == True):
                self.session_visible = False
                self.arrange_visible = True
                self.app.view.show_view("Arranger")
                self.arrange_browser_visible = self.app.view.is_view_visible(
                    "Browser")
            else:
                self.session_visible = True
                self.arrange_visible = False
                self.app.view.show_view("Session")
                self.session_browser_visible = self.app.view.is_view_visible(
                    "Browser")

    def detailview_toggle_button_callback(self, value):
        if (value == 127):
            if (self.detail_visible == True):
                self.detail_visible = False
                self.app.view.hide_view("Detail")
            else:
                self.detail_visible = True
                self.app.view.show_view("Detail")

    def write_text(self, msg):
        text_list = []
        sequence = ()

        text_list.append(len(msg.strip()))

        for i in msg.strip():
            text_list.append(ord(i))

        sequence = self.text_start_sequence + tuple(
            text_list) + self.text_end_sequence

        self._send_midi(sequence)

    def suggest_input_port(self):
        return "OP-1 Midi Device"

    def suggest_output_port(self):
        return "OP-1 Midi Device"

    def update_display_perform_mode(self):
        self.write_text("perform\rmode")

    def reset_display_clips(self):
        count = 0
        colors = []
        length = []
        sequence = ()

        for i in range(NUM_TRACKS):
            count += 1

            colors.append(0x00)
            colors.append(0x00)
            colors.append(0x00)

        length.append(count)
        sequence = self.text_color_start_sequence + tuple(length) + tuple(
            colors) + self.text_end_sequence
        self._send_midi(sequence)

    def update_display_clips(self):
        #self.log("UPDATING DISPLAY CLIPS")
        count = 0
        colors = []
        length = []
        sequence = ()

        tracks_len = len(self.song().tracks) - self._session._track_offset

        if (tracks_len > NUM_TRACKS):
            tracks_len = NUM_TRACKS

        for i in range(tracks_len):
            count += 1

            clip_slot = self._session.scene(0).clip_slot(i)

            if (clip_slot != None):
                if (clip_slot.has_clip() != False):
                    clip_color = clip_slot._clip_slot.clip.color
                    colors.append(((clip_color >> 16) & 0x000000ff) >> 1)
                    colors.append(((clip_color >> 8) & 0x000000ff) >> 1)
                    colors.append((clip_color & 0x000000ff) >> 1)
                else:
                    colors.append(0x00)
                    colors.append(0x00)
                    colors.append(0x00)
            else:
                colors.append(0x00)
                colors.append(0x00)
                colors.append(0x00)

        length.append(count)
        sequence = self.text_color_start_sequence + tuple(length) + tuple(
            colors) + self.text_end_sequence
        self._send_midi(sequence)

    def update_display_clip_mode(self):
        self.write_text(
            "sel. scene\r" +
            str(self.song().view.selected_scene.name.lower().strip()))

    def update_display_transport_mode(self):
        song_time = str(self.song().get_current_beats_song_time())
        self.write_text("song pos.\r" + song_time[:len(song_time) - 4])

    def update_display_mixer_mode(self):
        self.write_text("sel. track\r" +
                        str(self.song().view.selected_track.name.lower()))

    def update_display(self):
        if not (self.device_connected):
            if (self.retries_count < 5):
                self.log("TRYING OP-1 CONNECTION")
                self.retries_count += 1
                self._send_midi(self.id_sequence)
                time.sleep(1)

        # if in transport mode, update display with song position
        if (self._operation_mode_selector.mode_index == OP1_MODE_TRANSPORT):
            self.update_display_transport_mode()

        # checking if app current view is session
        if (self.app.view.is_view_visible("Session")):
            # checking if session browser state is diferent from the internal
            if (self.session_browser_visible !=
                    self.app.view.is_view_visible("Browser")):
                self.session_browser_visible = self.app.view.is_view_visible(
                    "Browser")

        # checking if app current view is arrange
        if (self.app.view.is_view_visible("Arranger")):
            # checking if arrange browser state is diferent from the internal
            if (self.arrange_browser_visible !=
                    self.app.view.is_view_visible("Browser")):
                self.arrange_browser_visible = self.app.view.is_view_visible(
                    "Browser")

        # checking if app current view is detail
        if (self.app.view.is_view_visible("Detail")):
            # checking if detail state is diferent from the internal
            if (self.detail_visible !=
                    self.app.view.is_view_visible("Detail")):
                self.detail_visible = self.app.view.is_view_visible("Detail")

    def refresh_state(self):
        self.log("REFRESH STATE")
        self.retries_count = 0
        self.device_connected = False

    def build_midi_map(self, midi_map_handle):
        #self.log("BUILD MIDI MAP")

        assert (self._suppress_requests_counter == 0)
        self._in_build_midi_map = True
        self._midi_map_handle = midi_map_handle
        self._forwarding_registry = {}
        for control in self.controls:
            if isinstance(control, InputControlElement):
                control.install_connections()
        self._midi_map_handle = None
        self._in_build_midi_map = False
        if (self._pad_translations != None):
            self._c_instance.set_pad_translation(self._pad_translations)

        # remove clip listeners
        self.rem_clip_slot_listeners()

        # add clip listeners
        self.add_clip_slot_listeners()

        # update display
        self.update_display_clips()

    def log(self, msg):
        self.c_instance.log_message("[TE OP-1] " + msg)

    def disconnect(self):
        # removing clip slots listeners
        self.rem_clip_slot_listeners()

        # removing value listener for track changed
        self.song().view.remove_selected_track_listener(
            self.selected_track_changed)

        # removing value listener for scene changed
        self.song().view.remove_selected_scene_listener(
            self.selected_scene_changed)

        # removing value listener for operation mode index
        self._operation_mode_selector.remove_mode_index_listener(
            self.mode_index_changed)

        # removing global transport assignments
        self._transport.set_punch_buttons(None, None)
        self._transport.set_loop_button(None)
        self._transport.set_overdub_button(None)
        self._transport.set_record_button(None)
        self._transport.set_play_button(None)
        self._transport.set_stop_button(None)
        self._transport.set_metronome_button(None)
        self._transport.set_tap_tempo_button(None)

        # removing global session assignments
        self._session.set_scene_bank_buttons(None, None)

        # removing misc listeners
        self.browser_toggle_button.remove_value_listener(
            self.browser_toggle_button_callback)
        self.mainview_toggle_button.remove_value_listener(
            self.mainview_toggle_button_callback)
        self.detailview_toggle_button.remove_value_listener(
            self.detailview_toggle_button_callback)
        self.clear_track_button.remove_value_listener(
            self.clear_track_button_callback)
        self.back_to_arranger_button.remove_value_listener(
            self.back_to_arranger_button_callback)

        # sending special ableton mode disable sequence
        self._send_midi(self.disable_sequence)

        # disconnecting control surface
        ControlSurface.disconnect(self)

        self.log("DISCONNECTED")
コード例 #60
0
class KeyLab(ArturiaControlSurface):
    def __init__(self, *a, **k):
        super(KeyLab, self).__init__(*a, **k)
        with self.component_guard():
            self._create_controls()
            self._create_display()
            self._create_device()
            self._create_drums()
            self._create_transport()
            self._create_session()
            self._create_session_recording()
            self._create_mixer()

    def _create_controls(self):
        self._device_encoders = ButtonMatrixElement(rows=[[
            EncoderElement(MIDI_CC_TYPE,
                           ENCODER_CHANNEL,
                           identifier,
                           Live.MidiMap.MapMode.relative_smooth_binary_offset,
                           name=b'Device_Encoder_%d_%d' %
                           (col_index, row_index))
            for col_index, identifier in enumerate(row)
        ] for row_index, row in enumerate((ENCODER_MSG_IDS[:4],
                                           ENCODER_MSG_IDS[4:8]))])
        self._horizontal_scroll_encoder = EncoderElement(
            MIDI_CC_TYPE,
            ENCODER_CHANNEL,
            ENCODER_MSG_IDS[(-2)],
            Live.MidiMap.MapMode.relative_smooth_binary_offset,
            name=b'Horizontal_Scroll_Encoder')
        self._vertical_scroll_encoder = EncoderElement(
            MIDI_CC_TYPE,
            ENCODER_CHANNEL,
            ENCODER_MSG_IDS[(-1)],
            Live.MidiMap.MapMode.relative_smooth_binary_offset,
            name=b'Vertical_Scroll_Encoder')
        self._volume_sliders = ButtonMatrixElement(rows=[[
            SliderElement(MIDI_CC_TYPE, ENCODER_CHANNEL, identifier)
            for identifier in SLIDER_MSG_IDS[:-1]
        ]])
        self._master_slider = SliderElement(MIDI_CC_TYPE, ENCODER_CHANNEL,
                                            SLIDER_MSG_IDS[(-1)])

        def make_keylab_button(name):
            button = ButtonElement(True,
                                   MIDI_CC_TYPE,
                                   0,
                                   get_button_identifier_by_name(name),
                                   name=name.title())
            return button

        for button_name in BUTTON_HARDWARE_AND_MESSAGE_IDS.keys():
            setattr(self, b'_' + button_name, make_keylab_button(button_name))

        self._pads = ButtonMatrixElement(rows=[[
            ButtonElement(True,
                          MIDI_CC_TYPE,
                          PAD_CHANNEL,
                          col_index + row_offset,
                          name=b'Pad_%d_%d' % (col_index, row_index))
            for col_index in xrange(4)
        ] for row_index, row_offset in enumerate(xrange(48, 35, -4))])

    def _create_display(self):
        self._display_line1, self._display_line2 = DisplayElement(
            16, 1), DisplayElement(16, 1)
        for index, display_line in enumerate(
            (self._display_line1, self._display_line2)):
            display_line.set_message_parts(SETUP_MSG_PREFIX + (4, 0, 96),
                                           SETUP_MSG_SUFFIX)
            display_line.segment(0).set_position_identifier((index + 1, ))

        def adjust_null_terminated_string(string, width):
            return string.ljust(width, b' ') + b'\x00'

        self._display_line1_data_source, self._display_line2_data_source = DisplayDataSource(
            adjust_string_fn=adjust_null_terminated_string), DisplayDataSource(
                adjust_string_fn=adjust_null_terminated_string)
        self._display_line1.segment(0).set_data_source(
            self._display_line1_data_source)
        self._display_line2.segment(0).set_data_source(
            self._display_line2_data_source)
        self._display_line1_data_source.set_display_string(b'KeyLab')
        self._display_line2_data_source.set_display_string(b'Ableton Live')

    def _create_device(self):
        self._device = DeviceComponent(
            name=b'Device',
            is_enabled=False,
            layer=Layer(parameter_controls=self._device_encoders),
            device_selection_follows_track_selection=True)
        self._device.set_enabled(True)
        self.set_device_component(self._device)
        self._device_navigation = DeviceNavigationComponent(
            name=b'Device_Navigation',
            is_enabled=False,
            layer=Layer(device_nav_left_button=self._device_left_button,
                        device_nav_right_button=self._device_right_button))
        self._device_navigation.set_enabled(True)

    def _create_drums(self):
        self._drums = DrumRackComponent(name=b'Drums',
                                        is_enabled=False,
                                        layer=Layer(pads=self._pads))
        self._drums.set_enabled(True)

    def _create_transport(self):
        self._transport = TransportComponent(
            name=b'Transport',
            is_enabled=False,
            layer=Layer(play_button=self._play_button,
                        stop_button=self._stop_button,
                        record_button=self._record_button,
                        loop_button=self._loop_button))
        self._transport.set_enabled(True)

    def _create_session(self):
        self._session = SessionComponent(
            num_tracks=8,
            num_scenes=1,
            name=b'Session',
            is_enabled=False,
            layer=Layer(select_next_button=self._scene_down_button,
                        select_prev_button=self._scene_up_button,
                        selected_scene_launch_button=self._scene_launch_button,
                        stop_all_clips_button=self._stop_all_clips_button,
                        scene_select_encoder=self._vertical_scroll_encoder))
        self._session.set_enabled(True)

    def _create_session_recording(self):
        self._session_recording = SessionRecordingComponent(
            ClipCreator(),
            ViewControlComponent(),
            name=b'Session_Recording',
            is_enabled=False,
            layer=Layer(record_button=self._session_record_button))
        self._session_recording.set_enabled(True)

    def _create_mixer(self):
        self._mixer = MixerComponent(
            num_tracks=self._volume_sliders.width(),
            name=b'Mixer',
            is_enabled=False,
            layer=Layer(volume_controls=self._volume_sliders,
                        track_select_encoder=self._horizontal_scroll_encoder))
        self._mixer.master_strip().layer = Layer(
            volume_control=self._master_slider)
        self._mixer.set_enabled(True)

    def _collect_setup_messages(self):
        for hardware_id, identifier in izip(ENCODER_HARDWARE_IDS,
                                            ENCODER_MSG_IDS):
            self._setup_hardware_encoder(hardware_id, identifier,
                                         ENCODER_CHANNEL)

        for hardware_id, identifier in izip(SLIDER_HARDWARE_IDS,
                                            SLIDER_MSG_IDS):
            self._setup_hardware_slider(hardware_id, identifier,
                                        ENCODER_CHANNEL)

        for hardware_id, identifier in BUTTON_HARDWARE_AND_MESSAGE_IDS.itervalues(
        ):
            self._setup_hardware_button(hardware_id, identifier)

        for hardware_id, identifier in izip(PAD_HARDWARE_IDS, PAD_MSG_IDS):
            self._setup_hardware_pad(hardware_id, identifier)

    def _setup_hardware_encoder(self, hardware_id, identifier, channel=0):
        self._set_encoder_cc_msg_type(hardware_id, is_relative=True)
        self._set_identifier(hardware_id, identifier)
        self._set_channel(hardware_id, channel)

    def _setup_hardware_button(self, hardware_id, identifier, channel=0, **k):
        self._set_encoder_cc_msg_type(hardware_id)
        self._set_identifier(hardware_id, identifier)
        self._set_channel(hardware_id, channel)
        self._set_value_minimum(hardware_id)
        self._set_value_maximum(hardware_id)

    def _setup_hardware_pad(self,
                            hardware_id,
                            identifier,
                            channel=PAD_CHANNEL):
        self._set_pad_note_msg_type(hardware_id)
        self._set_identifier(hardware_id, identifier)
        self._set_channel(hardware_id, channel)

    def _set_pad_note_msg_type(self, hardware_id):
        self._collect_setup_message(MODE_PROPERTY, hardware_id, PAD_NOTE_MODE)