本文整理汇总了Python中LC2Sysex.LC2Sysex类的典型用法代码示例。如果您正苦于以下问题:Python LC2Sysex类的具体用法?Python LC2Sysex怎么用?Python LC2Sysex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LC2Sysex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
LC2Sysex.set_log(self.log_message)
if LC2Sysex.l9():
with self.component_guard():
self.do_setup()
else:
self.do_setup()
示例2: _bank_down
def _bank_down(self):
if LC2Sysex.l9():
if len(self.song().scenes) > self.scene_offset() + self.height():
SessionComponent._bank_down(self)
self.send_offsets()
LC2Sysex.log_message(str(len(self.song().scenes)) + ' ' + str(self.scene_offset() + self.height()))
if len(self.song().scenes) == self.scene_offset() + self.height():
self._bank_down_button.turn_off()
示例3: set_clip
def set_clip(self, clip, slot):
if self._clip is not None:
try:
if self._clip.playing_position_has_listener(self._on_playing_position_changed):
self._clip.remove_playing_position_listener(self._on_playing_position_changed)
if self._clip.notes_has_listener(self._on_notes_changed):
self._clip.remove_notes_listener(self._on_notes_changed)
if self._slot.has_clip_has_listener(self._on_slot_changed):
self._slot.remove_has_clip_listener(self._on_slot_changed)
for l in self._clisten:
chk = getattr(self._clip, l + "_has_listener")
if chk(self._on_length_changed):
rem = getattr(self._clip, "remove_" + l + "_listener")
rem(self._on_length_changed)
except:
pass
self._clip = clip
self._slot = slot
if clip is not None:
self._clip.add_playing_position_listener(self._on_playing_position_changed)
self._clip.add_notes_listener(self._on_notes_changed)
self._slot.add_has_clip_listener(self._on_slot_changed)
for l in self._clisten:
add = getattr(self._clip, "add_" + l + "_listener")
add(self._on_length_changed)
LC2Sysex.log_message(str(self._clip.length))
self._quantisation = 0.25
self._time_offset = 0
sysex = LC2Sysex("CLIP_TITLE")
sysex.ascii(
clip is not None
and clip.canonical_parent.canonical_parent.name
+ ": "
+ str(list(clip.canonical_parent.canonical_parent.clip_slots).index(clip.canonical_parent) + 1)
+ ". "
+ (clip.name and clip.name or "Unnamed")
or ""
)
sysex.rgb(clip is not None and clip.color or 0)
sysex.send()
self._cache_notes()
if self._clip is not None:
min = 128
for note in self._note_cache:
if note[0] < min:
min = note[0]
self._note_offset = len(self._note_cache) == 0 and 36 or min
self._fold_notes = 0
self._save_note = 0
self._send_offsets()
self._on_playing_position_changed()
self.update()
示例4: _select_xy
def _select_xy(self, sysex):
pid = sysex.parse('b')
LC2Sysex.log_message('SELECTING XY ' + str(pid))
if pid < len(self._xys):
self._selected_param = pid
param = self._xys[pid]
if param.mapped_parameter() is not None:
if isinstance(param.mapped_parameter().canonical_parent, Live.Device.Device):
self.song().view.select_device(param.mapped_parameter().canonical_parent)
self._send_id_param()
示例5: disconnect
def disconnect(self):
self._do_uncombine()
if LC2Sysex.l9():
task = self._tasks.find(self._on_time_changed)
self._tasks.remove(task)
else:
self._unregister_timer_callback(self._on_time_changed)
self.song().remove_tempo_listener(self._on_tempo_changed)
ControlSurface.disconnect(self)
LC2Sysex.release_attributes()
LC2SessionBank.release_attributes()
示例6: update
def update(self):
array = [0 for i in range(self._height)]
array_l = [0 for i in range(self._height)]
for note in self._note_cache:
step = self._step(note[1])
nstep = self._note_step(note[0])
if step in range(16) and nstep in range(self._height):
array[self._height - 1 - nstep] |= 1 << step
last = self._step(note[1] + note[2])
for j in range(step + 1, min(last, 16)):
array_l[self._height - 1 - nstep] |= 1 << j
sysex = LC2Sysex("STEPS")
for b in array:
sysex.int2(b)
sysex.send()
sysex = LC2Sysex("STEPS2")
for b in array_l:
sysex.int2(b)
sysex.send()
sysex = LC2Sysex("SEQ_FADERS")
states = 0
for i in range(16):
fad = self._get_fader(i)[0]
if fad == -1:
sysex.byte(0)
else:
states |= 1 << i
sysex.byte(fad)
sysex.int2(states)
sysex.send()
self._get_timeline()
self._get_note_line()
sysex = LC2Sysex("SEQ_MUTES")
mutes = 0
for i in range(self._height):
mutes |= self._mutes[self._note(i)] << self._height - 1 - i
sysex.int2(mutes)
sysex.send()
sysex = LC2Sysex("SEQ_FOLD")
sysex.byte(self._fold_notes)
sysex.send()
sysex = LC2Sysex("SEQ_QUANT")
sysex.int(int(self._quantisation * 1000))
LC2Sysex.log_message(str(int(self._quantisation * 1000)))
sysex.send()
sysex = LC2Sysex("SEQ_SAVE_NOTE")
sysex.byte(self._save_note)
sysex.send()
示例7: bank
def bank(self, ud):
if self._device is not None:
LC2Sysex.log_message('device')
if ud:
num_banks = self.number_of_parameter_banks(self._device)
LC2Sysex.log_message('up' + str(num_banks))
if num_banks > self._bank_index + 1:
self._bank_name = ''
self._bank_index += 1
self.update()
elif self._bank_index > 0:
self._bank_name = ''
self._bank_index -= 1
self.update()
示例8: _transpose
def _transpose(self, args):
if not self._fold_notes:
pitch = args[0] == 1 and 1 or -1
selection, left = self._get_selection()
for note in selection:
id = self._note_step(note[0])
LC2Sysex.log_message("old " + str(note[0]))
note[0] = self._note(id + pitch)
LC2Sysex.log_message("new " + str(note[0]) + " " + str(id))
self._clip.select_all_notes()
self._clip.replace_selected_notes(tuple(selection + left))
self._selection[0] += pitch
self._selection[1] += pitch
self.update()
示例9: _note_press
def _note_press(self, sysex):
x, y = sysex.parse("bb")
pos = self._pos(x)
pos2 = self._pos(x + 1)
pitch = self._note(y)
found = 0
for note in self._note_cache:
if note[1] >= pos and note[1] < pos2 and note[0] == pitch:
LC2Sysex.log_message(str(note[1]) + " " + str(pos) + " " + str(pos2))
found = 1
if found:
self.rem_note(pos, pos2, pitch)
else:
self.add_note(pos, pos2, pitch)
示例10: __init__
def __init__(self):
ControlSurfaceComponent.__init__(self)
self._register_timer_callback(self._on_timer)
self._refresh = 0
self._clip = None
self._note_cache = []
self._last_note = 36
self._last_pos = 0
self._quantisation = 0.25
self._default_length = 1
self._default_velocity = 100
self._time_offset = 0
self._note_offset = 36
self._num_steps = 16
self._height = 16
self._root = 0
self._scale = 0
self._scales = [[], [0, 2, 4, 5, 7, 9, 11], [0, 2, 3, 5, 7, 8, 10], [0, 2, 3, 5, 7, 8, 11], [0, 2, 4, 7, 9]]
self._mutes = [0 for i in range(127)]
self._fader_type = 0
self._fold_notes = 0
self._save_note = 0
self._ltime = ""
self._chord_intervals = [[0, 4, 7], [0, 3, 7], [0, 4, 8], [0, 4, 6], [0, 3, 6], [0, 5, 7]]
self._quick_chord = 127
self._durations = [0.125, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 4]
self._selection = [0, 0, 0, 0]
self._last_details = [-1, -1, -1, -1, -1]
if LC2Sysex.l9():
self._clisten = ("loop_start", "loop_end", "start_marker", "end_marker")
else:
self._clisten = ("loop_start", "loop_end")
示例11: _bank_left
def _bank_left(self):
if LC2Sysex.l9():
if self.track_offset() > 0:
SessionComponent._bank_left(self)
self.send_offsets()
else:
self._bank_left_button.turn_off()
示例12: _bank_right
def _bank_right(self):
if LC2Sysex.l9():
if len(self.tracks_to_use()) > self.track_offset() + self.width():
SessionComponent._bank_right(self)
self.send_offsets()
if len(self.tracks_to_use()) == self.track_offset() + self.width():
self._bank_right_button.turn_off()
示例13: _half
def _half(self, args):
if self._clip is not None:
self._clip.loop_end -= self._clip.length / 2
if LC2Sysex.l9():
if self._clip.end_marker > self._clip.loop_end:
self._clip.end_marker = self._clip.loop_end
self._time_offset = 0
self.update()
self._send_offsets()
示例14: _compress
def _compress(self, args):
sel, rem = self._get_selection()
min = 99999
for note in sel:
if note[1] < min:
min = note[1]
for note in sel:
LC2Sysex.log_message("before: " + str(note))
if not args[0]:
note[1] = (note[1] - min) / 0.5 + min
note[2] = note[2] / 0.5
else:
note[1] = (note[1] - min) * 0.5 + min
note[2] = note[2] * 0.5
LC2Sysex.log_message("after: " + str(note))
self._clip.select_all_notes()
self._clip.replace_selected_notes(tuple(sel + rem))
示例15: __init__
def __init__(self, num_tracks, num_scenes):
self._scene_count = LC2Sysex.l9() and -1 or 0
self._num_tracks = num_tracks
self._height = num_scenes
self._width = num_tracks
self._snapshot_bank = LC2SessionBank()
SessionComponent.__init__(self, num_tracks, num_scenes)
LC2SceneComponent.set_get_offsets(self._get_offset)
LC2ChannelStripComponent.set_get_offsets(self._get_offset)
LC2ClipSlotComponent.set_get_offsets(self._get_offset)
LC2ChannelStripComponent.set_playing_slot_changed(self._playing_slot_changed)