#!/usr/bin/env python # Exercise Ardour3's Open Sound Control Interface # Edit > Preferences > Control Surfaces > Enable Open Sound Control # http://manual.ardour.org/using-control-surfaces/controlling-ardour-with-osc/ import liblo, sys ## Ardour's default OSC control port try: target = liblo.Address(3819) except liblo.AddressError, err: print str(err) sys.exit() ## by default ardour 'replies' to messages to the host+port ## where they came from, hence we set up a sever and only ## send OSC messages using the server's port. try: server = liblo.ServerThread(9988) except liblo.ServerError, err: print str(err) sys.exit() ## OSC server callback, called for messages sent by Ardour def test_callback(path, args, types, src): # TODO don't print things here, just store data in array. print "message '%s' from '%s'" % (path, src.get_url()) for a, t in zip(args, types): print "argument of type '%s': '%s'" % (t, a) ## 'catch all' messages by ardour. server.add_method(None, None, test_callback) server.start() ##################### ALL SYSTEMS GO ##################### ## 'request a list of all tracks&busses (aka route) from ardour server.send(target, "/routes/list") ## ask ardour to send regular updates for routes 1-3 ## particularly level-fader ## (disabled since it clutters up the output) #server.send(target, "/routes/listen", 1, 2, 3) ## Wait for User Input def userinput(): c = raw_input('A3> ') return c while True: c = userinput() if c == "p": server.send(target, "/ardour/transport_play") elif c == "s": server.send(target, "/ardour/transport_stop") elif c == "tr": t = raw_input('track ? ') l = raw_input('level ? ') server.send(target, "/ardour/routes/gaindB", ('i', t), ('f', l)) elif c == "about": server.send(target, "/ardour/access_action", ('s', 'Window/toggle-about')) elif c == "mbr": server.send(target, "/ardour/access_action", ('s', 'Common/toggle-meterbridge')) elif c == "": break ## unsubscribe from updates #server.send(target, "/routes/ignore", 1, 2, 3) server.stop()