示例#1
0
    def nameSceneCB(self, msg, source):
        """Called when a /live/name/scene message is received.

        Messages:
        /live/name/scene                            Returns a a series of all the scene names in the form /live/name/scene (int scene, string name)
        /live/name/scene    (int scene)             Returns a single scene's name in the form /live/name/scene (int scene, string name)
        /live/name/scene    (int scene, string name)Sets scene number scene's name to name

        """        
        #Requesting all scene names
        if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"):
            bundle = OSC.OSCBundle()
            sceneNumber = 0
            for scene in LiveUtils.getScenes():
                bundle.append("/live/name/scene", (sceneNumber, str(scene.name)))
                sceneNumber = sceneNumber + 1
            self.oscEndpoint.sendMessage(bundle)
            return
        #Requesting a single scene name
        if len(msg) == 3:
            sceneNumber = msg[2]
            self.oscEndpoint.send("/live/name/scene", (sceneNumber, str(LiveUtils.getScene(sceneNumber).name)))
            return
        #renaming a scene
        if len(msg) == 4:
            sceneNumber = msg[2]
            name = msg[3]
            LiveUtils.getScene(sceneNumber).name = name
示例#2
0
    def nameSceneCB(self, msg, source):
        """Called when a /live/name/scene message is received.

        Messages:
        /live/name/scene                            Returns a a series of all the scene names in the form /live/name/scene (int scene, string name)
        /live/name/scene    (int scene)             Returns a single scene's name in the form /live/name/scene (int scene, string name)
        /live/name/scene    (int scene, string name)Sets scene number scene's name to name

        """
        #Requesting all scene names
        if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"):
            bundle = OSC.OSCBundle()
            sceneNumber = 0
            for scene in LiveUtils.getScenes():
                bundle.append("/live/name/scene",
                              (sceneNumber, str(scene.name)))
                sceneNumber = sceneNumber + 1
            self.oscEndpoint.sendMessage(bundle)
            return
        #Requesting a single scene name
        if len(msg) == 3:
            sceneNumber = msg[2]
            self.oscEndpoint.send(
                "/live/name/scene",
                (sceneNumber, str(LiveUtils.getScene(sceneNumber).name)))
            return
        #renaming a scene
        if len(msg) == 4:
            sceneNumber = msg[2]
            name = msg[3]
            LiveUtils.getScene(sceneNumber).name = name
示例#3
0
    def nameSceneCB(self, msg):
        """Called when a /live/name/scene message is received.

        Messages:
        /live/name/scene                            Rerurns a a series of all the scene names in the form /live/name/scene (int scene, string name)
        /live/name/scene    (int scene)             Returns a single scene's name in the form /live/name/scene (int scene, string name)
        /live/name/scene    (int scene, string name)Sets scene number scene's name to name

        """        
        #Requesting all scene names
        if len(msg) == 2:
            sceneNumber = 0
            for scene in LiveUtils.getScenes():
                self.oscServer.sendOSC("/live/name/scene", (sceneNumber, scene.name))
                sceneNumber = sceneNumber + 1
            return
        #Requesting a single scene name
        if len(msg) == 3:
            sceneNumber = msg[2]
            self.oscServer.sendOSC("/live/name/scene", (sceneNumber, LiveUtils.getScene(sceneNumber).name))
            return
        #renaming a scene
        if len(msg) == 4:
            sceneNumber = msg[2]
            name = msg[3]
            LiveUtils.getScene(sceneNumber).name = name
示例#4
0
    def scenesCB(self, msg, source):
        """Called when a /live/scenes message is received.

        Messages:
        /live/scenes        no argument or 'query'  Returns the total number of scenes

        """
        if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"):
            sceneTotal = len(LiveUtils.getScenes())
            self.oscEndpoint.send("/live/scenes", (sceneTotal))
            return
示例#5
0
    def scenesCB(self, msg, source):
        """Called when a /live/scenes message is received.

        Messages:
        /live/scenes        no argument or 'query'  Returns the total number of scenes

        """
        if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"):
            sceneTotal = len(LiveUtils.getScenes())
            self.oscEndpoint.send("/live/scenes", (sceneTotal))
            return
示例#6
0
 def stateCB(self, msg):
     tempo = LiveUtils.getTempo()
     overdub = LiveUtils.getSong().overdub
     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
     self.oscServer.sendOSC("/live/state", (tempo, overdub, selected_index))
示例#7
0
 def sceneCB(self, msg):
     """Called when a /live/scene message is received.
     
     Messages:
     /live/scene         no argument or 'query'  Returns the currently playing scene number
     """
     if len(msg) == 2 or (len(msg) == 3 and msg[2] == "query"):
         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
         self.oscServer.sendOSC("/live/scene", (selected_index))
