<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #osc - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23osc</link>
      <pubDate>Sun, 08 Aug 2021 18:05:44 +0000</pubDate>
         <description>Tagged with #osc - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23osc/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Processing - Kinect/ gesture - music interaction (Max7?)</title>
      <link>https://forum.processing.org/two/discussion/26820/processing-kinect-gesture-music-interaction-max7</link>
      <pubDate>Tue, 13 Mar 2018 23:41:04 +0000</pubDate>
      <dc:creator>mcmich</dc:creator>
      <guid isPermaLink="false">26820@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone!</p>

<p>I am using Kinect with Windows library (<a href="https://github.com/ThomasLengeling/KinectPV2" target="_blank" rel="nofollow">https://github.com/ThomasLengeling/KinectPV2</a>) in processing and detecting all the skeleton joints and positions. What I want to do is to combine sounds and music according to movements of the skeleton joints. (e.g. control pitch or volume of a sound according to the x-position of the left hand). Something like this (<span class="VideoWrap"><span class="Video YouTube" id="youtube-uoS0bS6nP1s"><span class="VideoPreview"><a href="http://youtube.com/watch?v=uoS0bS6nP1s"><img src="http://img.youtube.com/vi/uoS0bS6nP1s/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span>). As I don't have any experience with music software I would like to ask you which method you recommend in order to implement this. A possible approached that I've found to combine with processing is by using Max7 (<span class="VideoWrap"><span class="Video YouTube" id="youtube-FCazZMdSHtk"><span class="VideoPreview"><a href="http://youtube.com/watch?v=FCazZMdSHtk"><img src="http://img.youtube.com/vi/FCazZMdSHtk/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span>). But I am not sure if Max is the most suitable approach as I am aware that there are many other software (Ableton, virtual midi controllers). In respect to Max7, I am thinking that I could do that by controlling a slider using the skeleton joint position(e.g as the hand moves right the slider value will increase but I don't know how I could do that  - assign the position values from processing to a Max's slider). Any guidelines would be appreciated!</p>

<p>Michael</p>
]]></description>
   </item>
   <item>
      <title>Open Sound Control on P5js?</title>
      <link>https://forum.processing.org/two/discussion/25110/open-sound-control-on-p5js</link>
      <pubDate>Mon, 20 Nov 2017 15:37:09 +0000</pubDate>
      <dc:creator>tobor</dc:creator>
      <guid isPermaLink="false">25110@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I am a processing user and now migrating to p5js, I use extensively OSC or UDP to exchange data with C74 Max7,
