To talk to TouchOSC using the Open Sound Control protocol you'll first need to download and install the oscP5 library for Processing here
Once you figure out the basic structure of messages, OSC is a really simple and effective way of talking to all kinds of multimedia devices.
In the setup you'll need to do two things: initialize oscP5 and tell it what port to listen to for incoming messages, as well as declare a remote address (in this case the IP address of the smartphone) and the outgoing port. You can find these two values in the OSC app.oscP5 = new OscP5(this,8000);
// Start oscP5, listening for incoming messages at port 8000myRemoteLocation = new NetAddress("10.0.1.3",9000);
// IP address, outgoing port (taken from the TouchOSC app)
An OSC signal is composed of a message and a value. Let's look at the simple case of turning a TouchOSC LED on and off:OSCMessage myMessage = new OscMessage("/1/led1");
// <--- where /1 is the first page and /led1 is led1myMessage.add(1);
// <-- assign a value to the message (in this case turn the led on)oscP5.send(myMessage, myRemoteAddress);
// <-- send the message to the remote address
To dim the LED to half of its maximum brightness you just need to send another message exactly as above but with 0.5 instead 1 in the myMessage.add(__).
The oscP5Message example pictured provides a good baseline to work from.