Discussion:
Send/Receive OSC with Processing
G-Wohl
2007-10-12 20:54:47 UTC
Permalink
I recently was able to achieve interfacing Processing with Supercollider
through the use of this thread:

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1133669730;start=0#1

I understand pretty well how to send OSC messages FROM Processing TO
Supercollider, but what if I want to send messages FROM Supercollider TO
Processing? For example, having a shape grow in size in Processing every
time an AudioIn hits a certain gain? How would I go about establishing this
type of connection between these two programs?

Thanks so much,
-Andrew
--
View this message in context: http://www.nabble.com/Send-Receive-OSC-with-Processing-tf4615626.html#a13181728
Sent from the Supercollider - User mailing list archive at Nabble.com.
Stefan Nussbaumer
2007-10-12 23:47:23 UTC
Permalink
... How would I go about establishing this
type of connection between these two programs?
I don't know what you are really after but the following example worked
for me in way that I could see the messages comming in from SC (not
more). The processing applet has to be running _before_ you send
anything from SC. The incomming messages should appear in the post-area
below the editing area.

good luck, stefan


/* ----------------- SuperCollider code ---------------------------- */
// execute the following code line by line resp. block by block from top
~netAddr = NetAddr("127.0.0.1", 12000); // should be working with this ip and port-number ...
~oscResp = OSCresponder(~netAddr, '/toprocessing', { arg time, resp, msg; [time, msg].postln }).add;

(
~test = Pseq(#[
"you, not", "me", "whoever",
1, "hello", "what you mean?",
"another", "message", 1.9, "whatever"
], 3).asStream;
)

(
~task = Task({
loop({
1.wait;
~netAddr.sendMsg("/toprocessing", ~test.next);
});
}).stop.reset.play;
)

// just for testing - send messages manually line by line
~netAddr.sendMsg("/toprocessing", "you", "not you");
// strange: processing seems to receive these messages in an array, which i just can't achieve in a Task, it seems ...
~netAddr.sendMsg("/toprocessing", 1, 1.3, 77);
~netAddr.sendMsg("/toprocessing", 1, 1.3, 77);

// should send to processing with a 15 secs delay, though i didn't recognize it when i tried it
~netAddr.sendBundle(15, ["/toprocessing", 1, 1.3, 77]);

~task.stop;
~task.reset;
~oscResp.remove;
~netAddr.disconnect



/* ----------------- Processing code --------------------- */
/**
* oscP5broadcastClient by andreas schlegel
* an osc broadcast client.
* an example for broadcast server is located in the oscP5broadcaster exmaple.
* oscP5 website at http://www.sojamo.de/oscP5
*/

import oscP5.*;
import netP5.*;

OscP5 oscP5;

/* a NetAddress contains the ip address and port number of a remote location in the network. */
NetAddress myBroadcastLocation;

void setup() {
size(400,400);
frameRate(25);

/* create a new instance of oscP5.
* 12000 is the port number you are listening for incoming osc messages.
*/
oscP5 = new OscP5(this,12000);

/* create a new NetAddress. a NetAddress is used when sending osc messages
* with the oscP5.send method.
*/

/* the address of the osc broadcast server */
myBroadcastLocation = new NetAddress("127.0.0.1",32000);
}

void draw() {
background(0);
}

void mousePressed() {
/* create a new OscMessage with an address pattern, in this case /test. */
OscMessage myOscMessage = new OscMessage("/test");
/* add a value (an integer) to the OscMessage */
myOscMessage.add(100);
/* send the OscMessage to a remote location specified in myNetAddress */
oscP5.send(myOscMessage, myBroadcastLocation);
}

void keyPressed() {
OscMessage m;
switch(key) {
case('c'):
/* connect to the broadcaster */
m = new OscMessage("/server/connect",new Object[0]);
oscP5.flush(m,myBroadcastLocation);
break;
case('d'):
/* disconnect from the broadcaster */
m = new OscMessage("/server/disconnect",new Object[0]);
oscP5.flush(m,myBroadcastLocation);
break;

}
}

/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
/* get and print the address pattern and the typetag of the received OscMessage */
println("### received an osc message with addrpattern "+theOscMessage.addrPattern()+" and typetag "+theOscMessage.typetag());
theOscMessage.print();
}
Nick Collins
2007-10-13 08:59:17 UTC
Permalink
Stefan has also sent some code, but I enclose a link to my minimal
working examples of messaging both ways:

http://www.informatics.sussex.ac.uk/users/nc81/courses/cm2/workshop.html

(under week 4)
Post by G-Wohl
I recently was able to achieve interfacing Processing with
Supercollider
http://processing.org/discourse/yabb_beta/YaBB.cgi?
board=Integrate;action=display;num=1133669730;start=0#1
I understand pretty well how to send OSC messages FROM Processing TO
Supercollider, but what if I want to send messages FROM
Supercollider TO
Processing? For example, having a shape grow in size in Processing every
time an AudioIn hits a certain gain? How would I go about
establishing this
type of connection between these two programs?
Thanks so much,
-Andrew
--
View this message in context: http://www.nabble.com/Send-Receive-
OSC-with-Processing-tf4615626.html#a13181728
Sent from the Supercollider - User mailing list archive at Nabble.com.
_______________________________________________
sc-users mailing list
http://www.create.ucsb.edu/mailman/listinfo/sc-users
___________________________________________________________
Inbox full of spam? Get leading spam protection and 1GB storage with All New Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html
Loading...