seems like there is no library like oscP5 for p5js, am I wrong?
what can I do? 
thank you!</p>
]]></description>
   </item>
   <item>
      <title>OSC library for p5.js</title>
      <link>https://forum.processing.org/two/discussion/21435/osc-library-for-p5-js</link>
      <pubDate>Thu, 16 Mar 2017 18:39:30 +0000</pubDate>
      <dc:creator>cdeepak</dc:creator>
      <guid isPermaLink="false">21435@/two/discussions</guid>
      <description><![CDATA[<p>Hey everyone, I'm Deepak, a Music Tech grad. I'm interested in the interfacing of browser based Processing sketches with musical programming environments like Pure Data.</p>

<p>I'm currently looking at ways of reading/writing OSC packets using Javascript and I was wondering what are the thoughts of the Processing community on implementing such a library. Also, any suggestions regarding working with OSC in JS would be greatly helpful.</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>How to communicate with c# TcpListener (server) as a client?</title>
      <link>https://forum.processing.org/two/discussion/23654/how-to-communicate-with-c-tcplistener-server-as-a-client</link>
      <pubDate>Mon, 31 Jul 2017 18:52:07 +0000</pubDate>
      <dc:creator>MDEV</dc:creator>
      <guid isPermaLink="false">23654@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>I'm trying to do a game wich is written in <strong>c#</strong> and I want to force this game to coexistence with a Processing application and communicate with it. So the default stage is --&gt; <strong>C# server</strong> read and write data too to the <strong>client  : Processing.Net OR java.net</strong> (I have tried both) read and write data too but don't blocking the Processing main thread because I need the draw method in Processing too.</p>

<p>So as I write here I have already tried processing.net.client to connect to the <strong>C#</strong> <strong>TcpListener</strong> but I think this is just not possible? And now I can connect to the server with java.net.Socket but when I trying to write a message in <strong>C# to the Processing</strong> the C# says to me how the Processing is forced the socket to close.. So I can't send data to it.. (The threading is created with the Processing <a rel="nofollow" href="https://processing.org/reference/thread_.html">thread("...") method</a>)</p>

<p>M. Márkó (MDEV) , Hungary</p>
]]></description>
   </item>
   <item>
      <title>Exchange data...</title>
      <link>https://forum.processing.org/two/discussion/21173/exchange-data</link>
      <pubDate>Sun, 05 Mar 2017 14:26:58 +0000</pubDate>
      <dc:creator>orso2001</dc:creator>
      <guid isPermaLink="false">21173@/two/discussions</guid>
      <description><![CDATA[<p>I can't figure how to make possible communication between a PC and Cell phone using network !? 
which library I have to use? 
not to program the cell phone but to exchange data between both.
Thanks</p>
]]></description>
   </item>
   <item>
      <title>how to createwrite with selection.getAbsolutePath();</title>
      <link>https://forum.processing.org/two/discussion/16889/how-to-createwrite-with-selection-getabsolutepath</link>
      <pubDate>Mon, 30 May 2016 03:53:39 +0000</pubDate>
      <dc:creator>vincent2</dc:creator>
      <guid isPermaLink="false">16889@/two/discussions</guid>
      <description><![CDATA[<p>I used the createWrite() to save my out file. I want to add the function for change folder by selectFolder() to save the file in new folder. but with fail to change folder.  I got the new folder but failed to path to createWrite(), Is there any suggestion?</p>

<p>AbsolutePath = selection.getAbsolutePath();<br />
println("new Folder = " + AbsolutePath );
fileoutput = createWriter( AbsolutePath + ADC" +str(month())+"-"+str(day())+"-"+str(year())+"_"+str(hour())+"."+str(minute())+"."+str(second())+".txt");</p>
]]></description>
   </item>
   <item>
      <title>Code deleted: your sketch has been modified externally</title>
      <link>https://forum.processing.org/two/discussion/15662/code-deleted-your-sketch-has-been-modified-externally</link>
      <pubDate>Thu, 24 Mar 2016 09:25:18 +0000</pubDate>
      <dc:creator>gerome</dc:creator>
      <guid isPermaLink="false">15662@/two/discussions</guid>
      <description><![CDATA[<p>Hello all,</p>

<p>just I loosed my work of the day by the following mistake: suddenly a message appears: 
"your sketch has been modified externally" with Yes/No buttons, but the No button returns the same message and if I push the yes button Code of the last session is deleted e.g. in my case a whole class. Is there a solution of this problem?</p>

<p>Win7 64bit</p>

<p>Help is appreciated. Thanks.</p>
]]></description>
   </item>
   <item>
      <title>How can i map my midi-keyboard to the minim oscilator?</title>
      <link>https://forum.processing.org/two/discussion/14533/how-can-i-map-my-midi-keyboard-to-the-minim-oscilator</link>
      <pubDate>Tue, 19 Jan 2016 15:31:04 +0000</pubDate>
      <dc:creator>isaakwit</dc:creator>
      <guid isPermaLink="false">14533@/two/discussions</guid>
      <description><![CDATA[<p>Hey there everyone!</p>

<p>I just recently got into processing and it is great.</p>

<p>Anyways, I was just learning some things about midi and and audio-processing with the midibus and minim. I wanted to write a code where I could control the minim-oscilator with my 88-keys midi-keyboard.</p>

<p>Oscilator works fine, I can control everything. But not with the keyboard for some reason... I am quite sure I messed up halfway through the code. There must be some error with my thinking-process...</p>

<p>How can I map my midi-controller correctly to this oscillator?</p>

<p>Any Help is appreciated!</p>

<p>Here is the code:</p>

<pre><code>import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import themidibus.*;

MidiBus myBus;

float bufferX;
float bufferY;

float amp; //creating global variables to swap values between functions
float freq; 

Minim       minim;
AudioOutput out;
Oscil       wave;

void setup()
{
  size(400, 400);
   MidiBus.list();

   myBus = new MidiBus(this, 0, 3);
  minim = new Minim(this);

  out = minim.getLineOut();

  // create a sine wave Oscil, set to 440 Hz, at 0.5 amplitude
  wave = new Oscil( 440, 0.5f, Waves.SINE );
  // patch the Oscil to the output
  wave.patch( out );



}

void draw()
{
  background(0);

  fill(255);
 noStroke(); 

 for(int i = 0; i &lt; out.bufferSize() - 1; i++) {

bufferX = out.left.get(i)*100;  
bufferY = out.right.get(i)*100;

 rect(width/2, height/2, bufferX, bufferY); //this draws some kind of rectangle to visualize the sound

 }
}
 void noteOn( int pitch, int velocity, int value) {
  // Receive a noteOn
  println(value);
  println("Pitch:"+pitch);
  println("Velocity:"+velocity);

  freq = value;  //writing the frequency data to the global variable
}


void controllerChange(int channel, int number, int value) {
  // Receive a controllerChange
  println();
  println("Controller Change:");
  println("--------");
  println("Channel:"+channel);
  println("Number:"+number);
  println("Value:"+value);

  if(number == 7) {  // only the volume-slider has to handle this business

 amp = value;  // writing the volume data into the global variable
  }
}


void midikeys()
{



 float freq1 = map(freq, 0, 98, 110, 880);  //mapping the notes-values to the frequency-spectrum
  wave.setFrequency( freq1 );

 float amp1 = map(amp, 0, 127, 0, 1);  //mapping the volume-slider to the volume control
  wave.setAmplitude( amp1 );
}

void keyPressed()
{ 
  switch( key )  //mapping the different osc-forms to the number-keys
  {
    case '1': 
      wave.setWaveform( Waves.SINE );
      break;

    case '2':
      wave.setWaveform( Waves.TRIANGLE );
      break;

    case '3':
      wave.setWaveform( Waves.SAW );
      break;

    case '4':
      wave.setWaveform( Waves.SQUARE );
      break;

    case '5':
      wave.setWaveform( Waves.QUARTERPULSE );
      break;

    default: break; 
  }

}
</code></pre>

<p>Have a good one!</p>

<p>Isaak</p>
]]></description>
   </item>
   <item>
      <title>LeapMotionP5 updated with new examples</title>
      <link>https://forum.processing.org/two/discussion/11442/leapmotionp5-updated-with-new-examples</link>
      <pubDate>Wed, 24 Jun 2015 19:09:22 +0000</pubDate>
      <dc:creator>Neurogami</dc:creator>
      <guid isPermaLink="false">11442@/two/discussions</guid>
      <description><![CDATA[<p>Neurogami's LeapMotionP5 library has been updated to include some new examples.  One is a finger painting sketch.  There are also two OSC (Open Sound Control) examples. One shows the use of polling for Leap data in draw(), the other shows the use of callbacks from the Leap to drive behavior.</p>

<p>See  <a href="https://github.com/Neurogami/LeapMotionP5" target="_blank" rel="nofollow">https://github.com/Neurogami/LeapMotionP5</a></p>
]]></description>
   </item>
   <item>
      <title>OSC and ControlP5 Libraries working together</title>
      <link>https://forum.processing.org/two/discussion/10865/osc-and-controlp5-libraries-working-together</link>
      <pubDate>Sun, 17 May 2015 22:55:26 +0000</pubDate>
      <dc:creator>Casey_Scalf</dc:creator>
      <guid isPermaLink="false">10865@/two/discussions</guid>
      <description><![CDATA[<p>I am writing a sketch that uses the ControlP5 and OSC libraries. I want to have control over something using theControlP5  GUI in Processing. I also want to have a fader on my mobile device change the y-position through OSC.</p>

<p>My question is how can I route the OSC signal into ControlP5 so that the GUI fader is updated as I use the mobile interface?</p>

<p>Otherwise I would end up changing a variable in the sketch without updating the GUI.</p>

<p>I hope my question is clear.</p>

<p>oscP5: <a href="http://www.sojamo.de/libraries/oscp5/" target="_blank" rel="nofollow">http://www.sojamo.de/libraries/oscp5/</a>
controlP5: <a href="http://www.sojamo.de/libraries/controlP5/" target="_blank" rel="nofollow">http://www.sojamo.de/libraries/controlP5/</a></p>
]]></description>
   </item>
   <item>
      <title>Cannot get my android tablet to send messages to osc program in processing</title>
      <link>https://forum.processing.org/two/discussion/9799/cannot-get-my-android-tablet-to-send-messages-to-osc-program-in-processing</link>
      <pubDate>Tue, 10 Mar 2015 21:25:31 +0000</pubDate>
      <dc:creator>devonrevenge</dc:creator>
      <guid isPermaLink="false">9799@/two/discussions</guid>
      <description><![CDATA[<p>Im not interested in sending messages yet, Im using osc touch on my tablet, the hostname on it is set to the computer thats running the sketches, its listening but its not recieving anyhting at all, just sitting htere like a lemon, what have I missed?</p>

<pre><code>import oscP5.*;
import netP5.*;

OscP5 osc;
NetAddress remoteLoc;

void oscEvent(OscMessage oscIn){


  int firstVal = oscIn.get(0).intValue();

  float secondVal = oscIn.get(1).floatValue();

  String thirdVal = oscIn.get(2).stringValue();

  print(":-");
  print(" addrpattern: "+oscIn.addrPattern()); 
  println(firstVal+" "+secondVal+" "+thirdVal);
}



void setup(){

  osc = new OscP5(this,5001);

}

void draw(){


}
</code></pre>
]]></description>
   </item>
   <item>
      <title>zoom with a variable OPENGL</title>
      <link>https://forum.processing.org/two/discussion/9376/zoom-with-a-variable-opengl</link>
      <pubDate>Wed, 11 Feb 2015 13:25:29 +0000</pubDate>
      <dc:creator>donuan</dc:creator>
      <guid isPermaLink="false">9376@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
In a processing OPENGL sketch, is it possible to handle the zoom (generally done with scroll in/out) with a variable without scaling (scale();) the object it self?</p>

<p>I have a sketch that is running on a computer that is controlled through OSC by another sketch running on an android mobile, and I would like to handle the zoom from there.
It seems easiest to do that with a variable if this is possible, otherwise other solutions are also welcome.</p>

<p>I am pretty new to processing and would be very thankful for help.</p>
]]></description>
   </item>
   <item>
      <title>Kinect to Processing to OSC to Blender</title>
      <link>https://forum.processing.org/two/discussion/9188/kinect-to-processing-to-osc-to-blender</link>
      <pubDate>Mon, 26 Jan 2015 23:01:00 +0000</pubDate>
      <dc:creator>dhall5150</dc:creator>
      <guid isPermaLink="false">9188@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,
