{
   "id" : "1-4UL",
   "is_private" : null,
   "code" : "// Tracking audio data\r\n///////////////////////////////////\r\n\r\nSynthDef(\\pulse,{\r\n\tvar sig, chain, onsets;\r\n\tsig = SinOsc.ar(Rand(220.0,440.0))\r\n\t*EnvGen.ar(Env.perc(releaseTime:0.5),Dust.ar(0.5))*0.7;\r\n\tOut.ar(0,sig !2);\r\n\t//\r\n\tchain = FFT({LocalBuf(512, 1)}, sig);\r\n\tonsets = Onsets.kr(chain,0.1,\\power);\r\n\tSendTrig.kr(onsets);\r\n\tSendPeakRMS.kr(sig, 20, 3, \"/replyAddress\");\r\n}).add;\r\nSynth(\\pulse)\r\n\r\n~host = NetAddr(\"localhost\", 4859); // address de PROCESSING\r\n\r\n\r\no = OSCFunc({ arg msg, time;\r\n\t[time, msg].postln;\r\n\t~host.sendMsg(\"/trigger\",42,12.34,\"hello processing\");\r\n},'/tr', s.addr);\r\n\r\np = OSCFunc({ |msg|\r\n\t\"peak: %, rms: %\".format(msg[3], msg[4]).postln\r\n}, '/replyAddress');\r\n\r\n//////////////////////////////////////////////////////////////////////\r\n///////////////////////////////////////////////////////////////////////\r\n\r\n// Processing code\r\n\r\n// OSC RECEIVE\r\nimport oscP5.*;\r\nimport netP5.*;\r\n\r\nOscP5 oscP5;                 // objet for OSC send and receive\r\nNetAddress myRemoteLocation;  // objet for service address\r\n\r\nvoid setup() {\r\n  size(400,400);\r\n  oscP5 = new OscP5(this,4859); // start OSC and listen port ...\r\n  // set remote location to localhost SuperColider port\r\n  myRemoteLocation = new NetAddress(\"127.0.0.1\",4859);\r\n}\r\n\r\nvoid draw() {\r\n}\r\n\r\n\r\nvoid oscEvent(OscMessage theOscMessage) \r\n{  \r\n  // get the first value as an integer\r\n  int firstValue = theOscMessage.get(0).intValue();\r\n \r\n  // get the second value as a float  \r\n  float secondValue = theOscMessage.get(1).floatValue();\r\n \r\n  // get the third value as a string\r\n  String thirdValue = theOscMessage.get(2).stringValue();\r\n \r\n  // print out the message\r\n  print(\"OSC Message Recieved: \");\r\n  print(theOscMessage.addrPattern() + \" \");\r\n  println(firstValue + \" \" + secondValue + \" \" + thirdValue);\r\n  //\r\n  \r\n  rect(random(width),random(height),random(10),random(10));\r\n}",
   "labels" : [
      "osc",
      "audiovisual",
      "processing"
   ],
   "ancestor_list" : [],
   "description" : "first in SC  i analyse audio data with some useful UGens: Onsets, SendTrig and SendPeakRMS;\r\nthis data is then polled back to de client and dispatched to Processing via NetAddr and OSCFunc classes\r\nin Processing i receive the incoming messages and simple trig a draw function with the callback oscEvent (use oscP5 and netP5 libs",
   "author" : "Luigi Tamagnini",
   "name" : "SuperCollider sending data to Processing"
}
