def nameTrackCB(self, msg, source): """Called when a /live/name/track message is received. Messages: /live/name/track Returns a a series of all the track names in the form /live/name/track (int track, string name) /live/name/track (int track) Returns a single track's name in the form /live/name/track (int track, string name) /live/name/track (int track, string name)Sets track number track's name to name """ #Requesting all track names if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"): trackNumber = 0 bundle = OSC.OSCBundle() for track in LiveUtils.getTracks(): bundle.append("/live/name/track", (trackNumber, str(track.name),int(track.has_midi_input))) trackNumber = trackNumber + 1 self.oscEndpoint.sendMessage(bundle) return #Requesting a single track name if len(msg) == 3: trackNumber = msg[2] self.oscEndpoint.send("/live/name/track", (trackNumber, str(LiveUtils.getTrack(trackNumber).name),int(LiveUtils.getTrack(trackNumber).has_midi_input))) return #renaming a track if len(msg) == 4: trackNumber = msg[2] name = msg[3] LiveUtils.getTrack(trackNumber).name = name
def nameTrackCB(self, msg, source): """Called when a /live/name/track message is received. Messages: /live/name/track Returns a a series of all the track names in the form /live/name/track (int track, string name) /live/name/track (int track) Returns a single track's name in the form /live/name/track (int track, string name) /live/name/track (int track, string name)Sets track number track's name to name """ #Requesting all track names if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"): trackNumber = 0 bundle = OSC.OSCBundle() for track in LiveUtils.getTracks(): bundle.append("/live/name/track", (trackNumber, str(track.name))) trackNumber = trackNumber + 1 self.oscEndpoint.sendMessage(bundle) return #Requesting a single track name if len(msg) == 3: trackNumber = msg[2] self.oscEndpoint.send( "/live/name/track", (trackNumber, str(LiveUtils.getTrack(trackNumber).name))) return #renaming a track if len(msg) == 4: trackNumber = msg[2] name = msg[3] LiveUtils.getTrack(trackNumber).name = name
def nameTrackCB(self, msg): """Called when a /live/name/track message is received. Messages: /live/name/track Returns a a series of all the track names in the form /live/name/track (int track, string name) /live/name/track (int track) Returns a single track's name in the form /live/name/track (int track, string name) /live/name/track (int track, string name)Sets track number track's name to name """ #Requesting all track names if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"): trackNumber = 0 for track in LiveUtils.getTracks(): self.oscServer.sendOSC("/live/name/track", (trackNumber, str(track.name))) trackNumber = trackNumber + 1 return #Requesting a single track name if len(msg) == 3: trackNumber = msg[2] self.oscServer.sendOSC("/live/name/track", (trackNumber, str(LiveUtils.getTrack(trackNumber).name))) return #renaming a track if len(msg) == 4: trackNumber = msg[2] name = msg[3] LiveUtils.getTrack(trackNumber).name = name
def nameTrackCB(self, msg): """Called when a /live/name/track message is received. Messages: /live/name/track Rerurns a a series of all the track names in the form /live/name/track (int track, string name) /live/name/track (int track) Returns a single track's name in the form /live/name/track (int track, string name) /live/name/track (int track, string name)Sets track number track's name to name """ #Requesting all track names if len(msg) == 2: trackNumber = 0 for track in LiveUtils.getTracks(): self.oscServer.sendOSC("/live/name/track", (trackNumber, track.name)) trackNumber = trackNumber + 1 return #Requesting a single track name if len(msg) == 3: trackNumber = msg[2] self.oscServer.sendOSC("/live/name/track", (trackNumber, LiveUtils.getTrack(trackNumber).name)) return #renaming a track if len(msg) == 4: trackNumber = msg[2] name = msg[3] LiveUtils.getTrack(trackNumber).name = name
def addControlTrack(self): #check for LiveControl listener track firstTrack = LiveUtils.getTrack(0) if firstTrack.name != CONTROL_TRACK_IDENTIFIER: LiveUtils.getSong().create_midi_track(0) controlTrack = LiveUtils.getTrack(0) controlTrack.name = CONTROL_TRACK_IDENTIFIER controlTrack.mute = 1
def slot_changestate(self, slot, tid, cid): tmptrack = LiveUtils.getTrack(tid) armed = tmptrack.arm and 1 or 0 # Added new clip if slot.clip != None: self.add_cliplistener(slot.clip, tid, cid) playing = 1 if slot.clip.is_playing == 1: playing = 2 if slot.clip.is_triggered == 1: playing = 3 length = slot.clip.loop_end - slot.clip.loop_start self.oscEndpoint.send('/live/track/info', (tid, armed, cid, playing, length)) self.oscEndpoint.send('/live/name/clip', (tid, cid, str(slot.clip.name), slot.clip.color)) else: if self.clisten.has_key(slot.clip) == 1: slot.clip.remove_playing_status_listener(self.clisten[slot.clip]) if self.pplisten.has_key(slot.clip) == 1: slot.clip.remove_playing_position_listener(self.pplisten[slot.clip]) if self.cnlisten.has_key(slot.clip) == 1: slot.clip.remove_name_listener(self.cnlisten[slot.clip]) if self.cclisten.has_key(slot.clip) == 1: slot.clip.remove_color_listener(self.cclisten[slot.clip]) self.oscEndpoint.send('/live/track/info', (tid, armed, cid, 0, 0.0)) self.oscEndpoint.send('/live/clip/info', (tid, cid, 0))
def slot_changestate(self, slot, tid, cid): # Added new clip print "added new clip" tmptrack = LiveUtils.getTrack(tid) armed = tmptrack.arm and 1 or 0 if slot.clip != None: self.add_cliplistener(slot.clip, tid, cid) playing = 1 if slot.clip.is_playing == 1: playing = 2 if slot.clip.is_triggered == 1: playing = 3 length = slot.clip.loop_end - slot.clip.loop_start self.oscServer.sendOSC('/live/track/info', (tid, armed, cid, playing, length)) else: self.oscServer.sendOSC('/live/track/info', (tid, armed, cid, 0, 0.0)) if self.clisten.has_key(slot.clip) == 1: slot.clip.remove_playing_status_listener( self.clisten[slot.clip])
def slot_changestate(self, slot, tid, cid): tmptrack = LiveUtils.getTrack(tid) armed = tmptrack.arm and 1 or 0 # Added new clip if slot.clip != None: self.add_cliplistener(slot.clip, tid, cid) playing = 1 if slot.clip.is_playing == 1: playing = 2 if slot.clip.is_triggered == 1: playing = 3 length = slot.clip.loop_end - slot.clip.loop_start self._server.send('track:info', {"track": tid, "armed":armed, "clip": cid, "status": str(playing), "length": str(length)}) else: if self.clisten.has_key(slot.clip) == 1: slot.clip.remove_playing_status_listener(self.clisten[slot.clip]) if self.cnlisten.has_key(slot.clip) == 1: slot.clip.remove_name_listener(self.cnlisten[slot.clip]) if self.cclisten.has_key(slot.clip) == 1: slot.clip.remove_color_listener(self.cclisten[slot.clip]) self._server.send('track:info', {"track": tid, "armed": armed, "clip": cid, "status": "0", "length": "0.0"})
def loadedSongs(self): controlHashes = [] controlTrack = LiveUtils.getTrack(0) for slot in controlTrack.clip_slots: if slot.has_clip: #slotName = slot.clip.name #nameParts = slotName.split(CONTROL_CLIP_IDENTIFIER) songID = findName(slot.clip.name, CONTROL_CLIP_IDENTIFIER) if not songID in controlHashes: controlHashes.append(str(songID)) return controlHashes
def trackJump(self, msg, source): """Called when a /live/track/jump message is received. Messages: /live/track/jump (int track, float beats) Jumps in track's currently running session clip by beats """ if len(msg) == 4: track = msg[2] beats = msg[3] track = LiveUtils.getTrack(track) track.jump_in_running_session_clip(beats)
def __init__(self, trackID): self.trackID = trackID self.track = LiveUtils.getTrack(self.trackID) callback = lambda: self.slot_changed() # make sure we get notified whenever a new clip starts playing by putting a listener on the Track self.track.add_playing_slot_index_listener(callback) log("Clip Monitor initialized on Track " + str(self.trackID))
def nameTrackBlockCB(self, msg): """Called when a /live/name/trackblock message is received. /live/name/trackblock (int offset, int blocksize) Returns a list of blocksize track names starting at offset """ if len(msg) == 4: block = [] trackOffset = msg[2] blocksize = msg[3] for track in range(0, blocksize): block.extend([str(LiveUtils.getTrack(trackOffset+track).name)]) self.oscServer.sendOSC("/live/name/trackblock", block)
def playClipSlotCB(self, msg, source): """Called when a /live/play/clipslot message is received. Messages: /live/play/clipslot (int track, int clip) Launches clip number clip in track number track """ if len(msg) == 4: track_num = msg[2] clip_num = msg[3] track = LiveUtils.getTrack(track_num) clipslot = track.clip_slots[clip_num] clipslot.fire()
def nameTrackBlockCB(self, msg, source): """Called when a /live/name/trackblock message is received. /live/name/trackblock (int offset, int blocksize) Returns a list of blocksize track names starting at offset """ if len(msg) == 4: block = [] trackOffset = msg[2] blocksize = msg[3] for track in range(0, blocksize): block.extend([str(LiveUtils.getTrack(trackOffset+track).name)]) self.oscEndpoint.send("/live/name/trackblock", block)
def send_playing_scene_id(self): track = LiveUtils.getTrack(LIVE_CONTROL_TRACK) index = track.playing_slot_index if index != -1: songID = Scan.findName(track.clip_slots[index].clip.name, CONTROL_CLIP_IDENTIFIER) scene = LiveUtils.getScene(index) idIndex = scene.name.find(" #cS") if idIndex != -1: sceneID = scene.name[idIndex:] #log(sceneID) self.oscEndpoint.send("/session/playing", (index, str(sceneID), str(songID)))
def add_clip_listeners(self): self.rem_clip_listeners() track = LiveUtils.getTrack(LIVE_CONTROL_TRACK) slot_index = 0 for slot in track.clip_slots: if slot.has_clip: self.add_cliplistener(slot.clip, LIVE_CONTROL_TRACK, slot_index) log("Added clip listener track: " + str(LIVE_CONTROL_TRACK) + " clip: " + str(slot_index)) slot_index += 1 """
def trackInfoCB(self, msg): """Called when a /live/track/info message is received. Messages: /live/track/info (int track) Returns clip slot status' for all clips in a track in the form /live/track/info (tracknumber, armed (clipnumber, state, length)) [state: 1 = Has Clip, 2 = Playing, 3 = Triggered] """ clipslots = LiveUtils.getClipSlots() new = [] if len(msg) == 3: new.append(clipslots[msg[2]]) tracknum = msg[2] - 1 else: new = clipslots tracknum = -1 for track in new: tracknum = tracknum + 1 clipnum = -1 tmptrack = LiveUtils.getTrack(tracknum) armed = tmptrack.arm and 1 or 0 li = [tracknum, armed] for clipSlot in track: clipnum = clipnum + 1 li.append(clipnum); if clipSlot.clip != None: clip = clipSlot.clip if clip.is_playing == 1: li.append(2) clipLength = clip.loop_end - clip.loop_start li.append(clipLength) elif clip.is_triggered == 1: li.append(3) li.append(0.0) else: li.append(1) li.append(0.0) else: li.append(0) li.append(0.0) tu = tuple(li) self.oscServer.sendOSC("/live/track/info", tu)
def muteTrackCB(self, msg): """Called when a /live/mute message is received. Messages: /live/mute (int track) Mutes track number track """ track = msg[2] if len(msg) == 4: if msg[3] == 1: LiveUtils.muteTrack(track) else: LiveUtils.unmuteTrack(track) elif len(msg) == 3: status = LiveUtils.getTrack(track).mute self.oscServer.sendOSC("/live/mute", (track, int(status)))
def armTrackCB(self, msg, source): """Called when a /live/arm message is received. Messages: /live/arm (int track) (int armed/disarmed) Arms track number track """ track = msg[2] if len(msg) == 4: if msg[3] == 1: LiveUtils.armTrack(track) else: LiveUtils.disarmTrack(track) # Return arm status elif len(msg) == 3: status = LiveUtils.getTrack(track).arm self.oscEndpoint.send("/live/arm", (track, int(status)))
def trackInfoCB(self, msg, source): """Called when a /live/track/info message is received. Messages: /live/track/info (int track) Returns trackId, arm, solo, mute, volume, panning """ if len(msg) == 3: tracknum = msg[2] track = LiveUtils.getTrack(tracknum) arm = track.arm and 1 or 0 solo = track.solo and 1 or 0 mute = track.mute and 1 or 0 audio = track.has_audio_input and 1 or 0 volume = track.mixer_device.volume.value; panning = track.mixer_device.panning.value; self.oscEndpoint.send("/live/track/info", (tracknum, arm, solo, mute, audio, volume, panning))
def soloTrackCB(self, msg): """Called when a /live/solo message is received. Messages: /live/solo (int track) Solos track number track """ track = msg[2] if len(msg) == 4: if msg[3] == 1: LiveUtils.soloTrack(track) else: LiveUtils.unsoloTrack(track) elif len(msg) == 3: status = LiveUtils.getTrack(track).solo self.oscServer.sendOSC("/live/solo", (track, int(status)))
def playSelectedClipCB(self, msg): """Called when a /live/play/clipslot message is received. Messages: /live/play/clipslot (int track) Launches current scenes clipslot in track number track """ if len(msg) == 3: selected_scene = LiveUtils.getSong().view.selected_scene scenes = LiveUtils.getScenes() index = 0 selected_index = 0 for scene in scenes: index = index + 1 if scene == selected_scene: selected_index = index track_num = msg[2] clip_num = (selected_index - 1) track = LiveUtils.getTrack(track_num) clipslot = track.clip_slots[clip_num] clipslot.fire()
def addControlClips(self, songID): controlTrack = LiveUtils.getTrack(0) slotNumber = 0 for slot in controlTrack.clip_slots: if not slot.has_clip: signature_denominator = LiveUtils.getSong( ).signature_denominator signature_numerator = LiveUtils.getSong().signature_numerator if slotNumber in self.sceneScanLengths.keys(): info = self.sceneScanLengths[slotNumber] length = info['length'] signature_numerator = int(info['signature_numerator']) signature_denominator = int(info['signature_denominator']) else: length = 4.0 slot.create_clip(length) slot.clip.signature_numerator = signature_numerator slot.clip.signature_denominator = signature_denominator slot.length = length slot.clip.name = CONTROL_CLIP_IDENTIFIER + " " + songID slotNumber = slotNumber + 1
def update(self): if self.track_index >= len(LiveUtils.getTracks()): return track = LiveUtils.getTrack(self.track_index) colorIndex = track.color_index colorHue = ColorMap.hue[colorIndex] colorSatu = ColorMap.saturation[colorIndex] colorLight = ColorMap.light[colorIndex] valLeft = round(track.output_meter_left, 3) if track.has_audio_output else 0 valRight = round(track.output_meter_right, 3) if track.has_audio_output else 0 level = (valLeft + valRight) / 2 if (level > CHANNEL_SCALE_MAX): level = CHANNEL_SCALE_MAX elif (level < CHANNEL_SCALE_MIN): level = CHANNEL_SCALE_MIN level = level - CHANNEL_SCALE_MIN level = (level / (CHANNEL_SCALE_MAX - CHANNEL_SCALE_MIN)) * self.resolution for index in range(self.resolution): max_value = index + 1 min_value = index if (level <= min_value): colorLight = 0 elif (level < max_value): colorLight = (level - min_value) * colorLight if colorHue != self.previousHue[index]: self.sliderHue[index].send_value(colorHue, True) self.previousHue[index] = colorHue if colorSatu != self.previousSatu[index]: self.sliderSatu[index].send_value(colorSatu, True) self.previousSatu[index] = colorSatu if colorLight != self.previousLight[index]: self.sliderLight[index].send_value(colorLight, True) self.previousLight[index] = colorLight
def __init__(self, c_instance): self._LiveOSC__c_instance = c_instance self.basicAPI = 0 self.oscEndpoint = RemixNet.OSCEndpoint() self.oscEndpoint.send('/server/running', 1) log("LiveControl initialized") #self.clipMonitor = ClipMonitor.ClipMonitor(0) # log(dir(Live.Song)) # log(dir(Live.Song.BeatTime)) # log(dir(Live.Application.get_application().view)) # for x in Live.Application.get_application().view.available_main_views(): # log(x) """ #Tracks listener - refresh_state() will be called whenever the song.tracks changes if self.song().tracks_has_listener(self.refresh_state) != 1: self.song().add_tracks_listener(self.refresh_state) # Scenes listener - as tracks listener but for song.scenes if self.song().scenes_has_listener(self.refresh_state) != 1: self.song().add_scenes_listener(self.refresh_state) """ # Put a listener on our control track (slots) controlTrack = LiveUtils.getTrack(LIVE_CONTROL_TRACK) if controlTrack.clip_slots_has_listener(self.refresh_state) != 1: controlTrack.add_clip_slots_listener(self.refresh_state) if controlTrack.playing_slot_index_has_listener( self.send_playing_scene_id) != 1: controlTrack.add_playing_slot_index_listener( self.send_playing_scene_id)
def soloTrackCB(self, msg, source): """Called when a /live/solo message is received. Messages: /live/solo (int track) Solos track number track """ ty = msg[0] == '/live/return/solo' and 1 or 0 track = msg[2] if len(msg) == 4: if msg[3] == 1: LiveUtils.soloTrack(track, ty) else: LiveUtils.unsoloTrack(track, ty) elif len(msg) == 3: if ty == 1: status = LiveUtils.getSong().return_tracks[track].solo self.oscEndpoint.send("/live/return/solo", (track, int(status))) else: status = LiveUtils.getTrack(track).solo self.oscEndpoint.send("/live/solo", (track, int(status)))
def slot_changestate(self, slot, tid, cid): # Added new clip print "added new clip" tmptrack = LiveUtils.getTrack(tid) armed = tmptrack.arm and 1 or 0 if slot.clip != None: self.add_cliplistener(slot.clip, tid, cid) playing = 1 if slot.clip.is_playing == 1: playing = 2 if slot.clip.is_triggered == 1: playing = 3 length = slot.clip.loop_end - slot.clip.loop_start self.oscServer.sendOSC('/live/track/info', (tid, armed, cid, playing, length)) else: self.oscServer.sendOSC('/live/track/info', (tid, armed, cid, 0, 0.0)) if self.clisten.has_key(slot.clip) == 1: slot.clip.remove_playing_status_listener(self.clisten[slot.clip])
def soloTrackCB(self, msg): """Called when a /live/solo message is received. Messages: /live/solo (int track) Solos track number track """ ty = msg[0] == '/live/return/solo' and 1 or 0 track = msg[2] if len(msg) == 4: if msg[3] == 1: LiveUtils.soloTrack(track, ty) else: LiveUtils.unsoloTrack(track, ty) elif len(msg) == 3: if ty == 1: status = LiveUtils.getSong().return_tracks[track].solo self.oscServer.sendOSC("/live/return/solo", (track, int(status))) else: status = LiveUtils.getTrack(track).solo self.oscServer.sendOSC("/live/solo", (track, int(status)))
def muteTrackCB(self, msg): """Called when a /live/mute message is received. Messages: /live/mute (int track) Mutes track number track """ ty = msg[0] == '/live/return/mute' and 1 or 0 track = msg[2] if len(msg) == 4: if msg[3] == 1: LiveUtils.muteTrack(track, ty) else: LiveUtils.unmuteTrack(track, ty) elif len(msg) == 3: if ty == 1: status = LiveUtils.getSong().return_tracks[track].mute self.oscServer.sendOSC("/live/return/mute", (track, int(status))) else: status = LiveUtils.getTrack(track).mute self.oscServer.sendOSC("/live/mute", (track, int(status)))
def trBlock(self, trackOffset, blocksize): block = [] for track in range(0, blocksize): block.extend([str(LiveUtils.getTrack(trackOffset+track).name)]) self.oscServer.sendOSC("/live/name/trackblock", block)
def trBlock(self, trackOffset, blocksize): block = [] for track in range(0, blocksize): block.extend([str(LiveUtils.getTrack(trackOffset + track).name)]) self.oscServer.sendOSC("/live/name/trackblock", block)
def viewTrackCB(self, msg): if len(msg) == 3: track_num = msg[2] track = LiveUtils.getTrack(track_num) track.view.select_instrument()