I've started a project to create a sketch that produces compatible OSC output to use NIMate's official Blender plugin unmodified in blender.</p>

<p>So far my results are fantastic - except for 1 joint rotation I can not figure out. When reaching up to cover the models eyes, for example, there is a point where the elbow does an unnatural rotation. It seems like when the hand joint is higher than the elbow joint the hand twists around, in an impossible way, showing the palm. Continuing to the eyes, the rotation eventually comes back to a natural position.</p>

<p>The sketch, and the version of NIMate's Big Buck Blender Model I'm using can be found here <a rel="nofollow" href="http://1drv.ms/1BstWXN">1drv.ms/1BstWXN</a></p>

<p>The sketch is using simpleopenni, and a few other libraries that I've included in the link.</p>

<p>Surprisingly the math up to this point has been easy to understand.<br />
Right now the bulk of the math sits in the "OSC" file inside the "sendJointMsg" function.   I am rotating the majority of joints based on its relation to the body's CoM.</p>

<p>The only 2 that I'm not doing that with is the shoulder and the elbow.  When I use CoM the positions of the arms aren't matching me.   Instead, I found using  a new vector of (1,0,0)  satisfies those joints, but the limbs seem more rigid compared to leg motions, head motions, leaning forward/backward, etc.</p>

<p>Finally, one more puzzle is that using NIMates plugin in blender, you can auto-generate shapes at joint points.    Using a blank blend, and enabling this option, you see a human shape and the joints seem to be rotating like you would expect.  Its hard to know that for sure since there is no bone between joints though.</p>

<p>Any help on getting the arms to rotate naturally would be appreciated
thanks</p>
]]></description>
   </item>
   <item>
      <title>sending OSC on the same computer without wifi connection</title>
      <link>https://forum.processing.org/two/discussion/8984/sending-osc-on-the-same-computer-without-wifi-connection</link>
      <pubDate>Sun, 11 Jan 2015 14:03:42 +0000</pubDate>
      <dc:creator>karl_hungus</dc:creator>
      <guid isPermaLink="false">8984@/two/discussions</guid>
      <description><![CDATA[<p>Hi, i send OSC messages both ways using P5 and SuperCollider on the same computer.
Just noticed when wifi is off OSC communication stops.
Why i need wifi for this and how to keep communication without it?</p>
]]></description>
   </item>
   <item>
      <title>run processing sketch from supercollider with osc</title>
      <link>https://forum.processing.org/two/discussion/8985/run-processing-sketch-from-supercollider-with-osc</link>
      <pubDate>Sun, 11 Jan 2015 15:49:31 +0000</pubDate>
      <dc:creator>schiller</dc:creator>
      <guid isPermaLink="false">8985@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>is there any way to run a processing sketch from supercollider ?</p>

