本文整理汇总了Python中SpecialSessionComponent.SpecialSessionComponent.track_offset方法的典型用法代码示例。如果您正苦于以下问题:Python SpecialSessionComponent.track_offset方法的具体用法?Python SpecialSessionComponent.track_offset怎么用?Python SpecialSessionComponent.track_offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialSessionComponent.SpecialSessionComponent
的用法示例。
在下文中一共展示了SpecialSessionComponent.track_offset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MF3D_Color_Clip
# 需要导入模块: from SpecialSessionComponent import SpecialSessionComponent [as 别名]
# 或者: from SpecialSessionComponent.SpecialSessionComponent import track_offset [as 别名]
class MF3D_Color_Clip(ControlSurface):
__doc__ = " Script for Mad Zach's Weekly soundpacks "
_active_instances = []
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
self.log_message(time.strftime("%d.%m.%Y %H:%M:%S", time.localtime()) + "--------------= MIDI Fighter Mad Zach Soundpack log opened =--------------") # Writes message into Live's main log file. This is a ControlSurface method.
self.set_suppress_rebuild_requests(True)
self._session = None
self._session_zoom = None
self._last_tr_off = 0
self._last_sc_off = 1
self._setup_session_control()
self.set_suppress_rebuild_requests(False)
def disconnect(self):
self._session = None
self._session_zoom = None
self.log_message(time.strftime("%d.%m.%Y %H:%M:%S", time.localtime()) + "--------------= MIDI Fighter Mad Zach Soundpack log closed =--------------") # Writes message into Live's main log file. This is a ControlSurface method.
ControlSurface.disconnect(self)
def _setup_session_control(self):
is_momentary = True
self._device = DeviceComponent()
self._device.name = 'Device_Component'
self._session = SpecialSessionComponent(4, 4)
self._session.name = 'Session_Control'
self._session.set_track_bank_buttons(self._set_button(BUTTONCHANNEL+1, SESSIONRIGHT),self._set_button(BUTTONCHANNEL+1, SESSIONLEFT))
self._session.set_scene_bank_buttons(self._set_button(BUTTONCHANNEL+1, SESSIONDOWN),self._set_button(BUTTONCHANNEL+1, SESSIONUP))
self._session_zoom = SpecialZoomingComponent(self._session)
self._session_zoom.name = 'Session_Overview'
self._session_zoom.set_nav_buttons(self._set_button(BUTTONCHANNEL+1, ZOOMUP), self._set_button(BUTTONCHANNEL+1, ZOOMDOWN), self._set_button(BUTTONCHANNEL+1, ZOOMLEFT), self._set_button(BUTTONCHANNEL+1, ZOOMRIGHT))
tracks = self.getslots() #get clip slots to access clip colors
for scene_index in range(4):
scene_off=self._session._scene_offset
scene = self._session.scene(scene_index+scene_off)
scene.name = 'Scene_' + str(scene_index+scene_off)
button_row = []
for track_index in range(4):
button = self._set_button(BUTTONCHANNEL, CLIPNOTEMAP[scene_index][track_index], GREEN, OFF)
button_row.append(button)
clip_slot = scene.clip_slot(track_index)
clip_slot.name = str(track_index) + '_Clip_Slot_' + str(scene_index+scene_off)
clip_slot.set_launch_button(button)
c = tracks[track_index][scene_index+scene_off] #get clip for color
clip_slot.set_stopped_value(LOWYELLOW)
if c.clip != None:
cval=self._get_MF3D_color(self.int_to_rgb(c.clip.color))
self.log_message("Clip: tr: " + str(track_index) + " clip: " + str(scene_index+scene_off) + " has color: " + str(self.int_to_rgb(c.clip.color)) + " va " + str(cval))
clip_slot.set_stopped_value(cval)
## clip_slot.set_triggered_to_launch_value(1)
clip_slot.set_triggered_to_play_value(PLAYTRIG_COL)
clip_slot.set_started_value(TRIGD_COL)
clip_slot.set_triggered_to_record_value(RECTRIG_COL)
clip_slot.set_recording_value(RECD_COL)
def int_to_rgb(self,rgbint):
return (rgbint/256/256%256, rgbint/256%256,rgbint%256)
def getslots(self):
tracks = self.song().visible_tracks
clipSlots = []
for track in tracks:
clipSlots.append(track.clip_slots)
return clipSlots
def _set_button(self,_channel,_note,_on_color=118,_off_color=0):
_button=None;
if not _note is -1:
_button = ConfigurableButtonElement(True, MESSAGETYPE, _channel, _note,_on_color,_off_color)
return _button
def _set_colors(self, scene_dir):
tracks = self.getslots() #get clip slots to access clip colors
scene_off=self._session.scene_offset()
track_off=self._session.track_offset()
for scene_index in range(4):
sc=scene_index
scene = self._session.scene(sc)
self.log_message("scene offset + index " + str(scene_index))
scene.name = 'Scene_' + str(scene_index)
button_row = []
for track_index in range(4):
#button = self._set_button(BUTTONCHANNEL, CLIPNOTEMAP[scene_index][track_index], GREEN, OFF)
#button_row.append(button)
tr=track_index
clip_slot = scene.clip_slot(tr)
clip_slot.name = str(track_index) + '_Clip_Slot_' + str(scene_index)
#clip_slot.set_launch_button(button)
c = tracks[track_index][scene_index+scene_off+scene_dir] #get clip for color
clip_slot.set_stopped_value(LOWYELLOW)
if c.clip != None:
cval=self._get_MF3D_color(self.int_to_rgb(c.clip.color))
clip_slot.set_stopped_value(cval)
self.log_message("Clip: tr: " + str(track_index) + " clip: " + str(scene_index) + " has color: " + str(self.int_to_rgb(c.clip.color)) + " va " + str(cval))
def update_display(self):
ControlSurface.update_display(self)
#.........这里部分代码省略.........
示例2: Axiom_AIR_25_49_61
# 需要导入模块: from SpecialSessionComponent import SpecialSessionComponent [as 别名]
# 或者: from SpecialSessionComponent.SpecialSessionComponent import track_offset [as 别名]
#.........这里部分代码省略.........
)
value = int((param.value - param.min) / param_range * 127)
elif param.name == "Track Panning":
name_string = (
self._mixer_for_encoders.channel_strip(self._encoders.index(sender))
.track_name_data_source()
.display_string()
+ " Pan"
)
value = int(param.value / param_range * 127)
if value < 0:
name_string += " L"
elif value > 0:
name_string += " R"
else:
name_string += " C"
else:
name_string = param.name
value = int((param.value - param.min) / param_range * 127)
value_string = str(value)
else:
name_string = "<unmapped>"
value_string = None
self.schedule_message(1, self._set_value_string)
self._set_name_string(name_string)
self._set_value_string(value_string)
def _set_displays_to_default(self):
self._name_display.segment(0).set_data_source(
self._mixer_for_encoders.selected_strip().track_name_data_source()
)
self._name_display.update()
self._update_bank_value()
self._set_value_string(None)
self._send_midi(SYSEX_START + LCD_HC_DEFAULT)
def _set_name_string(self, name_string):
self._name_display.segment(0).set_data_source(self._name_display_data_source)
self._name_display_data_source.set_display_string(name_string)
self._display_reset_delay = STANDARD_DISPLAY_DELAY
def _set_value_string(self, value_string=None):
if value_string != None:
self._value_display_data_source.set_display_string(value_string)
else:
self._value_display.reset()
def _set_bank_string(self, bank_string=None):
if bank_string != None:
self._bank_display_data_source.set_display_string(bank_string)
else:
self._bank_display.reset()
def _update_bank_value(self):
bank = (self._session.track_offset() + 1) / self._session.width() + 1
self._set_bank_string(str(bank))
def _install_mapping(self, midi_map_handle, control, parameter, feedback_delay, feedback_map):
if not self._in_build_midi_map:
raise AssertionError
raise midi_map_handle != None or AssertionError
raise control != None and parameter != None or AssertionError
raise isinstance(parameter, Live.DeviceParameter.DeviceParameter) or AssertionError
raise isinstance(control, InputControlElement) or AssertionError
raise isinstance(feedback_delay, int) or AssertionError
if not isinstance(feedback_map, tuple):
raise AssertionError
success = False
feedback_rule = None
feedback_rule = control.message_type() is MIDI_NOTE_TYPE and Live.MidiMap.NoteFeedbackRule()
feedback_rule.note_no = 0
feedback_rule.vel_map = (0,)
elif control.message_type() is MIDI_CC_TYPE:
feedback_rule = Live.MidiMap.CCFeedbackRule()
feedback_rule.cc_no = 0
feedback_rule.cc_value_map = (0,)
elif control.message_type() is MIDI_PB_TYPE:
feedback_rule = Live.MidiMap.PitchBendFeedbackRule()
feedback_rule.value_pair_map = feedback_map
raise feedback_rule != None or AssertionError
feedback_rule.channel = control.message_channel()
feedback_rule.delay_in_ms = feedback_delay
success = control.message_type() is MIDI_NOTE_TYPE and Live.MidiMap.map_midi_note_with_feedback_map(
midi_map_handle, parameter, control.message_channel(), control.message_identifier(), feedback_rule
)
elif control.message_type() is MIDI_CC_TYPE:
success = Live.MidiMap.map_midi_cc_with_feedback_map(
midi_map_handle,
parameter,
control.message_channel(),
control.message_identifier(),
control.message_map_mode(),
feedback_rule,
not control.needs_takeover(),
)
elif control.message_type() is MIDI_PB_TYPE:
success = Live.MidiMap.map_midi_pitchbend_with_feedback_map(
midi_map_handle, parameter, control.message_channel(), feedback_rule, not control.needs_takeover()
)
return success
示例3: LaunchControl
# 需要导入模块: from SpecialSessionComponent import SpecialSessionComponent [as 别名]
# 或者: from SpecialSessionComponent.SpecialSessionComponent import track_offset [as 别名]
class LaunchControl(ControlSurface):
def __init__(self, c_instance):
super(LaunchControl, self).__init__(c_instance)
with self.component_guard():
self._device_selection_follows_track_selection = True
self._init_mixer()
self._init_session()
self._init_device()
self._init_modes()
self._refresh_state_task = self._tasks.add(Task.sequence(Task.delay(3), Task.run(self._do_refresh_state)))
self._refresh_state_task.kill()
self.log_message('Launch Control script loaded')
def disconnect(self):
super(LaunchControl, self).disconnect()
for channel in xrange(16):
self._send_midi((CC_STATUS + channel, 0, 0))
def refresh_state(self):
self._refresh_state_task.restart()
def _do_refresh_state(self):
self._send_current_mode()
self._update_hardware()
self.schedule_message(3, super(LaunchControl, self).refresh_state)
def _update_hardware(self):
for channel in xrange(8, 11):
self._send_midi(Sysex.make_automatic_flashing_message(channel))
def _send_current_mode(self):
try:
self._send_midi(MODE_SYSEX_MAP[self._modes.selected_mode])
except KeyError:
pass
def _init_mixer(self):
make_button = partial(make_launch_control_button, channel=8)
make_encoder = partial(make_launch_control_encoder, channel=8)
bottom_encoders, top_encoders = make_all_encoders('Mixer', make_encoder)
pan_volume_layer = Layer(volume_controls=ButtonMatrixElement(rows=[bottom_encoders]), pan_controls=ButtonMatrixElement(rows=[top_encoders]))
sends_layer = Layer(sends_controls=ButtonMatrixElement(rows=[bottom_encoders, top_encoders]))
modes_layer = Layer(pan_volume_button=make_button(114, 'Pan_Volume_Mode_Button'), sends_button=make_button(115, 'Sends_Mode_Button'))
self._mixer = SpecialMixerComponent(8, modes_layer, pan_volume_layer, sends_layer)
self._mixer.set_enabled(False)
self._mixer.name = 'Mixer'
self._mixer.selected_strip().name = 'Selected_Channel_Strip'
self._mixer.master_strip().name = 'Master_Channel_Strip'
self._mixer_track_nav_layer = Layer(track_bank_left_button=make_button(116, 'Mixer_Track_Left_Button'), track_bank_right_button=make_button(117, 'Mixer_Track_Right_Button'))
for index in xrange(8):
strip = self._mixer.channel_strip(index)
strip.name = 'Channel_Strip_' + str(index)
strip.empty_color = Colors.LED_OFF
strip.set_invert_mute_feedback(True)
mute_button = make_button(pad_identifiers[index], 'Track_Mute_Button_' + str(index), is_pad=True)
mute_button.set_on_off_values(Colors.AMBER_FULL, Colors.AMBER_THIRD)
strip.set_mute_button(mute_button)
self._on_selected_send_index.subject = self._mixer
self._on_selected_mixer_mode.subject = self._mixer
def _init_session(self):
make_button = partial(make_launch_control_button, channel=9)
make_encoder = partial(make_launch_control_encoder, channel=9)
bottom_encoders, top_encoders = make_all_encoders('Session_Mixer', make_encoder)
pan_volume_layer = Layer(volume_controls=ButtonMatrixElement(rows=[bottom_encoders]), pan_controls=ButtonMatrixElement(rows=[top_encoders]))
self._session_mixer = SpecialMixerComponent(8, Layer(), pan_volume_layer, Layer())
self._session_mixer.set_enabled(False)
self._session_mixer.name = 'Session_Mixer'
clip_launch_buttons = [ make_button(identifier, 'Clip_Launch_Button_' + str(i), is_pad=True) for i, identifier in enumerate(pad_identifiers) ]
self._session = SpecialSessionComponent(num_tracks=8, num_scenes=0, name='Session')
self._session.set_enabled(False)
self._session.set_mixer(self._session_mixer)
self._session_layer = Layer(track_bank_left_button=make_button(116, 'Track_Bank_Left_Button'), track_bank_right_button=make_button(117, 'Track_Bank_Right_Button'), select_prev_button=make_button(114, 'Scene_Bank_Up_Button'), select_next_button=make_button(115, 'Scene_Bank_Down_Button'), clip_launch_buttons=ButtonMatrixElement(rows=[clip_launch_buttons]))
scene = self._session.selected_scene()
for index in range(8):
clip_slot = scene.clip_slot(index)
clip_slot.set_triggered_to_play_value(Colors.GREEN_BLINK)
clip_slot.set_triggered_to_record_value(Colors.RED_BLINK)
clip_slot.set_stopped_value(Colors.AMBER_FULL)
clip_slot.set_started_value(Colors.GREEN_FULL)
clip_slot.set_recording_value(Colors.RED_FULL)
clip_slot.name = 'Selected_Clip_Slot_' + str(index)
self._on_track_offset.subject = self._session
def _init_device(self):
make_button = partial(make_launch_control_button, channel=10)
make_encoder = partial(make_launch_control_encoder, channel=10)
bottom_encoders, top_encoders = make_all_encoders('Device', make_encoder)
parameter_controls = top_encoders[:4] + bottom_encoders[:4]
bank_buttons = [ make_button(identifier, 'Device_Bank_Button_' + str(i), is_pad=True) for i, identifier in enumerate(pad_identifiers) ]
for button in bank_buttons:
button.set_on_off_values(Colors.LED_ON, Colors.LED_OFF)
self._device_bank_registry = DeviceBankRegistry()
self._device = DeviceComponent(device_bank_registry=self._device_bank_registry, name='Device')
self._device.set_enabled(False)
self._device.layer = Layer(parameter_controls=ButtonMatrixElement(rows=[parameter_controls]), bank_buttons=ButtonMatrixElement(rows=[bank_buttons]))
#.........这里部分代码省略.........
示例4: MainSelectorComponent
# 需要导入模块: from SpecialSessionComponent import SpecialSessionComponent [as 别名]
# 或者: from SpecialSessionComponent.SpecialSessionComponent import track_offset [as 别名]
#.........这里部分代码省略.........
scene.name = 'Scene_' + str(scene_index)
for track_index in range(8):
"TODO: this still doesn't light the launch clip buttons when supposed to..."
clip_slot = scene.clip_slot(track_index)
clip_slot.set_triggered_to_play_value(127)
clip_slot.set_triggered_to_record_value(127)
clip_slot.set_stopped_value(0)
clip_slot.set_started_value(127)
clip_slot.set_recording_value(127)
clip_slot.name = str(track_index) + '_Clip_Slot_' + str(scene_index)
def _mode_value(self, value, sender):
"method called each time the value of the mode selection changed"
"it's been momentary overriden to avoid dysfunctionnement in the framework method"
new_mode = self._modes_buttons.index(sender)
if sender.is_momentary():
#self._parent.log_message(sender.message_identifier())
if value > 0:
#self._parent.log_message("value = "+str(value))
mode_observer = MomentaryModeObserver()
mode_observer.set_mode_details(new_mode, self._controls_for_mode(new_mode), self._get_public_mode_index)
self._modes_heap.append((new_mode, sender, mode_observer))
self._update_mode()
elif self._modes_heap[-1][1] == sender and not self._modes_heap[-1][2].is_mode_momentary():
#self._parent.log_message("sender trouve")
self.set_mode(new_mode)
else:
#TODO: comprendre comment le framework est sense fonctionner et remplacer supprimer cet modif du framework
self.set_mode(new_mode)
self._update_mode()
else:
#self._parent.log_message("boutton pas trouve")
self.set_mode(new_mode)
def _setup_step_sequencer(self, as_active):
if(self._stepseq!=None):
if as_active:
self._stepseq._force_update = True
self._stepseq._is_active = True
self._stepseq.set_enabled(True)
self._stepseq._on_notes_changed()
self._stepseq._update_seq_buttons()
else:
self._stepseq._is_active = False
self._stepseq.set_enabled(False)
def _set_browser_control(self, as_active):
self._browser_control.remove_value_listener(self._browser_control_value)
if as_active:
self._browser_control.add_value_listener(self._browser_control_value)
def _browser_control_value(self, value):
if value != 64:
all_scenes = self.song().scenes
selected_scene = self.song().view.selected_scene
selected_scene_index = list(all_scenes).index(selected_scene)
new_selected_scene_index = max(0, min(selected_scene_index + (value-64), len(list(all_scenes))-1) )
self.song().view.selected_scene = all_scenes[new_selected_scene_index]
session_offset = self._session.scene_offset()
if new_selected_scene_index > session_offset + 15:
self._session.set_offsets(self._session.track_offset(), new_selected_scene_index - 15)
if new_selected_scene_index < session_offset:
self._session.set_offsets(self._session.track_offset(), new_selected_scene_index)
def _set_browser_button(self, as_active):
self._browser_button.remove_value_listener(self._browser_button_value)
if as_active:
self._browser_button.add_value_listener(self._browser_button_value)
def _browser_button_value(self, value):
if value != 0:
if self._mode_index == 2:
self.song().view.highlighted_clip_slot.fire()
else:
self.song().view.selected_scene.fire_as_selected()
def _set_scale_control(self, as_active):
self._divide_control.remove_value_listener(self._translation_selector._scale_index_value)
self._move_control.remove_value_listener(self._translation_selector._scale_offset_value)
if as_active:
self._divide_control.add_value_listener(self._translation_selector._scale_index_value)
self._move_control.add_value_listener(self._translation_selector._scale_offset_value)
def _update_session_translation(self):
if self._mode_index == 0 or self._mode_index == 1:
if self._translation_selector.mode():
self._session.set_offsets(8,self._session.scene_offset())
else:
self._session.set_offsets(0,self._session.scene_offset())
def on_selected_track_changed(self):
all_tracks = ((self.song().tracks + self.song().return_tracks))
selected_track = self.song().view.selected_track
self._previous_track_index = self._selected_track_index
self._selected_track_index = list(all_tracks).index(selected_track)
self.update()