本文整理汇总了Python中_Framework.SessionZoomingComponent.SessionZoomingComponent类的典型用法代码示例。如果您正苦于以下问题:Python SessionZoomingComponent类的具体用法?Python SessionZoomingComponent怎么用?Python SessionZoomingComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionZoomingComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, session, stop_buttons):
SessionZoomingComponent.__init__(self, session)
self._stop_buttons = stop_buttons
self._ignore_buttons = False
for button in self._stop_buttons:
assert isinstance(button, ButtonElement)
button.add_value_listener(self._stop_value, identify_sender=True)
示例2: update
def update(self):
if (not self._ignore_buttons):
SessionZoomingComponent.update(self)
elif self.is_enabled():
if (self._scene_bank_buttons != None):
for button in self._scene_bank_buttons:
button.turn_off()
示例3: __init__
def __init__(self, matrix, top_buttons, side_buttons, config_button):
raise isinstance(matrix, ButtonMatrixElement) or AssertionError
raise matrix.width() == 8 and matrix.height() == 8 or AssertionError
raise isinstance(top_buttons, tuple) or AssertionError
raise len(top_buttons) == 8 or AssertionError
raise isinstance(side_buttons, tuple) or AssertionError
raise len(side_buttons) == 8 or AssertionError
raise isinstance(config_button, ButtonElement) or AssertionError
ModeSelectorComponent.__init__(self)
self._session = SpecialSessionComponent(matrix.width(), matrix.height())
self._zooming = SessionZoomingComponent(self._session)
self._session.name = 'Session_Control'
self._zooming.name = 'Session_Overview'
self._matrix = matrix
self._side_buttons = side_buttons
self._nav_buttons = top_buttons[:4]
self._config_button = config_button
self._zooming.set_empty_value(LED_OFF)
self._all_buttons = []
for button in self._side_buttons + self._nav_buttons:
self._all_buttons.append(button)
self._sub_modes = SubSelectorComponent(matrix, side_buttons, self._session)
self._sub_modes.name = 'Mixer_Modes'
self._sub_modes.set_update_callback(self._update_control_channels)
self._init_session()
self._all_buttons = tuple(self._all_buttons)
self.set_modes_buttons(top_buttons[4:])
示例4: _setup_session_control
def _setup_session_control(self):
is_momentary = True
num_tracks = NUM_TRACKS
num_scenes = NUM_SCENES
self._session = SessionComponent(num_tracks, num_scenes)
self._session.name = "Session"
self._session.set_offsets(0, 0)
self._session.set_stop_track_clip_value(STOP_CLIP)
self._scene = [None for index in range(3)]
for row in range(num_scenes):
self._scene[row] = self._session.scene(row)
self._scene[row].name = 'Scene_' + str(row)
for column in range(num_tracks):
clip_slot = self._scene[row].clip_slot(column)
clip_slot.name = str(column) + '_Clip_Slot_' + str(row)
clip_slot.set_triggered_to_play_value(CLIP_TRG_PLAY)
clip_slot.set_triggered_to_record_value(CLIP_TRG_REC)
clip_slot.set_stopped_value(CLIP_STOP)
clip_slot.set_started_value(CLIP_STARTED)
clip_slot.set_recording_value(CLIP_RECORDING)
self._session._stop_track_value = self._session_stop_track_value(self._session)
self._session._on_fired_slot_index_changed = self._session_on_fired_slot_index_changed(self._session)
self._session._change_offsets = self._session_change_offsets(self._session)
self._session.update = self._session_update(self._session)
#self._session.add_offset_listener(self._update_navigation_view)
self._session.set_mixer(self._mixer)
self.set_highlighting_session_component(self._session)
self._session_zoom = SessionZoomingComponent(self._session)
self._session_zoom.name = 'Session_Overview'
self._session_zoom.set_stopped_value(ZOOM_STOPPED)
self._session_zoom.set_playing_value(ZOOM_PLAYING)
self._session_zoom.set_selected_value(ZOOM_SELECTED)
示例5: _setup_session_control
def _setup_session_control(self):
is_momentary = True
num_tracks = 8 #we are working with a 4x4 grid,
num_scenes = 4 #so the height and width are both set to 4
self._session = SessionComponent(num_tracks, num_scenes) #we create our SessionComponent with the variables we set above it
self._session.name = "Session" #we name it so we can access it in m4l
self._session.set_offsets(0, 0) #we set the initial offset to the far left, top of the session grid
self._session._track_banking_increment = 4
self._session.set_stop_clip_value(STOP_CLIP[self._rgb]) #we assign the colors that will be displayed when the stop_clip button is pressed. This value comes from CNTRLR_Map.py, which is imported in the header of our script
self._scene = [None for index in range(4)] #we create an array to hold the Scene subcomponents so that we can get to them if we need them.
for row in range(num_scenes): #now we'll fill the array with different objects that were created when we called the SessionComponent() module
self._scene[row] = self._session.scene(row) #each session row is a SceneComponent
self._scene[row].name = 'Scene_' + str(row) #name it so we can access it in m4l
for column in range(num_tracks): #now we'll create holders and names for the contents of each scene
clip_slot = self._scene[row].clip_slot(column) #we use our assignment of the scene above to gain access to the individual clipslots. Here, we are just assigning 'clip_slot' each time as a local variable so we can manipulated it's properties
clip_slot.name = str(column) + '_Clip_Slot' + str(row) #name it so that we can acces it in m4l
clip_slot.set_triggered_to_play_value(CLIP_TRG_PLAY[self._rgb]) #set its triggered to play color
clip_slot.set_triggered_to_record_value(CLIP_TRG_REC[self._rgb])#set its triggered to record color
clip_slot.set_stopped_value(CLIP_STOP[self._rgb]) #set its stop color
clip_slot.set_started_value(CLIP_STARTED[self._rgb]) #set its started color
clip_slot.set_recording_value(CLIP_RECORDING[self._rgb]) #set its recording value
self._session.set_mixer(self._mixer) #now we link the MixerComponent we created in _setup_mixer_control() to our session component so that they will follow each other when either is navigated
self.set_highlighting_session_component(self._session)
self._session_zoom = SessionZoomingComponent(self._session) #this creates the ZoomingComponent that allows navigation when the shift button is pressed
self._session_zoom.name = 'Session_Overview' #name it so we can access it in m4l
self._session_zoom.set_stopped_value(ZOOM_STOPPED[self._rgb]) #set the zooms stopped color
self._session_zoom.set_playing_value(ZOOM_PLAYING[self._rgb]) #set the zooms playing color
self._session_zoom.set_selected_value(ZOOM_SELECTED[self._rgb]) #set the zooms selected color
self._session_zoom.set_button_matrix(self._matrix) #assign the ButtonMatrixElement that we created in _setup_controls() to the zooming component so that we can control it
self._session_zoom.set_zoom_button(self._button[31]) #assign a shift button so that we can switch states between the SessionComponent and the SessionZoomingComponent
示例6: _setup_session_control
def _setup_session_control(self):
is_momentary = True
num_tracks = COLS
num_scenes = ROWS
global session
session = SessionComponent(num_tracks, num_scenes)
session.name = "Session"
session.set_offsets(0, 0)
self._session = session
self._session.set_stop_track_clip_value(0)
self._scene = [None for index in range(ROWS)]
for row in range(num_scenes):
self._scene[row] = session.scene(row)
self._scene[row].name = 'Scene_' + str(row)
for column in range(num_tracks):
clip_slot = self._scene[row].clip_slot(column)
clip_slot.name = str(column) + '_Clip_Slot_' + str(row)
clip_slot.set_triggered_to_play_value(64)
clip_slot.set_triggered_to_record_value(64)
clip_slot.set_stopped_value(0)
clip_slot.set_started_value(64)
clip_slot.set_recording_value(64)
#clip_slot.set_launch_button(self._grid[column][row]) #comment out if you don't want clip launch
session.set_mixer(mixer)
self._session_zoom = SessionZoomingComponent(session)
self._session_zoom.name = 'Session_Overview'
self._session_zoom.set_stopped_value(0)
self._session_zoom.set_playing_value(64)
self._session_zoom.set_selected_value(64)
if STANDALONE is True:
self.set_highlighting_session_component(self._session)
self._session.set_track_bank_buttons(self._grid[5][3], self._grid[4][3]) #comment out when using with Griid
self._session.set_scene_bank_buttons(self._grid[7][3], self._grid[6][3]) # comment out when using with Griid
示例7: _setup_session_control
def _setup_session_control(self):
is_momentary = True
self._shift_button = AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 98, 'Shift_Button', self)
right_button = AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 96, 'Right_Button', self)
self._right_button = right_button
left_button = AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 97, 'Left_Button', self)
self._left_button = left_button
up_button = AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 94, 'Up_Button', self)
self._up_button = up_button
down_button = AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 95, 'Down_Button', self)
self._down_button = down_button
self._session = PedaledSessionComponent(8, 5)
self._session.name = 'Session_Control'
self._session.set_track_bank_buttons(right_button, left_button)
self._session.set_scene_bank_buttons(down_button, up_button)
matrix = ButtonMatrixElement()
self._matrix = matrix # added a
matrix.name = 'Button_Matrix'
scene_launch_buttons = [ ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, (index + 82)) for index in range(5) ]
track_stop_buttons = [ AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, index, 52, 'Track_' + str(index) + '_Stop_Button', self) for index in range(8) ]
self._track_stop_buttons = track_stop_buttons # added a
for index in range(len(scene_launch_buttons)):
scene_launch_buttons[index].name = 'Scene_'+ str(index) + '_Launch_Button'
stop_all_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 81)
stop_all_button.name = 'Stop_All_Clips_Button'
self._session.set_stop_all_clips_button(stop_all_button)
self._session.set_stop_track_clip_buttons(tuple(track_stop_buttons))
self._session.set_stop_track_clip_value(2)
for scene_index in range(5):
scene = self._session.scene(scene_index)
scene.name = 'Scene_' + str(scene_index)
button_row = []
scene.set_launch_button(scene_launch_buttons[scene_index])
scene.set_triggered_value(2)
for track_index in range(8):
button = AumPCMonoButtonElement(is_momentary, MIDI_NOTE_TYPE, track_index, (scene_index + 53), str(track_index) + '_Clip_' + str(scene_index) + '_Button', self)
#button.name = str(track_index) + '_Clip_' + str(scene_index) + '_Button'
button_row.append(button)
clip_slot = scene.clip_slot(track_index)
clip_slot.name = str(track_index) + '_Clip_Slot_' + str(scene_index)
clip_slot.set_triggered_to_play_value(2)
clip_slot.set_triggered_to_record_value(4)
clip_slot.set_stopped_value(5)
clip_slot.set_started_value(1)
clip_slot.set_recording_value(3)
clip_slot.set_launch_button(button)
matrix.add_row(tuple(button_row))
self._session.set_slot_launch_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 67))
self._session.selected_scene().name = 'Selected_Scene'
self._session.selected_scene().set_launch_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 64))
self._session_zoom = SessionZoomingComponent(self._session)
self._session_zoom.name = 'Session_Overview'
self._session_zoom.set_button_matrix(matrix)
self._session_zoom.set_zoom_button(self._shift_button)
self._session_zoom.set_nav_buttons(up_button, down_button, left_button, right_button)
self._session_zoom.set_scene_bank_buttons(tuple(scene_launch_buttons))
self._session_zoom.set_stopped_value(3)
self._session_zoom.set_selected_value(5)
示例8: __init__
def __init__(self,
session = None,
shift = None,
unselected_color = RED,
selected_color = GREEN,
**kwargs):
Elementary.__init__(self, **kwargs)
SessionZoomingComponent.__init__(self, session)
self.set_button_matrix(session.button_matrix)
self.set_zoom_button(self.button(shift, blink_on = True))
self.set_stopped_value(unselected_color)
self.set_selected_value(selected_color)
self.set_nav_buttons(session.up_button, session.down_button, session.left_button, session.right_button)
if hasattr(session, 'scene_launch_buttons'):
self.set_scene_bank_buttons(tuple(session.scene_launch_buttons))
示例9: __init__
def __init__(self, matrix, top_buttons, side_buttons, config_button, osd, parent):
assert isinstance(matrix, ButtonMatrixElement)
assert ((matrix.width() == 8) and (matrix.height() == 8))
assert isinstance(top_buttons, tuple)
assert (len(top_buttons) == 8)
assert isinstance(side_buttons, tuple)
assert (len(side_buttons) == 8)
assert isinstance(config_button, ButtonElement)
ModeSelectorComponent.__init__(self)
self._osd = osd
self._parent = parent
self._mode_index=0
self._previous_mode_index=-1
self._main_mode_index=0
self._sub_mode_index=[0,0,0,0]
for index in range(4):
self._sub_mode_index[index]=0
self.set_mode_buttons(top_buttons[4:])
self._session = SpecialSessionComponent(matrix.width(), matrix.height(),self)
self._session.set_osd(self._osd)
self._zooming = SessionZoomingComponent(self._session)
self._session.name = 'Session_Control'
self._zooming.name = 'Session_Overview'
self._matrix = matrix
self._side_buttons = side_buttons
self._nav_buttons = top_buttons[:4]
self._config_button = config_button
self._zooming.set_empty_value(LED_OFF)
self._all_buttons = []
for button in self._side_buttons + self._nav_buttons:
self._all_buttons.append(button)
self._sub_modes = SubSelectorComponent(matrix, side_buttons, self._session)
self._sub_modes.name = 'Mixer_Modes'
self._sub_modes._mixer.set_osd(self._osd)
self._sub_modes.set_update_callback(self._update_control_channels)
self._stepseq = StepSequencerComponent(self._matrix, self._side_buttons, self._nav_buttons, self)
self._stepseq.set_osd(self._osd)
self._stepseq2 = StepSequencerComponent2(self._matrix, self._side_buttons, self._nav_buttons, self)
self._stepseq2.set_osd(self._osd)
self._instrument_controller = InstrumentControllerComponent( self._matrix, self._side_buttons, self._nav_buttons,self)
self._instrument_controller.set_osd(self._osd)
self._device_controller = DeviceControllerComponent(self._matrix, self._side_buttons, self._nav_buttons, self)
self._device_controller.set_osd(self._osd)
self._init_session()
self._all_buttons = tuple(self._all_buttons)
示例10: _setup_session_control
def _setup_session_control(self):
is_momentary = True
num_tracks = 7
num_scenes = 5
global session
session = SessionComponent(num_tracks, num_scenes)
session.name = "Session"
self._session = session
session.set_offsets(0, 0)
self._scene = [None for index in range(6)]
for row in range(num_scenes):
self._scene[row] = session.scene(row)
self._scene[row].name = 'Scene_' + str(row)
for column in range(num_tracks):
clip_slot = self._scene[row].clip_slot(column)
clip_slot.name = str(column) + '_Clip_Slot_' + str(row)
session.set_mixer(self._mixer)
self._session_zoom = SessionZoomingComponent(session)
self._session_zoom.name = 'Session_Overview'
示例11: __init__
def __init__(self, matrix, top_buttons, side_buttons, config_button, knobs, sliders, script):
assert isinstance(matrix, ButtonMatrixElement)
assert ((matrix.width() == 8) and (matrix.height() == 8))
assert isinstance(top_buttons, tuple)
assert (len(top_buttons) == 8)
assert isinstance(side_buttons, tuple)
assert (len(side_buttons) == 8)
assert isinstance(config_button, ButtonElement)
ModeSelectorComponent.__init__(self)
self._script = script
self._session = SpecialSessionComponent(matrix.width(), matrix.height())
for scene in self._session._scenes:
for slot in scene._clip_slots:
slot._triggered_to_play_value = 4
slot._triggered_to_record_value = 3
slot._started_value = 2
slot._recording_value = 1
slot._stopped_value = 127
self._zooming = SessionZoomingComponent(self._session)
self._zooming._stopped_value = 127
self._zooming._playing_value = 2
self._zooming._selected_value = 1
self._matrix = matrix
self._knobs = knobs
self._sliders = sliders
self._side_buttons = side_buttons
self._nav_buttons = top_buttons[:4]
self._config_button = config_button
self._shift_button = top_buttons[5]
self._zooming.set_empty_value(LED_OFF)
self._all_buttons = []
for button in (self._side_buttons + self._nav_buttons):
self._all_buttons.append(button)
self._shift_pressed = 0
self._shift_pressed_timer = 0
self._last_normal_mode = 0
self._shift_button = None
self.set_shift_button(top_buttons[6])
self._sub_modes = SubSelectorComponent(matrix, side_buttons, self._session)
self._sub_modes.set_update_callback(self._update_control_channels)
self._init_session()
self._all_buttons = tuple(self._all_buttons)
self.set_modes_buttons(top_buttons[4:6])
示例12: __init__
def __init__(self, matrix, top_buttons, side_buttons, config_button, script):
assert isinstance(matrix, ButtonMatrixElement)
assert matrix.width() == 8 and matrix.height() == 8
assert isinstance(top_buttons, tuple)
assert len(top_buttons) == 8
assert isinstance(side_buttons, tuple)
assert len(side_buttons) == 8
assert isinstance(config_button, ButtonElement)
ModeSelectorComponent.__init__(self)
self._script = script
self._session = SpecialSessionComponent(matrix.width(), matrix.height())
"""for scene in self._session._scenes:
for slot in scene._clip_slots:
slot._triggered_to_play_value = 24
slot._triggered_to_record_value = 27
slot._started_value = 7
slot._recording_value = 9
slot._stopped_value = 8"""
self._zooming = SessionZoomingComponent(self._session)
self._session.name = "Session_Control"
self._zooming.name = "Session_Overview"
"""self._zooming._stopped_value = 9
self._zooming._playing_value = 7
self._zooming._selected_value = 8"""
self._matrix = matrix
self._side_buttons = side_buttons
self._nav_buttons = top_buttons[:4]
self._config_button = config_button
self._zooming.set_empty_value(LED_OFF)
self._all_buttons = []
for button in self._side_buttons + self._nav_buttons:
self._all_buttons.append(button)
self._sub_modes = SubSelectorComponent(matrix, side_buttons, self._session)
self._sub_modes.name = "Mixer_Modes"
self._sub_modes.set_update_callback(self._update_control_channels)
self._init_session()
self._all_buttons = tuple(self._all_buttons)
self.set_modes_buttons(top_buttons[4:])
if START_IN_MOD is True:
self._set_protected_mode_index(4)
示例13: _setup_session_control
def _setup_session_control(self):
is_momentary = True
self._shift_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 98)
right_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 96)
left_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 97)
up_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 94)
down_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 95)
right_button.name = 'Bank_Select_Right_Button'
left_button.name = 'Bank_Select_Left_Button'
up_button.name = 'Bank_Select_Up_Button'
down_button.name = 'Bank_Select_Down_Button'
self._session = PedaledSessionComponent(8, 5)
self._session.name = 'Session_Control'
self._session.set_track_bank_buttons(right_button, left_button)
self._session.set_scene_bank_buttons(down_button, up_button)
self._matrix = ButtonMatrixElement() #was: matrix = ButtonMatrixElement()
self._matrix.name = 'Button_Matrix' #was: matrix.name = 'Button_Matrix'
scene_launch_buttons = [ ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, (index + 82)) for index in range(5) ]
#self._track_stop_buttons = [ ButtonElement(is_momentary, MIDI_NOTE_TYPE, index, 52) for index in range(8) ]
self._track_stop_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, index, 52) for index in range(8) ]
for index in range(len(scene_launch_buttons)):
scene_launch_buttons[index].name = 'Scene_'+ str(index) + '_Launch_Button'
for index in range(len(self._track_stop_buttons)):
self._track_stop_buttons[index].name = 'Track_' + str(index) + '_Stop_Button'
stop_all_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 81)
stop_all_button.name = 'Stop_All_Clips_Button'
self._session.set_stop_all_clips_button(stop_all_button)
self._session.set_stop_track_clip_buttons(tuple(self._track_stop_buttons))
self._session.set_stop_track_clip_value(2)
for scene_index in range(5):
scene = self._session.scene(scene_index)
scene.name = 'Scene_' + str(scene_index)
button_row = []
scene.set_launch_button(scene_launch_buttons[scene_index])
scene.set_triggered_value(2)
for track_index in range(8):
#button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, track_index, (scene_index + 53))
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, track_index, (scene_index + 53)) #use Launchpad configurable button instead
button.name = str(track_index) + '_Clip_' + str(scene_index) + '_Button'
button_row.append(button)
clip_slot = scene.clip_slot(track_index)
clip_slot.name = str(track_index) + '_Clip_Slot_' + str(scene_index)
clip_slot.set_triggered_to_play_value(2)
clip_slot.set_triggered_to_record_value(4)
clip_slot.set_stopped_value(3)
clip_slot.set_started_value(1)
clip_slot.set_recording_value(5)
clip_slot.set_launch_button(button)
self._matrix.add_row(tuple(button_row)) #matrix.add_row(tuple(button_row))
# Removing the launch selected clip footpedal option
#self._session.set_slot_launch_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 67))
self._session.selected_scene().name = 'Selected_Scene'
self._session.selected_scene().set_launch_button(ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 64))
self._session_zoom = SessionZoomingComponent(self._session) #use APC20 Zooming instead
self._session_zoom.name = 'Session_Overview'
self._session_zoom.set_button_matrix(self._matrix) #was: self._session_zoom.set_button_matrix(matrix)
self._session_zoom.set_zoom_button(self._shift_button) #set in MatrixModesComponent instead
self._session_zoom.set_nav_buttons(up_button, down_button, left_button, right_button)
self._session_zoom.set_scene_bank_buttons(tuple(scene_launch_buttons))
self._session_zoom.set_stopped_value(3)
self._session_zoom.set_selected_value(5)
return None
示例14: _setup_session_control
def _setup_session_control(self):
is_momentary = True
num_tracks = 4
num_scenes = 4
global session #We want to instantiate the global session as a SessionComponent object (it was a global "None" type up until now...)
session = MaschineSessionComponent(num_tracks, num_scenes) #(num_tracks, num_scenes)
session.set_offsets(0, 0) #(track_offset, scene_offset) Sets the initial offset of the red box from top left
matrix = ButtonMatrixElement()
self._register_timer_callback(session.flash_clip_slots)
"""set up the session buttons"""
left_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL, 91)
right_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL, 93)
session.set_track_bank_buttons(right_button, left_button)
# Stop buttons
track_stop_buttons = [ ButtonElement(is_momentary, MIDI_CC_TYPE, 4, (55 + index)) for index in range(num_tracks) ]
session.set_stop_track_clip_buttons(tuple(track_stop_buttons))
up_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL, 81)
down_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL, 92)
session.set_scene_bank_buttons(down_button, up_button) # (up_button, down_button) This is to move the "red box" up or down (increment track up or down, not screen up or down, so they are inversed)
session.set_mixer(mixer) #Bind the mixer to the session so that they move together
selected_scene = self.song().view.selected_scene #this is from the Live API
all_scenes = self.song().scenes
index = list(all_scenes).index(selected_scene)
session.set_offsets(0, index) #(track_offset, scene_offset)
scene_launch_buttons = []
for scene_index in range(4):
scene = session.scene(scene_index)
launch_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 1, (124 + scene_index))
scene.set_launch_button(launch_button)
scene_launch_buttons.append(launch_button)
clip_launch_notes = [
[24, 25, 26, 27],
[20, 21, 22, 23],
[16, 17, 18, 19],
[12, 13, 14, 15],
]
for scene_index in range(num_scenes):
button_row = []
for track_index in range(num_tracks):
clip_slot = session.scene(scene_index).clip_slot(track_index)
clip_slot.set_triggered_to_record_value(127)
clip_slot.set_recording_value(127)
clip_slot.set_started_value(127)
clip_slot.set_stopped_value(127)
button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, 2, clip_launch_notes[scene_index][track_index])
clip_slot.set_launch_button(button)
button_row.append(button)
matrix.add_row(tuple(button_row))
session_zoom = SessionZoomingComponent(session)
session_zoom.set_zoom_button(self.shift_button)
session_zoom.set_nav_buttons(up_button, down_button, left_button, right_button)
session_zoom.set_scene_bank_buttons(tuple(scene_launch_buttons))
session_zoom.set_button_matrix(matrix)
session_zoom.set_stopped_value(0)
session_zoom.set_selected_value(127)
示例15: MainSelectorComponent
class MainSelectorComponent(ModeSelectorComponent):
""" Class that reassigns the button on the launchpad to different functions """
def __init__(self, matrix, top_buttons, side_buttons, config_button, script):
assert isinstance(matrix, ButtonMatrixElement)
assert matrix.width() == 8 and matrix.height() == 8
assert isinstance(top_buttons, tuple)
assert len(top_buttons) == 8
assert isinstance(side_buttons, tuple)
assert len(side_buttons) == 8
assert isinstance(config_button, ButtonElement)
ModeSelectorComponent.__init__(self)
self._script = script
self._session = SpecialSessionComponent(matrix.width(), matrix.height())
"""for scene in self._session._scenes:
for slot in scene._clip_slots:
slot._triggered_to_play_value = 24
slot._triggered_to_record_value = 27
slot._started_value = 7
slot._recording_value = 9
slot._stopped_value = 8"""
self._zooming = SessionZoomingComponent(self._session)
self._session.name = "Session_Control"
self._zooming.name = "Session_Overview"
"""self._zooming._stopped_value = 9
self._zooming._playing_value = 7
self._zooming._selected_value = 8"""
self._matrix = matrix
self._side_buttons = side_buttons
self._nav_buttons = top_buttons[:4]
self._config_button = config_button
self._zooming.set_empty_value(LED_OFF)
self._all_buttons = []
for button in self._side_buttons + self._nav_buttons:
self._all_buttons.append(button)
self._sub_modes = SubSelectorComponent(matrix, side_buttons, self._session)
self._sub_modes.name = "Mixer_Modes"
self._sub_modes.set_update_callback(self._update_control_channels)
self._init_session()
self._all_buttons = tuple(self._all_buttons)
self.set_modes_buttons(top_buttons[4:])
if START_IN_MOD is True:
self._set_protected_mode_index(4)
def disconnect(self):
for button in self._modes_buttons:
button.remove_value_listener(self._mode_value)
self._session = None
self._zooming = None
for button in self._all_buttons:
button.set_on_off_values(127, LED_OFF)
self._config_button.turn_off()
self._matrix = None
self._side_buttons = None
self._nav_buttons = None
self._config_button = None
ModeSelectorComponent.disconnect(self)
def session_component(self):
return self._session
def set_modes_buttons(self, buttons):
assert buttons == None or isinstance(buttons, tuple) or len(buttons) == self.number_of_modes()
identify_sender = True
for button in self._modes_buttons:
button.remove_value_listener(self._mode_value)
self._modes_buttons = []
if buttons != None:
for button in buttons:
assert isinstance(button, ButtonElement)
self._modes_buttons.append(button)
button.add_value_listener(self._mode_value, identify_sender)
self.set_mode(0)
def number_of_modes(self):
return 5
def on_enabled_changed(self):
self.update()
def set_mode(self, mode):
assert mode in range(self.number_of_modes())
if (self._mode_index != mode) or (mode == 3):
self._mode_index = mode
self.update()
def channel_for_current_mode(self):
new_channel = self._mode_index + self._sub_modes.mode()
if new_channel > 0:
new_channel += 3
return new_channel
def update(self):
assert self._modes_buttons != None
if self.is_enabled():
#.........这里部分代码省略.........