<p>I'd like to have both:</p>

<p>sounds generated in supercollider 
and processing visuals,</p>

<p>to start at the same time.</p>
]]></description>
   </item>
   <item>
      <title>how to send data automatically via osc?</title>
      <link>https://forum.processing.org/two/discussion/6593/how-to-send-data-automatically-via-osc</link>
      <pubDate>Sat, 02 Aug 2014 10:35:55 +0000</pubDate>
      <dc:creator>joeparsons</dc:creator>
      <guid isPermaLink="false">6593@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm a new processing user.
I have create this sketch merging two sketches. one was taken from the site of the pulse sensor amped, and the other from an example of osc communication with vvvv.
it works, sending the BPM value I need on vvvv. the problem is that I must press the mouse button every time I want to send data. it is possible change the function "mousePressed" with another that sends data automatically every 3 seconds?</p>

<p>thanks a lot!!!</p>

<pre><code>/**
THIS PROGRAM WORKS WITH PulseSensorAmped_Arduino-xx ARDUINO CODE
THE PULSE DATA WINDOW IS SCALEABLE WITH SCROLLBAR AT BOTTOM OF SCREEN
PRESS 'S' OR 's' KEY TO SAVE A PICTURE OF THE SCREEN IN SKETCH FOLDER (.jpg)
MADE BY JOEL MURPHY AUGUST, 2012
*/


import processing.serial.*;
PFont f;

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;


int firstValue;
float secondValue;
String thirdValue="";
boolean data;





Scrollbar scaleBar;

Serial port;     

int Sensor;      // HOLDS PULSE SENSOR DATA FROM ARDUINO
int IBI;         // HOLDS TIME BETWEN HEARTBEATS FROM ARDUINO
int BPM;         // HOLDS HEART RATE VALUE FROM ARDUINO
int[] RawY;      // HOLDS HEARTBEAT WAVEFORM DATA BEFORE SCALING
int[] ScaledY;   // USED TO POSITION SCALED HEARTBEAT WAVEFORM
int[] rate;      // USED TO POSITION BPM DATA WAVEFORM
float zoom;      // USED WHEN SCALING PULSE WAVEFORM TO PULSE WINDOW
float offset;    // USED WHEN SCALING PULSE WAVEFORM TO PULSE WINDOW
color eggshell = color(255, 253, 248);
int heart = 0;   // This variable times the heart image 'pulse' on screen
//  THESE VARIABLES DETERMINE THE SIZE OF THE DATA WINDOWS
int PulseWindowWidth = 490;
int PulseWindowHeight = 512; 
int BPMWindowWidth = 180;
int BPMWindowHeight = 340;
boolean beat = false;    // set when a heart beat is detected, then cleared when the BPM graph is advanced


void setup() {
  size(700, 600);  // Stage size
  frameRate(100);  
  f = createFont("Arial",16,true);
  textFont(f);
  textAlign(CENTER);
  rectMode(CENTER);
  ellipseMode(CENTER);  


// GO FIND THE ARDUINO
  println(Serial.list());    // print a list of available serial ports
  // choose the number between the [] that is connected to the Arduino
  port = new Serial(this, Serial.list()[0], 115200);  // make sure Arduino is talking serial at this baud rate
  port.clear();            // flush buffer
  port.bufferUntil('\n');  // set buffer full flag on receipt of carriage return




size(400,400);

  f = createFont("Arial",16,true);

  // start oscP5, listening for incoming messages at port 12000
  oscP5 = new OscP5(this, 12000);

  // myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
  // an ip address and a port number.
  myRemoteLocation = new NetAddress("127.0.0.1", 12001);

}





















// vvvv talks to Processing via OSC.
// Click the mouse in the window. vvvv will reply. 
//
// vvvv patch can be found in \girlpower\IO\Networking\2_Advanced (OSC) 
// of the vvvv distribution, which can be downloaded here:
// vvvv.org/downloads
//
// This sketch is adapted version of these examples:
// <a href="http://www.sojamo.de/libraries/oscp5/examples/oscP5message/oscP5message.pde" target="_blank" rel="nofollow">http://www.sojamo.de/libraries/oscp5/examples/oscP5message/oscP5message.pde</a>
// <a href="http://www.sojamo.de/libraries/oscp5/examples/oscP5oscArgument/oscP5oscArgument.pde" target="_blank" rel="nofollow">http://www.sojamo.de/libraries/oscp5/examples/oscP5oscArgument/oscP5oscArgument.pde</a>

// **********************
//
// Add the OSC library: 
// 1. Sketch &gt; Import Library &gt; Add Library ...
// 2. Type OSC and choose oscP5
//
// **********************




void draw() {
  background(0); 





  fill(150);
  textFont(f,15);
  text(BPM + "BPM",120, 120);


  // if the oscEvent() function (see below) receives the OSC data it will be drawn 
  fill(255);
  if (data)
  {
    textFont(f,10);
    text(firstValue + " " + secondValue, 10,150);
    textFont(f,15);
    text(thirdValue, 10, 170);
  }
}

void mousePressed() {
  // in the following different ways of creating osc messages are shown by example 

  // this is the address 
  OscMessage myMessage = new OscMessage("/TheDarkSideOfTheMoon");

  myMessage.add(42); /* add an int to the osc message */
  myMessage.add(random(1)); /* add a float to the osc message */
  myMessage.add(BPM); /* add a string to the osc message */
  myMessage.add(new byte[] {0x00, 0x01, 0x10, 0x20}); /* add a byte blob to the osc message */
  myMessage.add(new int[] {1,2,3,4}); /* add an int array to the osc message */

  /* send the message */
  oscP5.send(myMessage, myRemoteLocation); 
}