示例#8
0
    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()
示例#9
0
    def nameClipFromSceneCB(self, msg):
        """Called when a /live/name/clip message is received.

        Messages:
        /live/name/clip                                      Returns a a series of all the clip names in the form /live/name/clip (int track, int clip, string name)
        /live/name/clip    (int track, int clip)             Returns a single clip's name in the form /live/name/clip (int clip, string name)
        /live/name/clip    (int track, int clip, string name)Sets clip number clip in track number track's name to name

        """
        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
            trackNumber = msg[2]
            clipNumber = selected_index
            self.oscServer.sendOSC("/live/name/clipfromscene/" + str(selected_index), (str(LiveUtils.getClip(trackNumber, clipNumber).name)))
            return
示例#10
0
    def scanScenes(self, songID):
        #cycle through the scenes for IDs

        sceneNumber = 0
        self.sceneScanLengths = {}
        sceneIDs = []
        #songID = makeID()
        self.oscEndpoint.sendMessage(
            OSC.OSCMessage("/song/" + songID + "/start/"))
        tempo = LiveUtils.getTempo()
        self.oscEndpoint.sendMessage(
            OSC.OSCMessage("/song/" + songID + "/tempo/", float(tempo)))
        numerator = LiveUtils.getNumerator()
        self.oscEndpoint.sendMessage(
            OSC.OSCMessage("/song/" + songID + "/numerator/", int(numerator)))
        denominator = LiveUtils.getDenominator()
        self.oscEndpoint.sendMessage(
            OSC.OSCMessage("/song/" + songID + "/denominator/",
                           int(denominator)))
        #sceneBundle.append(OSC.OSCMessage("/scenes/start"))
        for scene in LiveUtils.getScenes():
            sceneArgs = {}
            sceneBundle = OSC.OSCBundle()
            sceneID = re.findall("(\#cS.{8})", scene.name)
            if (not sceneID):
                sceneID = SCENE_IDENTIFIER + self.makeID()
                sceneName = scene.name
                scene.name = scene.name + sceneID
            else:
                #sceneID = scene.name[idIndex:]
                try:
                    usedAlready = sceneIDs.index(sceneID)
                except ValueError:
                    usedAlready = -1
                if usedAlready != -1:
                    sceneID = SCENE_IDENTIFIER + self.makeID()
                    sceneName = scene.name[:usedAlready]
                    scene.name = sceneName + newID

            self.oscEndpoint.sendMessage(
                OSC.OSCMessage("/song/" + songID + "/scene/" + sceneID +
                               "/start/"))
            sceneIDs.append(sceneID)
            length, signature_numerator, signature_denominator = self.findLongestClip(
                sceneNumber)
            sceneSignature = re.findall("\d+\/\d+", scene.name)
            if (sceneSignature):
                separator = sceneSignature[0].find('/')
                signature_numerator = int(sceneSignature[0][:separator])
                separator += 1
                signature_denominator = int(sceneSignature[0][separator:])
                #log(signature_denominator)
            self.sceneScanLengths[sceneNumber] = {
                'length': length,
                'signature_numerator': signature_numerator,
                'signature_denominator': signature_denominator
            }
            sceneBundle.append(
                OSC.OSCMessage(
                    "/song/" + songID + "/scene/" + sceneID + "/abletonIndex/",
                    int(sceneNumber)))
            sceneBundle.append(
                OSC.OSCMessage(
                    "/song/" + songID + "/scene/" + sceneID + "/name/",
                    str(scene.name)))
            sceneBundle.append(
                OSC.OSCMessage(
                    "/song/" + songID + "/scene/" + sceneID + "/tempo/",
                    float(scene.tempo)))
            sceneBundle.append(
                OSC.OSCMessage(
                    "/song/" + songID + "/scene/" + sceneID + "/length/",
                    float(length)))
            sceneBundle.append(
                OSC.OSCMessage(
                    "/song/" + songID + "/scene/" + sceneID + "/numerator/",
                    int(signature_numerator)))
            sceneBundle.append(
                OSC.OSCMessage(
                    "/song/" + songID + "/scene/" + sceneID + "/denominator/",
                    int(signature_denominator)))

            self.oscEndpoint.sendMessage(sceneBundle)
            self.oscEndpoint.sendMessage(
                OSC.OSCMessage("/song/" + songID + "/scene/" + sceneID +
                               "/end/"))

            sceneNumber += 1
        self.oscEndpoint.sendMessage(
            OSC.OSCMessage("/song/" + songID + "/end/"))
        return