Automation With OSC

Here’s an approach to creating automated sequences using OSC (Open Sound Control)

For this example, I’ll be using the Open Source OSC timeline sequencer Duration to send OSC messages to Arduino using Processing as an intermediary.

Full Project files (Duration, Processing & Arduino) can be found here

Because OSC is design to communicate over a network, we could just communicate directly with an ethernet or wifi connected Arduino but, in this case, we’ll use processing to parse the OSC messages and communicate with the Arduino over serial.

Duration has a number of different options for generating OSC messages.  For this example, we’ll be using “Curve” tracks, which send an ID + float (0-1 by default) and  “Switch” tracks, which send and ID + int32 (1 or 0);  We’ll use these OSC values to control two servos and a solenoid.

First,  let’s get everything talking together.  Our Processing sketch will use the oscP5 library, available here.

The default ouput port that duration uses is localhost 12345.

Screen Shot 2013-11-06 at 7.51.45 PM

 

You can set the port# to anything you want but just need to listen on the same one with Processing.  We do this when we initialize out oscP5 object:

Next, we need to tell processing what to listen for.
Here are the three tracks setup in Duration:
Screen Shot 2013-11-06 at 10.11.50 PM

The names of the tracks will also be the osc message addresses we listen for.  Here’s our oscEvent function:

Duration will send an osc message with an address determined by the track name.  We’ll look for the address and then map the message’s parameter (either a float for the servos or an int of the solenoid) to an appropriate range for controlling each actuator.  The Duration documentation specifies what datatypes are associated with each type of track.  Once we have our message parsed, mapped and stored in a variable, we’ll send it to Arduino over the serial port, sending the osc value + an ID character as a suffix to route it to the correct actuator:

Now let’s take a look at what Arduino does with that serial data

 

Duration is just one of many possibilities for generating OSC data that we can use to control Arduino.  Here are some other OSC sequencing platforms that would work with this routing setup:

Iannix

OSCseq

vvvv

Live Grabber  – Max for Live plugin to send OSC from live tracks