/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {

  /* print the address pattern and the typetag of the received OscMessage */
  print("### received an osc message.");
  print(" addrpattern: "+theOscMessage.addrPattern());
  println(" typetag: "+theOscMessage.typetag());

  /* get and parse the arguments */
  firstValue = theOscMessage.get(0).intValue();
  secondValue = theOscMessage.get(1).floatValue();
  thirdValue = theOscMessage.get(2).stringValue();

  data=true;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Sending a varying number from processing using OSC</title>
      <link>https://forum.processing.org/two/discussion/4794/sending-a-varying-number-from-processing-using-osc</link>
      <pubDate>Tue, 29 Apr 2014 14:08:45 +0000</pubDate>
      <dc:creator>judd127a</dc:creator>
      <guid isPermaLink="false">4794@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>a bit of background.</p>

<p>I am currently trying to send data from an EEG that i have built  being processed by processing. The example shown in the link shows how to send data with a mouseclick, is there any way to constantly send data from a particular part of the code? For me i would need to send the data from the frequency of the wave and the amplitude.</p>

<p><a href="http://learning.codasign.com/index.php?title=Sending_and_Receiving_OSC_Data_Using_Processing" target="_blank" rel="nofollow">http://learning.codasign.com/index.php?title=Sending_and_Receiving_OSC_Data_Using_Processing</a></p>

<p>also when i go to place this code in the sketch that processes the EEG, there seem to be errors such as "EOF expected found..."</p>

<p>So what im asking is:</p>

<p>Where should i put the osc send within the rest of the code?</p>

<p>Any ideas on what i would have to send in order to get the frequency and amplitude of waveforms?</p>

<p>How do i send a constant stream of data?</p>

<p>CODE FOLLOWS:</p>

<pre>
    /* Reading and Visualizing EEG Data
     * by Christian Henry.
     
     * Reads in EEG data through the microphone input of the 
     * computer, then displays the signal in time, its frequency
     * components, and then averages of frequencies that estimate
     * the concentration of different brain waves.
     *
     * For reference, the frequency bars are ordered/classified as
     * follows:
     *
     * 1 - blue -------- delta
     * 2 - blue/purple - theta
     * 3 - purple ------ alpha 
     * 4 - purple/red -- low beta
     * 5 - dark red ---- mid beta
     * 6 - red --------- high beta
     * 
     * This sketch will measure all brain waves, from 0 - 30 Hz. It does
     * best, however, measuring alpha waves across the occipital lobe.
     * To view this function, play the program, click the window to
     * make sure its in "focus", and hit the "a" key to bandpass the alpha
     * waves only. The alpha wave bar is the 3rd one (purple), and should
     * increase in height by 2-3x when you close your eyes and relax
     * (you'll see it for a second or two after you open your eyes, before it
     * averages back down).
     */
    
    /* One issue: when taking the FFT of the data, it seems as if
    the frequency bands have a bandwidth of 1.33 instead of 1, as 
    60Hz noise peaks out at band 45. This is worked around by using
    the scaleFreq parameter, which is used frequently. */
    
    
    import ddf.minim.*;
    import ddf.minim.signals.*;
    import ddf.minim.analysis.*;
    import ddf.minim.effects.*;
    
    //Important constants that may need to be changed.
    float timeScale = 50; //scales the amplitude of time-domain data, can be changed
    static float normalScale = 50;
    static float alphaScale = 100;
    static int freqAvgScale = 50; //does same for averages of frequency data
    static int alphaCenter = 12;
    static int alphaBandwidth = 2; //really bandwidth divided by 2
    static int betaCenter = 24;
    static int betaBandwidth = 2;
    
    //Variables used to store data functions/effects.
    Minim minim;
    AudioInput in;
    FFT fft;
    NotchFilter notch;
    LowPassSP lpSP;
    LowPassFS lpFS;
    BandPass betaFilter;
    BandPass alphaFilter;
    
    //Constants mainly used for scaling the data to readable sizes.
    int windowLength = 840;
    int windowHeight = 500;
    int FFTheight;
    float scaling[] = {.00202,.002449/2,.0075502/2,.00589,.008864,.01777};
    float offset[] = {0,0,0,0,0,0};
    float amplify[] = {1,1,1,1,1,1};
    float maximum[] = {0,0,0,0,0,0};
    float scaledMaximum[] = {0,0,0,0,0,0};
    int FFTrectWidth = 6;
    float scaleFreq = 1.33f;
    float timeDomainAverage = 0;
    
    //Variables used to handle bad data 
    int cutoffHeight = 200; //frequency height to throw out "bad data" for averaging after
    float absoluteCutoff = 1.5;
    boolean absoluteBadDataFlag; //data that is bad because it's way too far out of our desired range --
                                 // ex: shaking your head for a second
    boolean averageBadDataFlag;  //data that's bad because it spikes too far outside of the average for 
                                 //that second -- 
                                 // ex: blinking your eyes for a split second
    
    //Constants used to create a running average of the data.
    float[][] averages;
    int averageLength = 200; //averages about the last 5 seconds worth of data
    int averageBins = 6; //we have 6 types of brain waves
    int counter = 0;
    
    void setup()
    {
      //initialize array of averages for running average calculation
      averages = new float[averageBins][averageLength];
      for (int i = 0; i &lt; averageBins; i++){
        for (int j = 0; j &lt; averageLength; j++){
          averages[i][j] = 0;
        }
      }
      
      //set some drawing parameters
      windowLength = 840;
      windowHeight = 500;
      FFTheight = windowHeight - 200;
      
      size(windowLength, windowHeight, P2D);
      
      //initialize minim, as well as some filters
      minim = new Minim(this);
      minim.debugOn();
      notch = new NotchFilter(60, 10, 32768);
      lpSP = new LowPassSP(40, 32768);
      lpFS = new LowPassFS(60, 32768);
      betaFilter = new BandPass(betaCenter/scaleFreq,betaBandwidth/scaleFreq,32768);
      alphaFilter = new BandPass(alphaCenter/scaleFreq,alphaBandwidth/scaleFreq,32768);
      
      // get a line in from Minim, default bit depth is 16
      in = minim.getLineIn(Minim.MONO, 8192*4);
      in.addEffect(notch);
      
      //initialize FFT
      fft = new FFT(in.bufferSize(), in.bufferSize());
      fft.window(FFT.HAMMING);
      rectMode(CORNERS);
      println(fft.getBandWidth());
    }
    
    void draw()
    {
      /*badDataFlag handles any "artifacts" we may pick up while recording the data.
      Artifacts are essentially imperfections in the data recording -- they can come
      from muscle movements, blinking, anything that disturbs the electrodes. If the 
      program encounters a set of data that spikes out of a reasonable window 
      (controlled by the variable cutoffHeight), it won't consider that data
      when computing the running average.
      */
      absoluteBadDataFlag = false;
      averageBadDataFlag = false;
    
      fft.forward(in.mix); //compute FFT
      background(0); //make sure the background color is black
      stroke(255);   //and that time data is drawn in white
      
      line(0,100,windowLength,100); //line separating time and frequency data
      
      drawSignalData();
      
      //check for spikes relative to other data
      for (int i = 0; i &lt; windowLength - 1; i++){
        if (abs(in.left.get((i+1)*round(in.bufferSize()/windowLength))) &gt; timeDomainAverage*4)
          averageBadDataFlag = true;
      }
      
      displayText();
      
      displayFreqAverages();
      
      counter++;
    }
    
    //Calls function to zoom into average bars when you right click on the average bars.
    //Scales depending on position of click.
    void mousePressed(){
      if (mouseButton == RIGHT &amp;&amp; mouseY &gt; FFTheight){
        scaleAverage(floor(mouseX/(windowLength/averageBins)), windowHeight - mouseY);
      }
    }
    
    //Zooms into average bars to show small fluctuations better. New range (from original) is 
    //from position clicked on to a maximum height such that the previously logged maximum fills 75% of the 
    //current bar.
    void scaleAverage(int bin, float pos){
      offset[bin] += pos/amplify[bin];
      println(offset[bin]);
      amplify[bin] *= 200/(1.33f*(scaledMaximum[bin] - pos));
      println(amplify[bin]);
      maximum[bin] = 0;
      scaledMaximum[bin] = 0;
    }
    
    //Hitting number keys will reset that bin of averages, hitting "`" will wipe them all.
    void keyPressed(){
      if (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6'){
        char data[] = {key};
        String str1 = new String(data);
        int keyNum = Integer.parseInt(str1);
        keyNum -= 1; //shift down 1 since array is zero-indexed
        offset[keyNum] = 0;
        amplify[keyNum] *= 1;
        maximum[keyNum] = 0;
        scaledMaximum[keyNum] = 0;
      }
      
      if (key == '`'){
        for (int i = 0; i &lt; offset.length; i++){
          offset[i] = 0;
          amplify[i] = 1;
          maximum[i] = 0;
          scaledMaximum[i] = 0;
        }
      }
      if (key == 'w'){
        fft.window(FFT.HAMMING);
      }
      if (key == 'e'){
        fft.window(FFT.NONE);
      }
      if (key == 'a'){
        toggleEffect(alphaFilter);
      }
      if (key == 'b'){
        toggleEffect(betaFilter);
      }
    }
    
    //Toggle effects such as notch or lowpass filter, not being used at
    //the moment, though.
    void toggleEffect(AudioEffect effect){
      if(in.hasEffect(effect)){
        in.removeEffect(effect);
        timeScale = normalScale;
      }
      else{
        in.addEffect(effect);
        timeScale = alphaScale;
      }
    }
    
    //Draw the signal in time and frequency.
    void drawSignalData(){
      timeDomainAverage = 0;
      for(int i = 0; i &lt; windowLength - 1; i++)
        {
          stroke(255,255,255);
          //data that fills our window is normalized to +-1, so we want to throw out
          //sets that have data that exceed this by the factor absoluteCutoff
          if (abs(in.left.get(i*round(in.bufferSize()/windowLength)))*timeScale/normalScale &gt; .95){
              absoluteBadDataFlag = true;
              fill(250,250,250);
              stroke(150,150,150);
            }
          //Draw the time domain signal.
          line(i, 50 + in.left.get(i*round(in.bufferSize()/windowLength))*timeScale, 
               i+1, 50 + in.left.get((i+1)*round(in.bufferSize()/windowLength))*timeScale);
               
          timeDomainAverage += abs(in.left.get(i*round(in.bufferSize()/windowLength)));
          
          //Draw un-averaged frequency bands of signal.
          if (i &lt; (windowLength - 1)/2){
            //set colors for each type of brain wave
              if (i &lt;= round(3/scaleFreq)){             
                fill(0,0,250);        //delta
                stroke(25,0,225);
              }
              if (i &gt;= round(4/scaleFreq) &amp;&amp; i &lt;= round((alphaCenter - alphaBandwidth)/scaleFreq)-1){
                fill(50,0,200);       //theta
                stroke(75,0,175);
              }
              if (i &gt;= round((alphaCenter - alphaBandwidth)/scaleFreq) &amp;&amp; 
              i &lt;= round((alphaCenter + alphaBandwidth)/scaleFreq)){  
                fill(100,0,150);      //alpha
                stroke(125,0,125);
              }
              if (i &gt;= round((alphaCenter + alphaBandwidth)/scaleFreq)+1 &amp;&amp; 
              i &lt;= round((betaCenter-betaBandwidth)/scaleFreq)-1){ 
                fill(150,0,100);      //low beta
                stroke(175,0,75);
              }
              if (i &gt;= round((betaCenter - betaBandwidth)/scaleFreq) &amp;&amp; 
              i &lt;= round((betaCenter + betaBandwidth)/scaleFreq)){ 
                fill(200,0,50);       //midrange beta
                stroke(225,0,25);
              }
              if (i &gt;= round((betaCenter + betaBandwidth)/scaleFreq)+1 &amp;&amp; i &lt;= round(30/scaleFreq)){ 
                fill(250,0,0);        //high beta
                stroke(255,0,10);
              }
              if (i &gt;= round(32/scaleFreq)){
                fill(240,240,240);    //rest of stuff, mainly noise
                stroke(200,200,200);
              }
              if (i == round(60/scaleFreq)){
                fill(200,200,200);    //color 60 Hz a different tone of grey,
                stroke(150,150,150);  //to see how much noise is in data
              }
            //draw the actual frequency bars
            rect(FFTrectWidth*i, FFTheight, FFTrectWidth*(i+1), FFTheight - fft.getBand(i)/10);
          }
        }
      //divide the average by how many time points we have
      timeDomainAverage = timeDomainAverage / (windowLength - 1);
    }
    
    //Give user textual information on data being thrown out and filter's we have active.
    void displayText(){
      //show user when data is being thrown out
      text("absoluteBadDataFlag = " + absoluteBadDataFlag, windowLength - 200, 120);
      if (absoluteBadDataFlag == true)
      {
        println("absoluteBadDataFlag = " + absoluteBadDataFlag);
        println(counter);
      }
      text("averageBadDataFlag = " + averageBadDataFlag, windowLength - 200, 140);
      if (averageBadDataFlag == true)
      {
        println("averageBadDataFlag = " + averageBadDataFlag);
        println(counter);
      }
    
      //and when a filter is being applied to the data
      text("alpha filter is " + in.hasEffect(alphaFilter),
        windowLength - 200, 160);
      text("beta filter is " + in.hasEffect(betaFilter),
        windowLength - 200, 180);
    }
    
    //Compute and display averages for each brain wave for the past ~5 seconds.
    void displayFreqAverages(){
      //show averages of alpha, beta, etc. waves
      for (int i = 0; i &lt; 6; i++){
        float avg = 0; //raw data for amplitude of section of frequency
        int lowFreq = 0;
        int hiFreq = 0;
      
        //Set custom frequency ranges to be averaged. 
        if(i == 0){
          lowFreq = 0;
          hiFreq = 3;
          fill(0,0,250);
          stroke(25,0,225);
        }
        if(i == 1){
          lowFreq = 3;
          hiFreq = 7;
          fill(50,0,200);
          stroke(75,0,175);
        }
        if(i == 2){
          lowFreq = alphaCenter - alphaBandwidth;
          hiFreq = alphaCenter + alphaBandwidth;
          fill(100,0,150);
          stroke(125,0,125);
        }
        if(i == 3){
          lowFreq = 12;
          hiFreq = 15;
          fill(150,0,100);
          stroke(175,0,75);
        }
        if(i == 4){
          lowFreq = betaCenter - betaBandwidth;
          hiFreq = betaCenter + betaBandwidth;
          fill(200,0,50);
          stroke(225,0,25);
        }
        if(i == 5){
          lowFreq = 20;
          hiFreq = 30;
          fill(250,0,0);
          stroke(255,0,10);
        }
        
        //Convert frequencies we want to the actual FFT bands. Because of our
        //FFT parameters, these happen to be equal (each band has a 1 Hz width).
        int lowBound = fft.freqToIndex(lowFreq);
        int hiBound = fft.freqToIndex(hiFreq);
        
        //Scale the band number, because of the issue outlined at very beginning of
        //program.
        lowBound = round(lowBound/scaleFreq);
        hiBound = round(hiBound/scaleFreq);
        
        //get average for frequencies in range
        for (int j = lowBound; j </pre>
]]></description>
   </item>
   <item>
      <title>OSC (Open Sound Control) Parsing Messages : how to use class functions</title>
      <link>https://forum.processing.org/two/discussion/4434/osc-open-sound-control-parsing-messages-how-to-use-class-functions</link>
      <pubDate>Wed, 16 Apr 2014 05:38:33 +0000</pubDate>
      <dc:creator>gennylk</dc:creator>
      <guid isPermaLink="false">4434@/two/discussions</guid>
      <description><![CDATA[<p>Hi There, I am reading some data processed in a Gesture Recognition Kit, and the data is sent, and received via OSC (Open Sound Control) via Processing OSC Library. Although i've dabbled with OSC Messages I need some help to understand the code in the class file(See below) to read OSC data</p>

<p>The GRT class partly indicated at the end of this post is provided by the developer to send and receive message from OSC.  NOTE : Since the code is too long to be included in this post i've shared it via  <a rel="nofollow" href="http://txt.do/t6wf">txt.do/t6wf</a></p>

<p>My Question is When I have to use this class to parse messages receivedfrom OSC, what should I write in my main code ? 
 (I know how to send data from processing to OSC).</p>

<p>I guess i have to first initialze it like</p>

<pre><code>final int pipelineMode = GRT.CLASSIFICATION_MODE;
final int numInputs = 4;//NO OF INPUTS
final int numOutputs = 1;
//Create a new GRT instance, this will initalize everything for us and send the setup message to the GRT GUI
GRT grt = new GRT( pipelineMode, numInputs, numOutputs, "192.168.16.108", 5000, 5001, true );
</code></pre>

<p>and then</p>

<p>if OSCEvent.......?</p>

<p>Thanks in advance
Genny</p>

<pre><code>/**
GRT
Version: 1.0
Author: Nick Gillian

Info: This class acts as an interface to the GRT GUI. It sends data and commands to the GUI via Open Sound Control (OSC). To use this
code you should download and install the Processing OSC library from: <a href="http://www.sojamo.de/libraries/oscP5/" target="_blank" rel="nofollow">http://www.sojamo.de/libraries/oscP5/</a>
*/

class GRT{

  private OscP5 oscP5;
  private NetAddress grtBackend;

  private boolean initialized;
  private boolean record;
  private int pipelineMode;
  private int numDimensions;
  private int targetVectorSize;
  private int trainingClassLabel;
  private int predictedClassLabel;

  private int grtPipelineMode;
  private boolean grtPipelineTrained;
  private boolean grtRecording;
  private int grtNumTrainingSamples;
  private int grtNumClassesInTrainingData;
  private String grtInfoText;

  private float maximumLikelihood;
  private float[] preProcessedData;
  private float[] featureExtractionData;
  private float[] classLikelihoods;
  private float[] classDistances;
  private float[] regressionData;
  private float[] targetVector;
  private int[] classLabels;

  //Pipeline Modes
  public static final int CLASSIFICATION_MODE = 0;
  public static final int REGRESSION_MODE = 1;
  public static final int TIMESERIES_MODE = 2;

  //Classifier Types
  public static final int ANBC = 0;
  public static final int ADABOOST = 1;
  public static final int GMM = 2;
  public static final int KNN = 3;
  public static final int MINDIST = 4;
  public static final int SOFTMAX = 5;
  public static final int SVM = 6;

  /**
   Default constructor
  */
  GRT(){
    initialized = false;
  }

  /**
   Main constructor used to initialize the instance.

   <a href="/two/profile/param">@param</a> int pipelineMode: sets the mode that the pipeline will run in. This should be a valid pipeline mode, either CLASSIFICATION_MODE, REGRESSION_MODE, or TIMESERIES_MODE
   <a href="/two/profile/param">@param</a> int numInputs: sets the size of your data vector, this is the data that you will send to the GRT GUI
   <a href="/two/profile/param">@param</a> int numOutputs: this parameter is only used for REGRESSION_MODE, in which case it sets the target vector size
   <a href="/two/profile/param">@param</a> String grtIPAddress: the IP address of the machine running the GRT GUI. If it is running on the same machine as this Processing Sketch this should be "127.0.0.1"
   <a href="/two/profile/param">@param</a> int grtPort: the network port that the GRT GUI is listening for connections on. This is set by the OSC Receive Port setting in the GRT GUI
   <a href="/two/profile/param">@param</a> int listenerPort: the network port that this Processing Sketch should listen for OSC messages from the GRT GUI
   <a href="/two/profile/param">@param</a> bool sendSetupMessage: if true then the Setup message will be sent to the GRT GUI, if false then the message will not be sent
  */
  GRT(int pipelineMode,int numInputs,int numOutputs,String grtIPAddress,int grtPort,int listenerPort, boolean sendSetupMessage){
    initialized = init( pipelineMode, numInputs, numOutputs, grtIPAddress, grtPort, listenerPort, sendSetupMessage );
  }

  /**

// &lt;&lt;&lt;&lt;Cropped due to space Limitation&gt;&gt;

  /**
   This function is called anytime a new OSC message is received. It will then try and parse the message.
  */
  void oscEvent(OscMessage theOscMessage) {

    if( parseMessage( theOscMessage ) ) return;

  }

  /**
   This function parses OSC messages from the GRT GUI. 

   <a href="/two/profile/param">@param</a> OscMessage theOscMessage: the osc message to parse
   <a href="/two/profile/return">@return</a> returns true if the message was successfully parsed, false otherwise
  */
  boolean parseMessage(OscMessage theOscMessage) {

    if( theOscMessage.checkAddrPattern("/Status")==true) {
      grtPipelineMode = theOscMessage.get(0).intValue();
      grtPipelineTrained = theOscMessage.get(1).intValue() == 1 ? true : false;
      grtRecording = theOscMessage.get(2).intValue() == 1 ? true : false;
      grtNumTrainingSamples = theOscMessage.get(3).intValue();
      grtNumClassesInTrainingData = theOscMessage.get(4).intValue();
      grtInfoText = theOscMessage.get(5).stringValue();
      return true;
    }

    if(theOscMessage.checkAddrPattern("/PreProcessedData")==true) {
      int N = theOscMessage.get(0).intValue();
      if( preProcessedData.length != N ){
        preProcessedData = new float[N]; 
      }
      for(int i=0; i&lt;N; i++){
        preProcessedData[i] =  theOscMessage.get(i+1).floatValue();
      }
      return true;
    }

    if(theOscMessage.checkAddrPattern("/FeatureExtractionData")==true) {
      int N = theOscMessage.get(0).intValue();
      if( featureExtractionData.length != N ){
        featureExtractionData = new float[N]; 
      }
      for(int i=0; i&lt;N; i++){
        featureExtractionData[i] =  theOscMessage.get(i+1).floatValue();
      }
      return true;
    }

    if(theOscMessage.checkAddrPattern("/Prediction")==true) {
      if(theOscMessage.checkTypetag("if")) {
        predictedClassLabel = theOscMessage.get(0).intValue();
        maximumLikelihood = theOscMessage.get(1).floatValue();
        return true;
      }   
    }

    if(theOscMessage.checkAddrPattern("/ClassLikelihoods")==true) {
        int N = theOscMessage.get(0).intValue();
        if( classLikelihoods.length != N ) classLikelihoods = new float[N];

        for(int i=0; i&lt;N; i++){
          classLikelihoods[i] = theOscMessage.get(1+i).floatValue();
        }
        return true;
    }

    if(theOscMessage.checkAddrPattern("/ClassDistances")==true) {
        int N = theOscMessage.get(0).intValue();
        if( classDistances.length != N ) classDistances = new float[N];

        for(int i=0; i&lt;N; i++){
          classDistances[i] = theOscMessage.get(1+i).floatValue();
        }
        return true;
    }

    if(theOscMessage.checkAddrPattern("/ClassLabels")==true) {
      int N = theOscMessage.get(0).intValue();
      if( classLabels.length != N ) classLabels = new int[N]; 

      for(int i=0; i&lt;N; i++){
        classLabels[i] = theOscMessage.get(i+1).intValue();
      }
      return true;
    }

     if(theOscMessage.checkAddrPattern("/RegressionData")==true) {
        int N = theOscMessage.get(0).intValue();
        if( regressionData.length != N ) regressionData = new float[N];
        for(int i=0; i&lt;N; i++){
          regressionData[i] = theOscMessage.get(1+i).floatValue();
        }
        return true;
    }

    return false;

  }

};
</code></pre>
]]></description>
   </item>
   </channel>
</rss>