本文整理汇总了Python中MainSelectorComponent.MainSelectorComponent.session_component方法的典型用法代码示例。如果您正苦于以下问题:Python MainSelectorComponent.session_component方法的具体用法?Python MainSelectorComponent.session_component怎么用?Python MainSelectorComponent.session_component使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainSelectorComponent.MainSelectorComponent
的用法示例。
在下文中一共展示了MainSelectorComponent.session_component方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Launchpad
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class Launchpad(ControlSurface):
" SCRIPT FOR NOVATION'S LAUNCHPAD CONTROLLER "
" INITALIZE "
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
with self.component_guard():
#self.set_suppress_rebuild_requests(True)
self._suppress_send_midi = True
self._suppress_session_highlight = True
is_momentary = True
self._suggested_input_port = "Launchpad"
self._suggested_output_port = "Launchpad"
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = "User_Byte_Button"
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = (Live.Application.get_random_int(0, 400000000) & 2139062143)
matrix = ButtonMatrixElement()
matrix.name = "Button_Matrix"
""" TRACKFINDER TEST
track_index = 0
for track in self.song().tracks:
if track_index < 8:
button_row = []
if track.is_foldable:
for column in range(8):
log("right one: " + str(track_index))
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, ((track_index * 16) + column)) #@UndefinedVariable
button.name = (((str(column) + "_Clip_") + str(track_index)) + "_Button")
button_row.append(button)
track_index = track_index + 1
else:
for column in range(8):
log("wrong one: " + str(track_index))
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 99, True) #@UndefinedVariable
button.name = (str(column) + "_Clip_Button-DUMMY")
button_row.append(button)
matrix.add_row(tuple(button_row))
log("done")"""
""" ORIGINAL CODE """
for row in range(8):
button_row = []
for column in range(8):
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, ((row * 16) + column))
button.name = (((str(column) + "_Clip_") + str(row)) + "_Button")
button_row.append(button)
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0, optimized_send_midi=False)
self._config_button.add_value_listener(self._config_value)
top_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, (104 + index)) for index in range(8) ]
side_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, SIDE_NOTES[index]) for index in range(8) ]
top_buttons[0].name = "Bank_Select_Up_Button"
top_buttons[1].name = "Bank_Select_Down_Button"
top_buttons[2].name = "Bank_Select_Left_Button"
top_buttons[3].name = "Bank_Select_Right_Button"
top_buttons[4].name = "Session_Button"
top_buttons[5].name = "User1_Button"
top_buttons[6].name = "User2_Button"
top_buttons[7].name = "Mixer_Button"
side_buttons[0].name = "Vol_Button"
side_buttons[1].name = "Pan_Button"
side_buttons[2].name = "SndA_Button"
side_buttons[3].name = "SndB_Button"
side_buttons[4].name = "Stop_Button"
side_buttons[5].name = "Trk_On_Button"
side_buttons[6].name = "Solo_Button"
side_buttons[7].name = "Arm_Button"
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button)
self._selector.name = "Main_Modes"
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self.set_highlighting_session_component(self._selector.session_component())
self._suppress_session_highlight = False
#self.set_suppress_rebuild_requests(False)
" DISCONNECTOR "
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
self._config_button.remove_value_listener(self._config_value)
ControlSurface.disconnect(self)
self._suppress_send_midi = False
self._config_button.send_value(32)
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
self._user_byte_write_button = None
" RETURN THE SESSION COMPONENT SHOWING THE RING IN LIVE SESSION "
#.........这里部分代码省略.........
示例2: Launchpad
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class Launchpad(ControlSurface):
""" Script for Novation's Launchpad Controller """
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
self.set_suppress_rebuild_requests(True)
self._suppress_send_midi = True
self._suppress_session_highlight = True
is_momentary = True
self._suggested_input_port = 'Launchpad'
self._suggested_output_port = 'Launchpad'
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = 'User_Byte_Button'
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
matrix = ButtonMatrixElement()
matrix.name = 'Button_Matrix'
for row in range(8):
button_row = []
for column in range(8):
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, row * 16 + column)
button.name = str(column) + '_Clip_' + str(row) + '_Button'
button_row.append(button)
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0)
self._config_button.add_value_listener(self._config_value)
top_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, 104 + index) for index in range(8) ]
side_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, SIDE_NOTES[index]) for index in range(8) ]
top_buttons[0].name = 'Bank_Select_Up_Button'
top_buttons[1].name = 'Bank_Select_Down_Button'
top_buttons[2].name = 'Bank_Select_Left_Button'
top_buttons[3].name = 'Bank_Select_Right_Button'
top_buttons[4].name = 'Session_Button'
top_buttons[5].name = 'User1_Button'
top_buttons[6].name = 'User2_Button'
top_buttons[7].name = 'Mixer_Button'
side_buttons[0].name = 'Vol_Button'
side_buttons[1].name = 'Pan_Button'
side_buttons[2].name = 'SndA_Button'
side_buttons[3].name = 'SndB_Button'
side_buttons[4].name = 'Stop_Button'
side_buttons[5].name = 'Trk_On_Button'
side_buttons[6].name = 'Solo_Button'
side_buttons[7].name = 'Arm_Button'
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button, self)
self._selector.name = 'Main_Modes'
self._do_combine()
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self._suppress_session_highlight = False
self.set_suppress_rebuild_requests(False)
self.log_message("LaunchPad85 Loaded !")
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._do_uncombine()
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
self._config_button.remove_value_listener(self._config_value)
ControlSurface.disconnect(self)
self._suppress_send_midi = False
self._config_button.send_value(32)
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
self._user_byte_write_button = None
_active_instances = []
def highlighting_session_component(self):
" Return the session component showing the ring in Live session "
return self._selector.session_component()
def _combine_active_instances():
support_devices = False
for instance in Launchpad._active_instances:
support_devices |= (instance._device_component != None)
offset = 0
for instance in Launchpad._active_instances:
instance._activate_combination_mode(offset, support_devices)
offset += instance._selector._session.width()
_combine_active_instances = staticmethod(_combine_active_instances)
def _activate_combination_mode(self, track_offset, support_devices):
if(LINK_STEPSEQ):
self._selector._stepseq.link_with_step_offset(track_offset)
if(LINK_SESSION):
self._selector._session.link_with_track_offset(track_offset)
#.........这里部分代码省略.........
示例3: Launchpad
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class Launchpad(ControlSurface):
_active_instances = []
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
live = Live.Application.get_application()
self._live_major_version = live.get_major_version()
self._live_minor_version = live.get_minor_version()
self._live_bugfix_version = live.get_bugfix_version()
self._selector = None #needed because update hardware is called.
self._mk2_rgb = False
with self.component_guard():
self._suppress_send_midi = True
self._suppress_session_highlight = True
self._suggested_input_port = ("Launchpad", "Launchpad Mini", "Launchpad S", "Launchpad MK2")
self._suggested_output_port = ("Launchpad", "Launchpad Mini", "Launchpad S", "Launchpad MK2")
self._control_is_with_automap = False
self._user_byte_write_button = None
self._config_button = None
self._wrote_user_byte = False
self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
self._init_done = False
# caller will send challenge and we will continue as challenge is received.
def init(self):
#skip init if already done.
if self._init_done:
return
self._init_done = True
# second part of the __init__ after model has been identified using its challenge response
if self._mk2_rgb:
from SkinMK2 import make_skin
self._skin = make_skin()
self._side_notes = (89, 79, 69, 59, 49, 39, 29, 19)
#self._drum_notes = (20, 30, 31, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126)
self._drum_notes = (20, 30, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126)
else:
from SkinMK1 import make_skin
self._skin = make_skin()
self._side_notes = (8, 24, 40, 56, 72, 88, 104, 120)
self._drum_notes = (41, 42, 43, 44, 45, 46, 47, 57, 58, 59, 60, 61, 62, 63, 73, 74, 75, 76, 77, 78, 79, 89, 90, 91, 92, 93, 94, 95, 105, 106, 107)
with self.component_guard():
is_momentary = True
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0, optimized_send_midi=False)
self._config_button.add_value_listener(self._config_value)
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = 'User_Byte_Button'
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
matrix = ButtonMatrixElement()
matrix.name = 'Button_Matrix'
for row in range(8):
button_row = []
for column in range(8):
if self._mk2_rgb:
# for mk2 buttons are assigned "top to bottom"
midi_note = (81 - (10 * row)) + column
else:
midi_note = row * 16 + column
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, midi_note, skin = self._skin, control_surface = self)
button.name = str(column) + '_Clip_' + str(row) + '_Button'
button_row.append(button)
matrix.add_row(tuple(button_row))
top_buttons = [ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, 104 + index, skin = self._skin) for index in range(8)]
side_buttons = [ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, self._side_notes[index], skin = self._skin) for index in range(8)]
top_buttons[0].name = 'Bank_Select_Up_Button'
top_buttons[1].name = 'Bank_Select_Down_Button'
top_buttons[2].name = 'Bank_Select_Left_Button'
top_buttons[3].name = 'Bank_Select_Right_Button'
top_buttons[4].name = 'Session_Button'
top_buttons[5].name = 'User1_Button'
top_buttons[6].name = 'User2_Button'
top_buttons[7].name = 'Mixer_Button'
side_buttons[0].name = 'Vol_Button'
side_buttons[1].name = 'Pan_Button'
side_buttons[2].name = 'SndA_Button'
side_buttons[3].name = 'SndB_Button'
side_buttons[4].name = 'Stop_Button'
side_buttons[5].name = 'Trk_On_Button'
side_buttons[6].name = 'Solo_Button'
side_buttons[7].name = 'Arm_Button'
self._osd = M4LInterface()
self._osd.name = "OSD"
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button, self._osd, self)
self._selector.name = 'Main_Modes'
self._do_combine()
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self.set_highlighting_session_component(self._selector.session_component())
self._suppress_session_highlight = False
# due to our 2 stage init, we need to rebuild midi map
self.request_rebuild_midi_map()
# and request update
#.........这里部分代码省略.........
示例4: Launchpad
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class Launchpad(ControlSurface):
""" Script for Novation's Launchpad Controller """
def __init__(self, c_instance):
live = Live.Application.get_application()
self._live_major_version = live.get_major_version()
self._live_minor_version = live.get_minor_version()
self._live_bugfix_version = live.get_bugfix_version()
self._mk2 = Settings.DEVICE == 'Launchpad mk2'
if self._mk2:
self._skin = Skin('Launchpad mk2')
self._side_notes = (89, 79, 69, 59, 49, 39, 29, 19)
self._drum_notes = (20, 30, 31, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126)
else:
self._skin = Skin('Launchpad')
self._side_notes = (8, 24, 40, 56, 72, 88, 104, 120)
self._drum_notes = (41, 42, 43, 44, 45, 46, 47, 57, 58, 59, 60, 61, 62, 63, 73, 74, 75, 76, 77, 78, 79, 89, 90, 91, 92, 93, 94, 95, 105, 106, 107)
ControlSurface.__init__(self, c_instance)
with self.component_guard():
self._suppress_send_midi = True
self._suppress_session_highlight = True
is_momentary = True
if self._mk2:
self._suggested_input_port = 'Launchpad'
self._suggested_output_port = 'Launchpad'
else:
self._suggested_input_port = 'Launchpad MK2'
self._suggested_output_port = 'Launchpad MK2'
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = 'User_Byte_Button'
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
matrix = ButtonMatrixElement()
matrix.name = 'Button_Matrix'
for row in range(8):
button_row = []
for column in range(8):
if self._mk2:
# for mk2 buttons are assigned "top to bottom"
midi_note = (81 - (10 * row)) + column
else:
midi_note = row * 16 + column
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, midi_note, self._skin.off)
button.name = str(column) + '_Clip_' + str(row) + '_Button'
button_row.append(button)
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0, optimized_send_midi=False)
self._config_button.add_value_listener(self._config_value)
top_buttons = [ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, 104 + index, self._skin.off) for index in range(8)]
side_buttons = [ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, self._side_notes[index], self._skin.off) for index in range(8)]
top_buttons[0].name = 'Bank_Select_Up_Button'
top_buttons[1].name = 'Bank_Select_Down_Button'
top_buttons[2].name = 'Bank_Select_Left_Button'
top_buttons[3].name = 'Bank_Select_Right_Button'
top_buttons[4].name = 'Session_Button'
top_buttons[5].name = 'User1_Button'
top_buttons[6].name = 'User2_Button'
top_buttons[7].name = 'Mixer_Button'
side_buttons[0].name = 'Vol_Button'
side_buttons[1].name = 'Pan_Button'
side_buttons[2].name = 'SndA_Button'
side_buttons[3].name = 'SndB_Button'
side_buttons[4].name = 'Stop_Button'
side_buttons[5].name = 'Trk_On_Button'
side_buttons[6].name = 'Solo_Button'
side_buttons[7].name = 'Arm_Button'
self._osd = M4LInterface()
self._osd.name = "OSD"
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button, self._osd, self, self._skin)
self._selector.name = 'Main_Modes'
self._do_combine()
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self.set_highlighting_session_component(self._selector.session_component())
self._suppress_session_highlight = False
self.log_message("LaunchPad95 Loaded !")
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._do_uncombine()
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
#.........这里部分代码省略.........
示例5: Launchpad
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class Launchpad(ControlSurface):
""" Script for Novation's Launchpad Controller """
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
with self.component_guard():
self._suppress_send_midi = True
self._suppress_session_highlight = True
is_momentary = True
self._suggested_input_port = 'Launchpad'
self._suggested_output_port = 'Launchpad'
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = 'User_Byte_Button'
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
matrix = ButtonMatrixElement()
matrix.name = 'Button_Matrix'
for row in range(8):
button_row = []
for column in range(8):
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, row * 16 + column)
button.name = str(column) + '_Clip_' + str(row) + '_Button'
button_row.append(button)
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0, optimized_send_midi=False)
self._config_button.add_value_listener(self._config_value)
top_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, 104 + index) for index in range(8) ]
side_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, SIDE_NOTES[index]) for index in range(8) ]
top_buttons[0].name = 'Bank_Select_Up_Button'
top_buttons[1].name = 'Bank_Select_Down_Button'
top_buttons[2].name = 'Bank_Select_Left_Button'
top_buttons[3].name = 'Bank_Select_Right_Button'
top_buttons[4].name = 'Session_Button'
top_buttons[5].name = 'User1_Button'
top_buttons[6].name = 'User2_Button'
top_buttons[7].name = 'Mixer_Button'
side_buttons[0].name = 'Vol_Button'
side_buttons[1].name = 'Pan_Button'
side_buttons[2].name = 'SndA_Button'
side_buttons[3].name = 'SndB_Button'
side_buttons[4].name = 'Stop_Button'
side_buttons[5].name = 'Trk_On_Button'
side_buttons[6].name = 'Solo_Button'
side_buttons[7].name = 'Arm_Button'
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button)
self._selector.name = 'Main_Modes'
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self.set_highlighting_session_component(self._selector.session_component())
self._suppress_session_highlight = False
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
self._config_button.remove_value_listener(self._config_value)
ControlSurface.disconnect(self)
self._suppress_send_midi = False
self._config_button.send_value(32)
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
self._user_byte_write_button = None
def refresh_state(self):
ControlSurface.refresh_state(self)
self.schedule_message(5, self._update_hardware)
def handle_sysex(self, midi_bytes):
if len(midi_bytes) == 8:
if midi_bytes[1:5] == (0, 32, 41, 6):
response = long(midi_bytes[5])
response += long(midi_bytes[6]) << 8
if response == Live.Application.encrypt_challenge2(self._challenge):
self._on_handshake_successful()
def _on_handshake_successful(self):
self._suppress_send_midi = False
self.set_enabled(True)
def build_midi_map(self, midi_map_handle):
ControlSurface.build_midi_map(self, midi_map_handle)
if self._selector.mode_index == 1:
new_channel = self._selector.channel_for_current_mode()
for note in DRUM_NOTES:
self._translate_message(MIDI_NOTE_TYPE, note, 0, note, new_channel)
def _send_midi(self, midi_bytes, optimized = None):
sent_successfully = False
#.........这里部分代码省略.........
示例6: LaunchMod
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class LaunchMod(ControlSurface):
""" Script for Novation's Launchpad Controller """
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
with self.component_guard():
self._monomod_version = 'b995'
self._host_name = 'LaunchMod'
self._color_type = 'Launchpad'
self.hosts = []
self._timer = 0
self._suppress_send_midi = True
self._suppress_session_highlight = True
self._suppress_highlight = False
is_momentary = True
self._suggested_input_port = 'Launchpad'
self._suggested_output_port = 'Launchpad'
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = 'User_Byte_Button'
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
matrix = ButtonMatrixElement()
matrix.name = 'Button_Matrix'
for row in range(8):
button_row = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, ((row * 16) + column), str(column) + '_Clip_' + str(row) + '_Button', self) for column in range(8) ]
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0, optimized_send_midi=False)
self._config_button.add_value_listener(self._config_value)
top_button_names = ['Bank_Select_Up_Button', 'Bank_Select_Down_Button', 'Bank_Select_Left_Button', 'Bank_Select_Right_Button', 'Session_Button', 'User1_Button', 'User2_Button', 'Mixer_Button']
side_button_names = ['Vol_Button', 'Pan_Button', 'SndA_Button', 'SndB_Button', 'Stop_Button', 'Trk_On_Button', 'Solo_Button', 'Arm_Button']
top_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, (104 + index), top_button_names[index], self) for index in range(8) ]
side_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, SIDE_NOTES[index], side_button_names[index], self) for index in range(8) ]
self._setup_monobridge()
self._setup_monomod()
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button, self)
self._selector.name = 'Main_Modes'
for control in self.controls:
if isinstance(control, MonoButtonElement):
control.add_value_listener(self._button_value)
self.set_highlighting_session_component(self._selector.session_component())
self._suppress_session_highlight = False
self.log_message("--------------= " + str(self._monomod_version) + " log opened =--------------") #Create entry in log file
def allow_updates(self, allow_updates):
for component in self.components:
component.set_allow_update(int(allow_updates!=0))
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
self._config_button.remove_value_listener(self._config_value)
ControlSurface.disconnect(self)
self._suppress_send_midi = False
self._config_button.send_value(32)
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
self._user_byte_write_button = None
def refresh_state(self):
ControlSurface.refresh_state(self)
self.schedule_message(5, self._update_hardware)
def handle_sysex(self, midi_bytes):
if len(midi_bytes) == 8:
if midi_bytes[1:5] == (0, 32, 41, 6):
response = long(midi_bytes[5])
response += long(midi_bytes[6]) << 8
if response == Live.Application.encrypt_challenge2(self._challenge):
self._suppress_send_midi = False
self.set_enabled(True)
def build_midi_map(self, midi_map_handle):
ControlSurface.build_midi_map(self, midi_map_handle)
if self._selector.mode_index == 1:
new_channel = self._selector.channel_for_current_mode()
for note in DRUM_NOTES:
self._translate_message(MIDI_NOTE_TYPE, note, 0, note, new_channel)
def _send_midi(self, midi_bytes, optimized = None):
sent_successfully = False
if not self._suppress_send_midi:
sent_successfully = ControlSurface._send_midi(self, midi_bytes, optimized=optimized)
return sent_successfully
def _update_hardware(self):
self._suppress_send_midi = False
self._wrote_user_byte = True
self._user_byte_write_button.send_value(1)
#.........这里部分代码省略.........
示例7: APCmini
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class APCmini(ControlSurface):
""" Script for Novation's Launchpad Controller """
def __init__(self, c_instance):
live = Live.Application.get_application()
self._live_major_version = live.get_major_version()
self._live_minor_version = live.get_minor_version()
self._live_bugfix_version = live.get_bugfix_version()
ControlSurface.__init__(self, c_instance)
#self._device_selection_follows_track_selection = True
with self.component_guard():
self._suppress_send_midi = True
self._suppress_session_highlight = True
is_momentary = True
self._suggested_input_port = 'Launchpad'
self._suggested_output_port = 'Launchpad'
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16) # Apparently this CC is used to enable feedback, ie lighting up buttons that you pressed
self._user_byte_write_button.name = 'User_Byte_Button'
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = Live.Application.get_random_int(0, 400000000) & 2139062143
matrix = ButtonMatrixElement()
matrix.name = 'Button_Matrix'
for row in range(8):
button_row = []
for column in range(8):
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, (7-row) * 8 + column) # APCmini rows are in reverse order from Launchpad
button.name = str(column) + '_Clip_' + str(row) + '_Button'
button_row.append(button)
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0, optimized_send_midi=False) # Control goes through here on LP, no real equivalent in APCmini (I don't think)
self._config_button.add_value_listener(self._config_value)
top_buttons = [ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, 64 + index) for index in range(8)]
side_buttons = [ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, SIDE_NOTES[index]) for index in range(8)]
top_buttons[0].name = 'Bank_Select_Up_Button'
top_buttons[1].name = 'Bank_Select_Down_Button'
top_buttons[2].name = 'Bank_Select_Left_Button'
top_buttons[3].name = 'Bank_Select_Right_Button'
top_buttons[4].name = 'Session_Button'
top_buttons[5].name = 'User1_Button'
top_buttons[6].name = 'User2_Button'
top_buttons[7].name = 'Mixer_Button'
side_buttons[0].name = 'Vol_Button'
side_buttons[1].name = 'Pan_Button'
side_buttons[2].name = 'SndA_Button'
side_buttons[3].name = 'SndB_Button'
side_buttons[4].name = 'Stop_Button'
side_buttons[5].name = 'Trk_On_Button'
side_buttons[6].name = 'Solo_Button'
side_buttons[7].name = 'Arm_Button'
self._osd = M4LInterface()
self._osd.name = "OSD"
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button, self._osd, self)
self._selector.name = 'Main_Modes'
self._do_combine()
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self.set_highlighting_session_component(self._selector.session_component())
self._suppress_session_highlight = False
self.log_message("LaunchPad95 Loaded !")
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._do_uncombine()
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
self._config_button.remove_value_listener(self._config_value)
ControlSurface.disconnect(self)
self._suppress_send_midi = False
self._config_button.send_value(32)
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
self._user_byte_write_button = None
_active_instances = []
#def highlighting_session_component(self):
# " Return the session component showing the ring in Live session "
# return self._selector.session_component()
def _combine_active_instances():
support_devices = False
for instance in APCmini._active_instances:
support_devices |= (instance._device_component != None)
offset = 0
for instance in APCmini._active_instances:
instance._activate_combination_mode(offset, support_devices)
#.........这里部分代码省略.........
示例8: Launchpad
# 需要导入模块: from MainSelectorComponent import MainSelectorComponent [as 别名]
# 或者: from MainSelectorComponent.MainSelectorComponent import session_component [as 别名]
class Launchpad(ControlSurface):
" Script for Novation's Launchpad Controller "
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
self.set_suppress_rebuild_requests(True)
self._suppress_send_midi = True
self._suppress_session_highlight = True
is_momentary = True
self._suggested_input_port = "Launchpad"
self._suggested_output_port = "Launchpad"
self._control_is_with_automap = False
self._user_byte_write_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 16)
self._user_byte_write_button.name = "User_Byte_Button"
self._user_byte_write_button.send_value(1)
self._user_byte_write_button.add_value_listener(self._user_byte_value)
self._wrote_user_byte = False
self._challenge = (Live.Application.get_random_int(0, 400000000) & 2139062143)
matrix = ButtonMatrixElement()
matrix.name = "Button_Matrix"
for row in range(8):
button_row = []
for column in range(8):
button = ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, ((row * 16) + column))
button.name = (((str(column) + "_Clip_") + str(row)) + "_Button")
button_row.append(button)
matrix.add_row(tuple(button_row))
self._config_button = ButtonElement(is_momentary, MIDI_CC_TYPE, 0, 0)
self._config_button.add_value_listener(self._config_value)
top_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_CC_TYPE, 0, (104 + index)) for index in range(8) ]
side_buttons = [ ConfigurableButtonElement(is_momentary, MIDI_NOTE_TYPE, 0, SIDE_NOTES[index]) for index in range(8) ]
top_buttons[0].name = "Bank_Select_Up_Button"
top_buttons[1].name = "Bank_Select_Down_Button"
top_buttons[2].name = "Bank_Select_Left_Button"
top_buttons[3].name = "Bank_Select_Right_Button"
top_buttons[4].name = "Session_Button"
top_buttons[5].name = "User1_Button"
top_buttons[6].name = "User2_Button"
top_buttons[7].name = "Mixer_Button"
side_buttons[0].name = "Vol_Button"
side_buttons[1].name = "Pan_Button"
side_buttons[2].name = "SndA_Button"
side_buttons[3].name = "SndB_Button"
side_buttons[4].name = "Stop_Button"
side_buttons[5].name = "Trk_On_Button"
side_buttons[6].name = "Solo_Button"
side_buttons[7].name = "Arm_Button"
self._selector = MainSelectorComponent(matrix, tuple(top_buttons), tuple(side_buttons), self._config_button, self)
self._selector.name = "Main_Modes"
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.add_value_listener(self._button_value)
self._suppress_session_highlight = False
self.set_suppress_rebuild_requests(False)
self.log_message("LaunchPad85 Loaded !")
def disconnect(self):
self._suppress_send_midi = True
for control in self.controls:
if isinstance(control, ConfigurableButtonElement):
control.remove_value_listener(self._button_value)
self._selector = None
self._user_byte_write_button.remove_value_listener(self._user_byte_value)
self._config_button.remove_value_listener(self._config_value)
ControlSurface.disconnect(self)
self._suppress_send_midi = False
self._config_button.send_value(32)
self._config_button.send_value(0)
self._config_button = None
self._user_byte_write_button.send_value(0)
self._user_byte_write_button = None
def highlighting_session_component(self):
" Return the session component showing the ring in Live session "
return self._selector.session_component()
def refresh_state(self):
ControlSurface.refresh_state(self)
self.schedule_message(5, self._update_hardware)
def handle_sysex(self, midi_bytes):
if (len(midi_bytes) == 8):
if (midi_bytes[1:5] == (0, 32, 41, 6)):
response = long(midi_bytes[5])
response += (long(midi_bytes[6]) << 8)
if (response == Live.Application.encrypt_challenge2(self._challenge)):
self._suppress_send_midi = False
self.set_enabled(True)
#.........这里部分代码省略.........