Changeset 12


Ignore:
Timestamp:
03/07/09 15:23:23 (14 months ago)
Author:
st8
Message:

Added nyquists remixnet fixes, fixed problems with a number of LiveOSC commands. Added fully working TouchOSC script with config file

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LiveControl/RemixNet.py

    r10 r12  
    5959       # 10.5 
    6060        try: 
    61             file = open("/usr/lib/python2.5/string.py") 
     61            file = open("/usr/lib/python2.5/string.pyc") 
    6262        except IOError: 
    63             exists = 0 
    6463            sys.path.append("/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5") 
     64            import socket_live8 as socket   
    6565        else: 
    6666            sys.path.append("/usr/lib/python2.5") 
    67  
    68         import socket_live8 as socket      
     67            import socket 
    6968 
    7069import OSC  
  • trunk/LiveOSC/LiveOSC.py

    r2 r12  
    2929 
    3030import Live 
    31 import socket 
    3231import LiveOSCCallbacks 
    3332import RemixNet 
  • trunk/LiveOSC/LiveOSCCallbacks.py

    r7 r12  
    254254            for track in LiveUtils.getTracks(): 
    255255                for clipSlot in track.clip_slots: 
    256                     if clipSlot: 
    257                         self.oscServer.sendOSC("/live/name/clip", (trackNumber, clipNumber, str(clipSlot.clip.name))) 
     256                    if clipSlot.clip != None: 
     257                        self.oscServer.sendOSC("/live/name/clip", (trackNumber, clipNumber, str(clipSlot.clip.name), str(clipSlot.clip.color_index))) 
    258258                    clipNumber = clipNumber + 1 
    259259                clipNumber = 0 
    260260                trackNumber = trackNumber + 1 
    261261            return 
    262         #Requesting a single scene name 
     262        #Requesting a single clip name 
    263263        if len(msg) == 4: 
    264264            trackNumber = msg[2] 
    265265            clipNumber = msg[3] 
    266             self.oscServer.sendOSC("/live/name/clip", (trackNumber, clipNumber, str(LiveUtils.getClip(trackNumber, clipNumber).name))) 
    267             return 
    268         #renaming a scene 
     266            self.oscServer.sendOSC("/live/name/clip", (trackNumber, clipNumber, str(LiveUtils.getClip(trackNumber, clipNumber).name), str(LiveUtils.getClip(trackNumber, clipNumber).color_index))) 
     267            return 
     268        #renaming a clip 
    269269        if len(msg) == 5: 
    270270            trackNumber = msg[2] 
     
    419419        /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)) 
    420420                                           [state: 1 = Has Clip, 2 = Playing, 3 = Triggered] 
    421         """         
    422         tracknum = -1 
     421        """ 
     422         
    423423        clipslots = LiveUtils.getClipSlots() 
    424424         
    425         for track in clipslots: 
     425        new = [] 
     426        if len(msg) == 3: 
     427            new.append(clipslots[msg[2]]) 
     428            tracknum = msg[2] - 1 
     429        else: 
     430            new = clipslots 
     431            tracknum = -1 
     432         
     433        for track in new: 
    426434            tracknum = tracknum + 1 
    427435            clipnum = -1 
  • trunk/LiveOSC/OSCAPI.txt

    r7 r12  
    2323/live/name/scene        (int scene)                                     Returns a single scene's name in the form /live/name/scene (int scene, string name) 
    2424/live/name/scene        (int scene, string name)                        Sets scene number scene's name to name 
    25 /live/name/track                                                        Returns a a series of all the track names in the form /live/name/track (int track, string name) 
    26 /live/name/track        (int track)                                     Returns a single track's name in the form /live/name/track (int track, string name) 
     25/live/name/track                                                        Returns a a series of all the track names in the form /live/name/track (int track, string name, int color) 
     26/live/name/track        (int track)                                     Returns a single track's name in the form /live/name/track (int track, string name, int color) 
    2727/live/name/track        (int track, string name)                        Sets track number track's name to name 
    2828/live/name/clip                                                         Returns a a series of all the clip names in the form /live/name/clip (int track, int clip, string name) 
  • trunk/LiveOSC/RemixNet.py

    r10 r12  
    5959       # 10.5 
    6060        try: 
    61             file = open("/usr/lib/python2.5/string.py") 
     61            file = open("/usr/lib/python2.5/string.pyc") 
    6262        except IOError: 
    63             exists = 0 
    6463            sys.path.append("/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5") 
     64            import socket_live8 as socket   
    6565        else: 
    6666            sys.path.append("/usr/lib/python2.5") 
    67  
    68         import socket_live8 as socket      
     67            import socket 
    6968 
    7069import OSC  
  • trunk/LiveOSC/__init__.py

    r10 r12  
    2020""" 
    2121 
    22 #import sys 
    23 import Live 
     22import sys 
     23#import Live 
    2424     
    25 #path = "/Live 8.0.3 OS X/Live.app/Contents/App-Resources/MIDI Remote Scripts/LiveOSC" 
    26 #errorLog = open(path + "/stderr.txt", "w") 
    27 #errorLog.write("Starting Error Log") 
    28 #sys.stderr = errorLog 
    29 #stdoutLog = open(path + "/stdout.txt", "w") 
    30 #stdoutLog.write("Starting Standard Out Log") 
    31 #sys.stdout = stdoutLog 
     25path = "/Live 8.0.3 OS X/Live.app/Contents/App-Resources/MIDI Remote Scripts/LiveOSC" 
     26errorLog = open(path + "/stderr.txt", "w") 
     27errorLog.write("Starting Error Log") 
     28sys.stderr = errorLog 
     29stdoutLog = open(path + "/stdout.txt", "w") 
     30stdoutLog.write("Starting Standard Out Log") 
     31sys.stdout = stdoutLog 
    3232 
    3333from LiveOSC import LiveOSC 
  • trunk/TouchOSC/TouchOSC.py

    r11 r12  
    88import OSC 
    99import re 
     10import os 
    1011from Logger import Logger 
    1112 
     
    2324        self.log("Logging Enabled") 
    2425         
    25         ip = RemixNet.get_ip() 
    26         self.log("Ableton IP: " + str(ip)) 
    27          
    28         self.oscServer = RemixNet.OSCServer(ip, 5001, None, 5000) 
    29         self.callbackManager = self.oscServer.callbackManager 
    30         self.oscServer.sendOSC('/touchosc/startup', 1) 
    31          
    32         self.c_instance.show_message("TouchOSC > Server Started on " + str(ip)) 
     26        local = RemixNet.get_ip() 
     27        self.log("Ableton IP: " + str(local)) 
    3328         
    3429        # Init all listeners 
    3530        self.cc = [] 
    36         config = open('config.txt', 'r') 
     31        self.cache = [] 
     32         
     33        config = open(os.path.expanduser('~') + '/touchosc_config.txt', 'r') 
    3734 
     35        first = 0 
    3836        for line in config: 
    39             (page, item) = line.rsplit("/") 
    40             #item = re.sub("/\d^/", "", item) 
     37            line = line.rstrip() 
    4138             
    42             if item == "rotary" or item == "toggle" or item == "fader" or item == "push": 
    43                 pass 
    44             else if item == "xy": 
    45                 pass 
    46             else if item == "multitoggle": 
    47                 pass 
    48             else if item == "multifader": 
    49                 pass 
     39            # First line is remote ip address 
     40            if first == 0: 
     41                remote = line 
     42                self.oscServer = RemixNet.OSCServer(remote, 5001, local, 5000) 
     43                self.callbackManager = self.oscServer.callbackManager 
     44                self.oscServer.sendOSC('/touchosc/startup', 1)   
     45                 
     46                first = 1 
     47            else: 
     48                if re.search("xy", line): 
     49                    self.cc.append(line) 
     50                    self.cc.append(line) 
     51                    self.cache.append(0) 
     52                    self.cache.append(0) 
     53                else: 
     54                    self.cc.append(line) 
     55                    self.cache.append(0) 
     56           
     57                self.callbackManager.add(self.callback, line) 
    5058             
    5159        config.close() 
    52  
    5360         
    54         for page in range(4): 
    55             for item in ("fader", "toggle", "xy", "push", "rotary"): 
    56                 for no in range(6): 
    57                     string = "/" + str(page) + "/" + str(item) + str(no) 
    58                     self.cc.append(string) 
    59                     self.callbackManager.add(self.callback, string) 
     61        self.c_instance.show_message("TouchOSC > Server Started on " + str(local) + ", sending data to: " + str(remote))         
     62                                 
     63        self.song().add_current_song_time_listener(self.oscServer.processIncomingUDP) 
    6064 
    6165######################################################################     
     
    7579 
    7680    def build_midi_map(self, midi_map_handle): 
    77         return 
     81        for i in range(0,20): 
     82            Live.MidiMap.forward_midi_cc(self.handle(), midi_map_handle, 0, i) 
    7883   
    7984        def send_midi(self, midi_bytes): 
    8085                self.c_instance.send_midi(midi_bytes) 
    8186 
    82     def receive_midi(self, midi_bytes): 
    83         return 
     87    def receive_midi(self, bytes): 
     88        cc = self.cc[bytes[1]] 
     89        val = float(bytes[2])/float(127) 
     90         
     91        if re.search("xy", cc): 
     92            self.cache[bytes[1]] = bytes[2] 
     93            xy1 = self.tuple_idx(self.cc, cc) 
     94             
     95            if bytes[1] == xy1: 
     96                val2 = float(self.cache[bytes[1] + 1])/float(127) 
     97                self.oscServer.sendOSC(str(self.cc[bytes[1]]), (val, val2)) 
     98            else: 
     99                val2 = float(self.cache[bytes[1] - 1])/float(127) 
     100                self.oscServer.sendOSC(str(self.cc[bytes[1]]), (val2, val)) 
     101                 
     102                self.log("cc: " + str(bytes[1]) + " val: " + str(val) + " cc2: " + str((bytes[1] - 1)) + " val2: " + str(val2) + " control: " + str(self.cc[bytes[1]]))      
     103 
     104        else: 
     105            self.log("cc: " + str(bytes[1]) + " val: " + str(bytes[2]) + " control: " + str(self.cc[bytes[1]])) 
     106            self.oscServer.sendOSC(str(self.cc[bytes[1]]), val) 
    84107 
    85108    def can_lock_to_devices(self): 
     
    91114    def suggest_output_port(self): 
    92115        return '' 
     116 
     117    def suggest_map_mode(self, cc_no, channel): 
     118        return Live.MidiMap.MapMode.absolute 
    93119 
    94120    def __handle_display_switch_ids(self, switch_id, value): 
     
    127153# Main Touch OSC Functions  
    128154    def callback(self, msg): 
    129         (page, item) = msg[0].rsplit("/") 
    130         item = re.sub("/\d^/", "", item) 
     155        if re.search("xy", msg[0]): 
     156            cc = self.tuple_idx(self.cc, msg[0]) 
     157             
     158            val = int(msg[2] * 127) 
     159            val2 = int(msg[3] * 127) 
     160             
     161            if abs(self.cache[cc] - val) > 0: 
     162                self.c_instance.send_midi((0xb0, cc, val)) 
     163                self.cache[cc] = val 
     164                 
     165                self.log(str(msg[0]) + " cc: " + str(cc) + " val: " + str(val)) 
     166                 
     167            if abs(self.cache[cc+1] - val2) > 0: 
     168                self.c_instance.send_midi((0xb0, cc + 1, val2)) 
     169                self.log(str(msg[0]) + " cc2: " + str(cc+1) + " val2: " + str(val2)) 
     170                 
     171                self.cache[cc+1] = val2 
     172 
     173        else: 
     174            cc = self.tuple_idx(self.cc, msg[0]) 
     175            val = int(msg[2] * 127) 
    131176         
    132         if item == "rotary" or item == "toggle" or item == "fader" or item == "push" or item == "multitoggle" or item == "multifader": 
    133             pass 
    134              
    135         else if item == "xy": 
    136             pass     
    137          
    138         cc = self.tuple_idx(self.cc, msg[0]) 
    139         val = int(msg[2] * 127) 
    140          
    141         self.log(str(msg[0]) + " cc: " + str(cc) + " val: " + str(val)) 
    142         self.c_instance.send_midi((0xb0, cc, val)) 
     177            self.c_instance.send_midi((0xb0, cc, val)) 
    143178 
     179            self.log(str(msg[0]) + " cc: " + str(cc) + " val: " + str(val)) 
     180 
Note: See TracChangeset for help on using the changeset viewer.