<?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 oscevent() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=oscevent%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:32:29 +0000</pubDate>
         <description>Tagged with oscevent() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedoscevent%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to connect processing with gh using UDP or OSC?</title>
      <link>https://forum.processing.org/two/discussion/28033/how-to-connect-processing-with-gh-using-udp-or-osc</link>
      <pubDate>Thu, 31 May 2018 03:18:24 +0000</pubDate>
      <dc:creator>vapeur</dc:creator>
      <guid isPermaLink="false">28033@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
 I am trying to receive some data from grasshopper, and I firstly use OCSP5 library, which allows sending message to gh but cannot receive. And I tried UDP class, but the processing keeps saying the library cannot be used...
I was wondering is there a way to get the newer version of the UDP library, or is there a way to receiving data from grasshopper?</p>

<p>Thanks!</p>

<p>I am really try with a simple sketch.</p>

<pre><code>import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;

float mySum;

void setup()
{
  frameRate(25);
  oscP5 = new OscP5(this,12000);
  myRemoteLocation = new NetAddress("10.10.15.157",12000);
  oscP5.addListener(myListener);
  mySum = 0;
}

void draw()
{
  background(0);
}

/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
  print ("oscEvent"+theOscMessage.addrPattern()+theOscMessage.arguments());
}
</code></pre>

<p>and when I send data from grasshopper, the console says NullPointerException, 
and print something in console like</p>

<pre><code>java.lang.NullPointerException
    at oscP5.OscP5.callMethod(Unknown Source)
    at oscP5.OscP5.process(Unknown Source)
    at oscP5.OscNetManager.process(Unknown Source)
    at netP5.AbstractUdpServer.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)
</code></pre>

<p>I commented the initiation for Add listener, and it worked...sorry 
I've got this in console</p>

<p><code>oscEvent/GH/none[Ljava.lang.Object;@54f912f5</code></p>

<p>Thanks for your time!</p>

<p>==============================</p>

<p>update
Now my new sketch, what troubles me now is that I don't want the java object, but a list of doubles. 
But I got Error in console</p>

<p>code:</p>

<pre><code>import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
OscMessage arrayMsg = new OscMessage("/array");

void setup()
{
  frameRate(25);
  oscP5 = new OscP5(this,12000);
  myRemoteLocation = new NetAddress("10.10.15.157",12000);
}

void draw()
{
  background(0);
}

void oscEvent(OscMessage theOscMessage) {
  println("Address pattern: "+theOscMessage.addrPattern());
  println ("Typetag: "+theOscMessage.typetag());
  println ("Arguments: "+theOscMessage.get(0).doubleValue());
}
</code></pre>

<p>and the console prints</p>

<pre><code>Address pattern: /test01
Typetag: ssss
### [2018/5/31 15:22:4] ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage
 to a method in your program. please check your code for any 
possible errors that might occur in the method where incoming
 OscMessages are parsed e.g. check for casting errors, possible
 nullpointers, array overflows ... .
method in charge : oscEvent  java.lang.reflect.InvocationTargetException
</code></pre>
]]></description>
   </item>
   <item>
      <title>Pitch, Roll, Yaw using rotateX/Y/Z query</title>
      <link>https://forum.processing.org/two/discussion/27557/pitch-roll-yaw-using-rotatex-y-z-query</link>
      <pubDate>Fri, 30 Mar 2018 21:33:08 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27557@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to represent the orientation of my phone being held upright. I'm using a simple rectangle for starters. I am sending messages over OSC. Each of my 3 values; pitch, roll and yaw (Azimuth) goes from -180degrees to +180degrees.</p>

<p>I am going by the example in the picture below my code, where X is pitch and Y is roll:</p>

<p>When I use just two values, (eg just pitch and roll) the orientation seems to be represented normally. But when I throw the third into the mix, it gets a little wild.</p>

<p>I don't have another device right now to check if it's the phone sensors that are faulty. Looking at the rotateX(and Y and Z) examples, this should work as is. I guess there's something a bit deeper I'm missing?</p>

<p>Thanks</p>

<pre><code>import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
float ZyawValue, XpitchValue, YrollValue;


void setup() {
  size(360, 360, P3D);
  lights();
  noStroke();
  colorMode(RGB, 256); 

  oscP5 = new OscP5(this,34567);
  myRemoteLocation = new NetAddress("192.168.1.7",34567);
}


void draw() {
  background(100);
  rectMode(CENTER);
  fill(51);
  stroke(255);

  pushMatrix();
  translate(width/2, height/2, 0);

    rotateX(radians(XpitchValue));
    rotateY(radians(-YrollValue));
    rotateZ(radians(ZyawValue));     // **Issues**

  rect(0, 0, 50, 100);
  popMatrix();

  textSize(24);
  String gyrStr1 = "X=Roll: " + (int) YrollValue; 
  String gyrStr2 = "Y=Pitch: " + (int) XpitchValue; 
  String gyrStr3 = "Z=Yaw: " + (int) ZyawValue; 
  fill(249, 250, 50);
  text(gyrStr1, (int) (width/6.0) - 40, 50); 
  text(gyrStr2, (int) (width/6.0) - 40, 100); 
  text(gyrStr3, (int) (width/6.0) - 40, 150);   
}



void oscEvent(OscMessage theOscMessage) {

  if(theOscMessage.checkAddrPattern("/orientation/azimuth")==true) { 
    if(theOscMessage.checkTypetag("f")) {
      ZyawValue = theOscMessage.get(0).floatValue();  
      return;
    }  
  }

  if(theOscMessage.checkAddrPattern("/orientation/pitch")==true) { 
    if(theOscMessage.checkTypetag("f")) 
    {
      XpitchValue = theOscMessage.get(0).floatValue();  
      return;
    }  
  } 

  if(theOscMessage.checkAddrPattern("/orientation/roll")==true) { 
    if(theOscMessage.checkTypetag("f")) {
      YrollValue = theOscMessage.get(0).floatValue();
      return;
    }  
  }   
  println("Azimuth: "+ZyawValue+", Pitch: "+XpitchValue+", Roll: "+YrollValue);
}
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/717/JGTPTPO6MT7I.png" alt="Screen Shot 2018-03-30 at 21.45.50" title="Screen Shot 2018-03-30 at 21.45.50" /></p>
]]></description>
   </item>
   <item>
      <title>Simple OSC receive from OpenFrameworks question.</title>
      <link>https://forum.processing.org/two/discussion/27384/simple-osc-receive-from-openframeworks-question</link>
      <pubDate>Tue, 27 Mar 2018 00:05:51 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27384@/two/discussions</guid>
      <description><![CDATA[<p>Hey there. I'm setting up some basic OSC comm from OpenFrameworks(in Xcode) to Processing. Attached are screenshots of the code on each side. The " x: " is unusual to me on the OF side. I'm new to OF however. I'm seeking tips on the correct code for the Processing side of things. Many thanks :)</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/982/UWGZLQBHONGL.png" alt="of" title="of" />
<img src="https://forum.processing.org/two/uploads/imageupload/110/CA7PV7QDTSBJ.png" alt="pr" title="pr" /></p>
]]></description>
   </item>
   <item>
      <title>Problems with Buffer (EyeTracker)</title>
      <link>https://forum.processing.org/two/discussion/26453/problems-with-buffer-eyetracker</link>
      <pubDate>Tue, 20 Feb 2018 14:54:56 +0000</pubDate>
      <dc:creator>eyetrackeruntref</dc:creator>
      <guid isPermaLink="false">26453@/two/discussions</guid>
      <description><![CDATA[<p>I'm receiving data from Matlab (1000fps) of a subject looking a picture using EyeTracker Hardware. [both in different computers].</p>

<p>Connection is OK, UDP is fine, OSC is working thanks to oscP5.</p>

<p>With the data, I draw circles ( that are designed by X and Y axis from EyeTracker device ) in a canvas.</p>

<p>Now the problem is that I don't know how to build a proper buffer to receive all this massive information, and then, after few milliseconds erase it. Because I want to see in my canvas, the eyes moving on real time drawing circles, but i just want to see 1 circle, not all of them, eventhough i don't need to save all this information.</p>

<p>If you don't understand something, please ask me, and I'll try to explain you better:</p>

<p>I have this code, feel free to ask and say whatever you want :</p>

<pre><code>/**
 * oscP5parsing by andreas schlegel
 * example shows how to parse incoming osc messages "by hand".
 * it is recommended to take a look at oscP5plug for an
 * alternative and more convenient way to parse messages.
 * oscP5 website at <a href="http://www.sojamo.de/oscP5" target="_blank" rel="nofollow">http://www.sojamo.de/oscP5</a>
 */
import java.util.*;

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

ArrayList &lt;Posiciones&gt; buffer  = new ArrayList&lt;Posiciones&gt;();

//Iterator &lt;Posiciones&gt; itr = new ArrayList&lt;Posiciones&gt;();


long tiempoX = 1000;
long tiempoActual = millis(); 

float x1, y1, x2, y2;
float diamt = 20;

float ancho = 400;
float alto = 400;

void setup() {
  size(400, 400); 
  smooth();
  noStroke();
  /* start oscP5, listening for incoming messages at port 8002 */
  oscP5 = new OscP5(this, 8002); //Pasar este puerto al experimento de MatLab

  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
   * an ip address and a port number. myRemoteLocation is used as parameter in
   * oscP5.send() when sending osc packets to another computer, device, 
   * application. usage see below. for testing purposes the listening port
   * and the port of the remote location address are the same, hence you will
   * send messages back to this sketch.
   */
  //myRemoteLocation = new NetAddress("127.0.0.1", 4002);
}

void draw() {

  escupirData();
  dibujarCirculos();
}

void oscEvent(OscMessage theOscMessage) {
  /* check if theOscMessage has the address pattern we are looking for. */

  if (theOscMessage.checkAddrPattern("/test")==true) {
    /* check if the typetag is the right one. */
    //println(theOscMessage);
    if (theOscMessage.checkTypetag("s")) {
      /* parse theOscMessage and extract the values from the osc message arguments. */
      String stringValue = theOscMessage.get(0).stringValue();
      println(" values: " + stringValue);

      int[] datos = int(split(stringValue, "-")); //divide los datos y los guarda temporalmente //  divide data and save temporarily
      Posiciones crearPosiciones = new Posiciones(); //creo un objeto para guardar la data // creating an object to save the data
      crearPosiciones.x1 = datos[0]; //guardo la data // saving data
      crearPosiciones.y1 = datos[1];
      crearPosiciones.x2 = datos[2];
      crearPosiciones.y2 = datos[3];
      buffer.add(crearPosiciones); //agrego un elemento al arrayList/buffer // adding an element to arrayList/buffer

      return;
    }
  }
}

void escupirData() {

  long currentMillis = millis();

  if (millis() - tiempoActual &gt;= tiempoX ) {
    //Pixel newPixel = pixeles.get(i); 

    if (buffer.size() &gt; 0) { //fijarse si el buffer tiene elementos // look if the buffer has elements
      Posiciones posicionActual = buffer.get(0); //creo un objeto para guardar el primer objeto del buffer // creating an object to save the first object of the buffer

      x1 = posicionActual.x1; //guardo la data para usar // saving the data to use
      y1 = posicionActual.y1;
      x2 = posicionActual.x2;
      y2 = posicionActual.y2;


      posicionActual.borrar = true;//si ya lo dibujé levanto el flag para borrarlo // if it is drawn, clear

      println(" borrado: " + posicionActual.borrar);

      tiempoActual = millis();
    }
  }

  //crear un iterator, que si ya dibujó la posición lo borre por el flag // creating an iterator

  //creo un iterator para podes remover lugares del ArrayList // creating an iterator to remove spots of ArrayList
  Iterator itr = buffer.iterator();
  // itr = buffer.iterator();
  while (itr.hasNext ()) {
    Posiciones posicionActual = (Posiciones)itr.next();
    if (posicionActual.borrar) {
      itr.remove(); //remuevo la frase que ya no se ve // removing the phrase that is not visible
      println("borré 1, quedan " + buffer.size() + " posiciones");
    }
  }
}

void dibujarCirculos() {

  x1 = map(x1, 0, ancho, 0, width); 
  y1 = map(y1, 0, ancho, 0, height);
  x2 = map(x2, 0, ancho, 0, width); 
  y2 = map(y2, 0, ancho, 0, height); 

  fill(255, 0, 0);
  ellipse(x1, y1, diamt, diamt);
  fill(0, 0, 255);
  ellipse(x2, y2, diamt, diamt);
}


AND THIS CLASS :

class Posiciones {
  int x1, y1, x2, y2;
  boolean borrar = false;


  Posiciones() {
  }

  void vacio() {
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Cannot get booleanValue() with oscP5</title>
      <link>https://forum.processing.org/two/discussion/12805/cannot-get-booleanvalue-with-oscp5</link>
      <pubDate>Sat, 03 Oct 2015 20:36:28 +0000</pubDate>
      <dc:creator>LDB477</dc:creator>
      <guid isPermaLink="false">12805@/two/discussions</guid>
      <description><![CDATA[<p>Hello!  I'm scratching my head here trying to figure this out, trying to use booleanValue() in an oscEvent is giving me problems.  When I run these together, program 2 gives me an Osc error.  The interesting thing is that typetag() give "T" and "F" when program 1 is running with mouseClicks.  Are these supposed to be type 'b'?  I've dug through the java reference doc and haven't found anything, even the booleanValue() example code doesn't include booleanValue....</p>

<p>Thanks for any help with this.</p>

<p>I'll post both both codes I'm using to talk to each other for good reference:</p>

<p>Program 1:</p>

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

OscP5 clickSend;
NetAddress clickSendLocation;

boolean click = false;

void setup(){

  size(200,200);
  textAlign(CENTER);
  fill(0);

  clickSend = new OscP5(this, 5001);
  clickSendLocation = new NetAddress("127.0.0.1", 6001);


}

void draw(){
  background(255);

  if (mousePressed){
    click = true;
  } else {
    click = false;
  }

  if (click == true){
    text("CLICK", width/2, height/2);
  }

  OscMessage clickMessage = new OscMessage("clickMessage");
  if (click == true){
    clickMessage.add(true);
  } else if (click == false){
    clickMessage.add(false);
  }

  clickSend.send(clickMessage, clickSendLocation);

}
</code></pre>

<p>Program 2:</p>

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

OscP5 clickGet;
NetAddress clickGetLocation;

boolean click = false;

void setup(){

  size(200,200);
  textAlign(CENTER);
  fill(0);

  clickGet = new OscP5(this, 6001);
  clickGetLocation = new NetAddress("127.0.0.1", 5001);

}

void draw(){
  background(255);



  if (click == true){
    text("CLICK", width/2, height/2);
  } else if (click == false){
    text("NO CLICK", width/2, height/2);
  }



}

void oscEvent(OscMessage clickGetMessage){
  println("Received message.");
  println("addrPattern: "+clickGetMessage.addrPattern());
  println("typetag: "+clickGetMessage.typetag());
  println("booleanValue() = " + clickGetMessage.get(0).booleanValue());


  if (clickGetMessage.get(0).booleanValue() == true){
    click = true;
    println("Click = true");
  } else if (clickGetMessage.get(0).booleanValue() == false){
    click = false;
    println("Click = false");
  }


}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Using oscP5 over the internet</title>
      <link>https://forum.processing.org/two/discussion/26082/using-oscp5-over-the-internet</link>
      <pubDate>Mon, 22 Jan 2018 22:22:22 +0000</pubDate>
      <dc:creator>VladShev</dc:creator>
      <guid isPermaLink="false">26082@/two/discussions</guid>
      <description><![CDATA[<p>Hello all,
I'm currently trying to figure out how to use the ocsP5 module to communicate over the internet. I have made 2 simple client and server sketches which act as a simple shared drawing canvas. I'm not posting the code in this thread to avoid cluttering, as each one is about 70 lines even after I removed all the unessential code. They can be found here:</p>

<p>Server: <a href="https://pastebin.com/NgsRaLJP" target="_blank" rel="nofollow">https://pastebin.com/NgsRaLJP</a><br />
Client: <a href="https://pastebin.com/L4UqD7Uw" target="_blank" rel="nofollow">https://pastebin.com/L4UqD7Uw</a></p>

<p>Now the curious thing is that my code works when both are run simultaneously on my computer and the server-ip in the client is set to '127.0.0.1'. Now when I replace that with my actual IP (IPV6) and run both on the same computer a strange effect happens - the server can draw on itself and the client, while the client can only draw on itself. If I export the client to my Android phone and run it off a separate network from the server, neither client nor server can draw on each other. I have triple-checked that the server-listening-port is portforwarded through my router and that the client, when ran on Android, has the 'CHANGE WIFI MULTICAST STATE' permission enabled.</p>

<p>What am I doing terribly wrong? Thanks in advance!</p>
]]></description>
   </item>
   <item>
      <title>How could I use a function from different class?</title>
      <link>https://forum.processing.org/two/discussion/25814/how-could-i-use-a-function-from-different-class</link>
      <pubDate>Thu, 04 Jan 2018 13:53:11 +0000</pubDate>
      <dc:creator>hsawa</dc:creator>
      <guid isPermaLink="false">25814@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I am quite new to Prcoessing and I am stuck on using functions from a class to another function. I basically want to use 'void update' in 'void oscEvent(OscMessage theOscMessage' to send update function to OSC. 
Hope my problem makes sense :(</p>

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

<pre><code>void draw() {
  background(0);
  for (Particle p : particles) {
    p.update();
  }
}

class Particle {

  PVector position, velocity;

  void update() {
    PVector mouse = new PVector(map(mouseX, 0, width, -width / 2, width / 2), map(mouseY, 0, height, -height / 2, height / 2), 0);
    PVector acc = PVector.sub(mouse, position);


    acc.limit(FULL_ACC);
    velocity.add(acc);
    velocity.limit(FULL_VEL);
    position.add(velocity);
  }

  void oscEvent(OscMessage theOscMessage) {
    if (theOscMessage.checkAddrPattern("/output_1")==true) {
      update(); //problem is here, what is the proper way in order for the OSC to pick up this info? 
      println("mouseMoved");
    } else if (theOscMessage.checkAddrPattern("/output_2")==true) {
      update();
      println("mouseMoved");
    } else if (theOscMessage.checkAddrPattern("/output_3") == true) {
      update();
      println("mouseMoved");
    } else {
      println("Unknown OSC message received");
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Receive OSC using OscP5 library, Android Mode 4.0-beta2</title>
      <link>https://forum.processing.org/two/discussion/18194/receive-osc-using-oscp5-library-android-mode-4-0-beta2</link>
      <pubDate>Sat, 17 Sep 2016 07:34:47 +0000</pubDate>
      <dc:creator>mraeclo</dc:creator>
      <guid isPermaLink="false">18194@/two/discussions</guid>
      <description><![CDATA[<p>Hey, how is it going?</p>

<p>Im trying to receive osc on my mobile, using OscP5 library and android mode 4.0-beta2. Codes:</p>

<p>Android app</p>

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

OscP5 oscP5;
NetAddress endereco;

float x = 1.0;
float y = 2.0;
float z = 3.0;

void setup() {
  fullScreen();
  orientation(LANDSCAPE);
  textSize(100);
  oscP5 = new OscP5(this, 9000);
  endereco = new NetAddress("localhost", 10000); // not sure if i even need to import netP5
}

void draw() {
  background(0);
  fill(255);
  text("x = " + x, 20, 200);
  text("y = " + y, 20, 400);
  text("z = " + z, 20, 600);
}

void oscEvent(OscMessage mensagem) {
  // tests if any message is being received at all
  fill(255);
  rect(50, 30, 100, 100);

  if (mensagem.checkAddrPattern("/x")) x = mensagem.get(0).floatValue();
  else if (mensagem.checkAddrPattern("/y")) y = mensagem.get(0).floatValue();
  else if (mensagem.checkAddrPattern("/z")) z = mensagem.get(0).floatValue();
}
</code></pre>

<p>Java code running on my laptop</p>

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

OscP5 osc;
NetAddress endereco;

float x = 0;
float y = 0;
float z = 0;

OscMessage mx = new OscMessage("/x");
OscMessage my = new OscMessage("/y");
OscMessage mz = new OscMessage("/z");

void setup() {
  osc = new OscP5(this, 12000);
  endereco = new NetAddress("192.168.25.2", 9000);

}

void draw() {
}

void keyPressed() {
  if (key == 'q') {
    x += 10.4;
    mx.add(x);
    osc.send(mx, endereco);
    mx.clearArguments();
  } else if (key == 'w') {
    x -= 10.5;
    mx.add(x);
    osc.send(mx, endereco);
    mx.clearArguments();
  } else if (key == 'a') {
    y += 10.4;
    my.add(y);
    osc.send(my, endereco);
    my.clearArguments();
  } else if (key == 's') {
    y -= 10.5;
    my.add(y);
    osc.send(my, endereco);
    my.clearArguments();
  } else if (key == 'z') {
    z += 10.4;
    mz.add(z);
    osc.send(mz, endereco);
    mz.clearArguments();
  } else if (key == 'x') {
    z -= 10.5;
    mz.add(z);
    osc.send(mz, endereco);
    mz.clearArguments();
  }
}
</code></pre>

<p>They are both connected to the same Wifi network, im pretty sure the IP address is correct, but it just does not receive the message sent, the INTERNET permission is checked for the app. What can I be missing?</p>

<p>Using Processing 3.2.1, Android Mode 4.0-beta2, Android 6.0 (API 23), Zenphone 2 Laser Android 5.0.2.</p>

<p>All best
Thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>How can I put microphone value into an array and also filter microphone value</title>
      <link>https://forum.processing.org/two/discussion/25222/how-can-i-put-microphone-value-into-an-array-and-also-filter-microphone-value</link>
      <pubDate>Mon, 27 Nov 2017 04:51:08 +0000</pubDate>
      <dc:creator>nancyjou</dc:creator>
      <guid isPermaLink="false">25222@/two/discussions</guid>
      <description><![CDATA[<p>I want to do a project which is about  when saying something through microphone, and then can draw something (on Processing).</p>

<p>l watch Daniel Shiffman's video "17.9: Sound Visualization: Graphing Amplitude - p5.js",
<a rel="nofollow" href="https://www.youtube.com/watch?v=jEwAMgcCgOA&amp;t=370s">https://youtube.com/watch?v=jEwAMgcCgOA&amp;t=370s</a>,
but what I use is processing and pure data,
I have a question about  how to put those microphone value into an array in Processing, like the tutorial  in the video,
(the way of receive sound from microphone I use is Pure data, and I'm successfully connect pd and Processing), 
but I just don't know how to put those value into an array in processing,
and I guess the value also need to greater than a certain value 
because microphone will also receive value when is not saying.Thank you for your help!﻿</p>

<p>My Pure data and Processing sketch is here
<a rel="nofollow" href="https://github.com/nancyjou/Sound-Visualization">https://github.com/nancyjou/Sound-Visualization</a></p>

<p>and here is only my Processing sketch.</p>

<pre><code>float global1;
float global2;
float adc;
float fiddle;
float colorY;
float alphaX;

import netP5.*;
import oscP5.*;


OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
  size(800, 800);
  background(255);
  frameRate(25);
  colorMode(HSB, 360, 100, 100);
  noStroke();
  /* start oscP5, listening for incoming messages at port 12000 */
  oscP5 = new OscP5(this, 12001);

  myRemoteLocation = new NetAddress("127.0.0.1", 12000);
}

void draw() {

  fiddle = global2;
  colorY= map(global2, 25, 150, 0, 360);
  alphaX= map(global1, 40, 250, 20, 255);
  fill(colorY, 100, 100);
  fill(colorY, 100, fiddle+50, alphaX);
  for (int y=200; y&lt;(height/4)+1; y+=10) {
    ellipse(width/2, random(0, 400), global1, global1);
    println(y);
  }
  adc = global1 + 10;
}


void mousePressed() {
  OscMessage myMessage = new OscMessage("/first");


  myMessage.add(123);
  myMessage.add(12.34);
  myMessage.add("some text");

  oscP5.send(myMessage, myRemoteLocation);
}  

void oscEvent(OscMessage theOscMessage) {

  if (theOscMessage.checkAddrPattern("/first")==true) {



    float firstValue = theOscMessage.get(0).floatValue();
    global1 = firstValue;
  }

  if (theOscMessage.checkAddrPattern("/second")==true) {



    float secondValue = theOscMessage.get(0).floatValue();
    global2 = secondValue;
  }
  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I send Kinect v1 depth data over OscP5 from one computer to another?</title>
      <link>https://forum.processing.org/two/discussion/25184/how-do-i-send-kinect-v1-depth-data-over-oscp5-from-one-computer-to-another</link>
      <pubDate>Fri, 24 Nov 2017 18:45:26 +0000</pubDate>
      <dc:creator>KMat</dc:creator>
      <guid isPermaLink="false">25184@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to send kinect depth from one computer to create a point cloud on another. I have tried sending the data through OSC, but I'm not sure how to declare it on the receiving end as the depth data is sending as an int[].</p>

<p>This is not my entire code for each side, just what matters to my question to avoid confusion:
(hello is what I am trying to send)
This is the sender code.</p>

<pre><code>int[] hello;

void draw() {
  int[] depth = kinect.getRawDepth();

  hello = depth;
}

void OscEvent(OscMessage theOscMessage) {
  //create a message with a unique address pattern
  OscMessage myOutGoingMessage = new OscMessage( playerAddressPattern ); 
  myOutGoingMessage.add(hello); //send the depth data (as an int string)
  osc.send( myOutGoingMessage, destination );  
}
</code></pre>

<p>This is the applicable code from the receiver</p>

<pre><code>int[] hello;//Declare the depth that is coming in from the kinect

int[] depth = hello; // the actual depth data coming from the remote kinect as the variable "hello"

void OscEvent (OscMessage theOscMessage) {
  hello=theOscMessage.get(0).intvalue(); //the value being received is an int[], not an int as i have typed- how do i declare this?
}
</code></pre>

<p>So what might help me here is how would i declare that " hello=theOscMessage.get(0).intvalue();" as an int[]</p>

<p>(MacOS High Sierra, Processing 3.0.1)</p>
]]></description>
   </item>
   <item>
      <title>How can I stream my Kinect feed from one computer to another with OSC?</title>
      <link>https://forum.processing.org/two/discussion/25137/how-can-i-stream-my-kinect-feed-from-one-computer-to-another-with-osc</link>
      <pubDate>Wed, 22 Nov 2017 02:57:18 +0000</pubDate>
      <dc:creator>KMat</dc:creator>
      <guid isPermaLink="false">25137@/two/discussions</guid>
      <description><![CDATA[<p>Hi all, this is my first post here</p>

<p>I am trying to feed my slightly tweaked PointCloud example from Open Kinect v1 library from one computer to another (for example sake, from one processing file to be displayed in another) through the OSC library.</p>

<p>I have attempted myself, but was unable to send the depth data properly (at all) and I am just lost as to where to start and how to even send the data to be displayed.</p>

<p>Here is my Kinect code (without any OSC), can anyone help or guide me through what to send/receive? 
(I'm on Mac OS 10.13 and Processing 3.0.1)</p>

<pre><code>import org.openkinect.freenect.*;
import org.openkinect.processing.*;

// Kinect Library object
Kinect kinect;

// Angle for rotation
float a = 0;

// We'll use a lookup table so that we don't have to repeat the math over and over
float[] depthLookUp = new float[750];

void setup() {
  // Rendering in P3D
  size(800, 600, P3D);
  kinect = new Kinect(this);
  kinect.initDepth();

  // Lookup table for all possible depth values (0 - 2047)
  for (int i = 0; i &lt; depthLookUp.length; i++) {
    depthLookUp[i] = rawDepthToMeters(i);
  }
}

void draw() {

  background(0);

  // Get the raw depth as array of integers
  int[] depth = kinect.getRawDepth();

  // We're just going to calculate and draw every 4th pixel (equivalent of 160x120)
  int skip = 4; //

  // Translate and rotate
  translate(width/2, height/2, 300); //dot distance
  //rotateY(a);

  for (int x = 0; x &lt; kinect.width; x += skip) {
    for (int y = 0; y &lt; kinect.height; y += skip) {
      int offset = x + y*kinect.width;

      // Convert kinect data to world xyz coordinate
      int rawDepth = depth[offset];
      PVector v = depthToWorld(x, y, rawDepth);

      stroke(255, 0, 0);
      pushMatrix();
      float factor = 400; //overall Scale
      translate(v.x*factor, v.y*factor, factor-v.z*factor);
      // Draw a point
      point(0, 0);
      //line(0,0,2,2);
      popMatrix();
    }
  }

  // Rotate
  //a += 0.015f;
}

// These functions come from: <a href="http://graphics.stanford.edu/~mdfisher/Kinect.html" target="_blank" rel="nofollow">http://graphics.stanford.edu/~mdfisher/Kinect.html</a>
float rawDepthToMeters(int depthValue) {
  if (depthValue &lt; 750) {
    return (float)(1.0 / ((double)(depthValue) * -0.0030711016 + 3.3309495161));
  }
  return 0.0f;
}

PVector depthToWorld(int x, int y, int depthValue) {

  final double fx_d = 1.0 / 5.9421434211923247e+02;
  final double fy_d = 1.0 / 5.9104053696870778e+02;
  final double cx_d = 3.3930780975300314e+02;
  final double cy_d = 2.4273913761751615e+02;

  PVector result = new PVector();
  double depth =  rawDepthToMeters(depthValue);
  result.x = (float)((x - cx_d) * depth * fx_d);
  result.y = (float)((y - cy_d) * depth * fy_d);
  result.z = (float)(depth);
  return result;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>My Little LAN Game</title>
      <link>https://forum.processing.org/two/discussion/25144/my-little-lan-game</link>
      <pubDate>Wed, 22 Nov 2017 13:44:00 +0000</pubDate>
      <dc:creator>NewStudent</dc:creator>
      <guid isPermaLink="false">25144@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys recently i created this little game but i am not able to test it completely because i do not have a second computer on the same network i was hoping you guys could test it here is the code:</p>

<p>RPG_Game.pde:</p>

<pre><code>import oscP5.*;
import netP5.*;
import processing.net.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Player player;
Bullet bullet;
Bullet playerBullet;
Player player2;
String playerIP = "";
String myIP;
boolean setup = true;
boolean load = false;
float loadV;
boolean connected = false;
float previous;
float stepPrevious;
boolean error = false;
int x;
int y;
boolean changeStep = false;
int step = 1;
int stepValue = 5;
float previousWay = UP;
boolean walking = false;
int range = 800;
boolean fireable = false;

void setup()
{
  bullet = new Bullet(color(255, 0, 0));
  playerBullet = new Bullet(color(0, 255, 0));
  background(255, 102, 0);
  myIP = Server.ip();
  fullScreen();
  oscP5 = new OscP5(this, 23492);
  textSize(48);
  textAlign(CENTER);
  player = new Player();
  player2 = new Player();
  x = width / 2;
  y = height / 2;
}

void draw()
{
  checkTime();
  background(255, 102, 0);
  set_up();
  load();
  player.show();
  player2.show();
  bullet.show();
  playerBullet.show();
  checkBulletPlayer();
  checkBulletOtherPlayer();
  showScore();
  if (walking) moveCharacter();
  if (bullet.show) bullet.move();
  if (playerBullet.show) playerBullet.move();
  if (!bullet.show) bullet.setDir(previousWay);
  if (!playerBullet.show) playerBullet.setDir(previousWay);
}

void keyPressed()
{
  keySetup();
  if (keyCode == UP || keyCode == DOWN || keyCode == LEFT || keyCode == RIGHT) walking = true;
  if (key == 'f' &amp;&amp; bullet.show == false &amp;&amp; !setup &amp;&amp; !load)
  {
    bullet.fire();
    OscMessage myMessage = new OscMessage("playerBullet");
    myMessage.add(bullet.bx);
    myMessage.add(bullet.by);
    myMessage.add(bullet.bdir);
    oscP5.send(myMessage, myRemoteLocation);
  }
  if (key == 'q' &amp;&amp; !setup &amp;&amp; !load) range = 300;
  if (key == 'w' &amp;&amp; !setup &amp;&amp; !load) range = 500;
  if (key == 'e' &amp;&amp; !setup &amp;&amp; !load) range = 800;
}

void keyReleased()
{
  if (keyCode == UP || keyCode == DOWN || keyCode == LEFT || keyCode == RIGHT) walking = false;
}

public void oscEvent(OscMessage theOscMessage)
{
  if (theOscMessage.checkAddrPattern("playerBullet"))
  {
    playerBullet.bx = theOscMessage.get(0).floatValue();
    playerBullet.by = theOscMessage.get(1).floatValue();
    playerBullet.setDir(theOscMessage.get(2).floatValue());
    playerBullet.fire();
  }
  if (theOscMessage.checkAddrPattern("PlayerCoor"))
  {
    player2.move(theOscMessage.get(0).intValue(), theOscMessage.get(1).intValue(), theOscMessage.get(2).intValue(), theOscMessage.get(3).intValue());
  }
  if (theOscMessage.checkAddrPattern("ConnectReq"))
  {
    myRemoteLocation = new NetAddress(theOscMessage.get(0).stringValue(), 23492);
    OscMessage myMessage = new OscMessage("Connect");
    myMessage.add("yes");
    oscP5.send(myMessage, myRemoteLocation);
  }
  if (theOscMessage.checkAddrPattern("Connect")) connected = true;
}
</code></pre>

<p>Bullet.pde:</p>

<pre><code>class Bullet
{
  float bx;
  float by;
  float bdir;
  boolean show = false;
  float previousX;
  float previousY;
  color clr;

  Bullet(color a)
  {
    bdir = UP;
    clr = a;
  }

  void move()
  {
    if (bdir == UP) by -= 55;
    if (bdir == LEFT) bx -= 55;
    if (bdir == DOWN) by += 55;
    if (bdir == RIGHT) bx += 55;
    if(dist(previousX, previousY, bx, by) &gt; range) show = false;
  }

  void show()
  {
    if (show)
    {
      noStroke();
      fill(clr);
      ellipse(bx + 24, by + 24, 10, 10);
      stroke(0);
      fill(255);
    }
    if(!show) bx = by = -1000;
  }

  void fire()
  {
    bx = player.x;
    by = player.y;
    previousX = bx;
    previousY = by;
    show = true;
  }

  void setDir(float _dir)
  {
    bdir = _dir;
  }
}
</code></pre>

<p>Draw.pde:</p>

<pre><code>void set_up()
{
  if (setup)
  {
    text("Enter Other Players IP:", width / 2, height / 3);
    text("Your IP: " + myIP, width / 2, height / 7);
    fill(0, 188, 255);
    text(playerIP, width / 2, height / 2 + 15);
    fill(255);
    if (error) text("Failed to Connect or Other Machine did not Respond", width / 2, height / 2 + 200);
  }
}

void load()
{
  if (load)
  {
    if (connected) loadV += 5;
    fill(255);
    text("Connecting to: " + playerIP, width / 2, height /  7);
    rectMode(CENTER);
    rect(width / 2, height / 2, 500, 100);
    fill(255, 0, 0);
    rectMode(CORNER);
    rect(width / 2 - 250, height / 2 - 50, loadV, 100);
    if (millis() - previous &gt; 5000 &amp;&amp; loadV &lt; 500)
    {
      loadV = 0;
      setup = true;
      load = false;
      connected = false;
      error = true;
    }
    if (loadV == 500) load = false;
  }
}

void keySetup()
{
  if (setup &amp;&amp; keyCode != CONTROL &amp;&amp; keyCode != SHIFT &amp;&amp; keyCode != 524)
  {
    if (keyCode == BACKSPACE)
    {
      if (playerIP.length() &gt; 0) playerIP = playerIP.substring(0, playerIP.length() - 1);
    } else
    {
      if (keyCode == ENTER)
      {
        error = false;
        if (!playerIP.equals(""))
        {
          myRemoteLocation = new NetAddress(playerIP, 23492);
          setup = false;
          load = true;
          OscMessage myMessage = new OscMessage("ConnectReq");
          myMessage.add(myIP);
          oscP5.send(myMessage, myRemoteLocation);
          previous = millis();
        }
      } else
      {
        playerIP += key;
      }
    }
  }
  if (keyCode == TAB)
  {
    loadV = 0;
    setup = true;
    load = false;
    connected = false;
  }
}

void moveCharacter()
{
  if (!setup &amp;&amp; !load)
  {
    if (keyCode == UP)
    {
      previousWay = UP;
      if (y &gt; 0) y -= stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, UP, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(UP);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == DOWN)
    {
      previousWay = DOWN;
      if (y + 65 &lt; height) y += stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, DOWN, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(DOWN);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == LEFT)
    {
      previousWay = LEFT;
      if (x &gt; 0) x -= stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, LEFT, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(LEFT);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == RIGHT)
    {
      previousWay = RIGHT;
      if (x + 65 &lt; width) x += stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, RIGHT, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(RIGHT);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
  }
}

void checkTime()
{
  if (millis() - stepPrevious &gt;= 200)
  {
    stepPrevious = millis();
    changeStep = true;
  }
}

void checkBulletPlayer()
{
  if (playerBullet.bx &gt; x - 15 &amp;&amp; playerBullet.bx &lt; x + 32 &amp;&amp; playerBullet.by &gt; y - 15 &amp;&amp; playerBullet.by &lt; y + 32)
  {
    player.health -= 20;
    if (player.health &lt;= 0)
    {
      player2.score++;
      player.health = 100;
      player.x = width / 2;
      player.y = height / 2;
      x = width / 2;
      y = height / 2;
    }
  }
}

void checkBulletOtherPlayer()
{
  if (bullet.bx &gt; player2.x - 15 &amp;&amp; bullet.bx &lt; player2.x + 32 &amp;&amp; bullet.by &gt; player2.y - 15 &amp;&amp; bullet.by &lt; player2.y + 32)
  {
    player2.health -= 20;
    if (player2.health &lt;= 0)
    {
      player.score++;
      player2.health = 100;
      player2.x = width / 2;
      player2.y = height / 2;
    }
  }
}

void showScore()
{
  if (!setup &amp;&amp; !load)
  {
    fill(255);
    text((int) player.score, width / 10, height / 10);
    text((int) player2.score, width - 150, height / 10);
  }
}
</code></pre>

<p>Player.pde:</p>

<pre><code>class Player
{
  PImage player = loadImage("character.png");
  PImage sprite = player.get(0, 97, 32, 32);;
  float x;
  float y;
  float dir;
  int foot = 1;
  float health = 100;
  float score = 0;

  Player()
  {
    x = width / 2;
    y = height / 2;
    dir = UP;
  }

  void move(float _x, float _y, float _dir, int _foot)
  {
    x = _x;
    y = _y;
    dir = _dir;
    foot = _foot;
    if(dir == UP &amp;&amp; foot == 1) sprite = player.get(0, 97, 32, 32);
    if(dir == UP  &amp;&amp; foot == 2) sprite = player.get(66, 97, 32, 32);
    if(dir == LEFT &amp;&amp; foot == 1) sprite = player.get(0, 32, 32, 32);
    if(dir == LEFT &amp;&amp; foot == 2) sprite = player.get(66, 32, 32, 32);
    if(dir == DOWN &amp;&amp; foot == 1) sprite = player.get(0, 128, 32, 32);
    if(dir == DOWN &amp;&amp; foot == 2) sprite = player.get(66, 128, 32, 32);
    if(dir == RIGHT &amp;&amp; foot == 1) sprite = player.get(0, 191, 32, 32);
    if(dir == RIGHT &amp;&amp; foot == 2) sprite = player.get(66, 191, 32, 32);
  }

  void show()
  {
    if (!setup &amp;&amp; !load)
    {
      sprite.resize(48, 48);
      image(sprite, x, y);
      fill(map(health, 20, 100, 255, 0), 0, 0);
      ellipse(x, y, 10, 10);
      fill(255);
    }
  }
}
</code></pre>

<p>I am open to any suggestions and opinions.
Thanks</p>

<p>and here is the character.png file:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/508/QEL8KBAM7B1C.png" alt="character" title="character" /></p>
]]></description>
   </item>
   <item>
      <title>How to display accents ?</title>
      <link>https://forum.processing.org/two/discussion/23982/how-to-display-accents</link>
      <pubDate>Thu, 31 Aug 2017 09:46:40 +0000</pubDate>
      <dc:creator>Marceau</dc:creator>
      <guid isPermaLink="false">23982@/two/discussions</guid>
      <description><![CDATA[<p>Hi ! I have created a small soft to chat on a local network and every time someone type an accented letter, it doesn't display and I have this error :</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/907/YY411UISFZ42.PNG" alt="example" title="example" /></p>

<p>As my soft is for french users, we do need those letters : é è ç à But I cannot find a way to  display them. My text messages are created with Controlp5, do I need to change a parameter on the character encoding ?</p>

<p>If you have the solution, please help me !</p>

<p>Have a good day,</p>
]]></description>
   </item>
   <item>
      <title>Crash (VM Failed) when OSC message is received</title>
      <link>https://forum.processing.org/two/discussion/23172/crash-vm-failed-when-osc-message-is-received</link>
      <pubDate>Thu, 22 Jun 2017 22:26:04 +0000</pubDate>
      <dc:creator>TKyubi</dc:creator>
      <guid isPermaLink="false">23172@/two/discussions</guid>
      <description><![CDATA[<pre><code>        import oscP5.*;

        ArrayList&lt;KochLine&gt; lines;
        ArrayList&lt;SierpTri&gt; triangles;

        OscP5 oscP5;

        int cellsize = 2; 
        int cols, rows; 

        int rect;
        int cycle;
        int tri;

        void setup() {
          size(600, 692, P3D);
          background(255);

          cols = width/cellsize;              // Calculate # of columns
          rows = height/cellsize;             // Calculate # of rows


          // inizializza colori
          rect = 65;
          cycle = 261;
          tri = 1046;

          oscP5 = new OscP5(this, 8001); // apre udp sulla porta 12000
          // TEST PER LE VARIABILI IN ENTRATA
          oscP5.plug(this, "testG", "/gain"); // test gain
          oscP5.plug(this, "testF1", "/freq1"); // test frequenza primo oscillatore
          oscP5.plug(this, "testF2", "/freq2"); // test frequenza secondo oscillatore
          oscP5.plug(this, "testF3", "/freq3"); // test frequenza terzo oscillatore

          //funzione di inizializzazione per la figura frattale
          init();

          // display della figura iniziale
          for (KochLine l : lines) { 
            l.display();
          }
          for (SierpTri t : triangles) { 
            t.display();
          }

          //carica l'array pixels
          loadPixels();
        }

        void draw() {

          //background variato via OSC
          background(tri, rect, cycle);

          //3D EXPLOSION (Ripresa dall'esempio)

          for (int i = 0; i &lt; cols; i++ ) {
            // Begin loop for rows
            for (int j = 0; j &lt; rows; j++ ) {
              int x = i*cellsize + cellsize/2; // x position
              int y = j*cellsize + cellsize/2; // y position
              int loc = x + y*width;           // Pixel array location
              color c = pixels[loc];       // Grab the color
              float z = map(int(random(40, 140)), 0, 255, 0, mouseX);
              // Translate to the location, set fill and stroke, and draw the rect
              pushMatrix();
              translate(x, y, z); 
              fill(c);
              noStroke();
              rectMode(CENTER);
              rect(0, 0, cellsize, cellsize);
              popMatrix();
            }
          }
        }

        // GENERAZIONE FRATTALE

        public void init() { // funzione per inizializzare il triangolo base del frattale
          lines = new ArrayList&lt;KochLine&gt;();  // inizializza l'array per il KochSnowflake
          triangles = new ArrayList&lt;SierpTri&gt;(); // inizializza l'array per il SierpinskiTriangle

          // inizializza 3 vettori che rappresentano i 3 punti del triangolo iniziale
          PVector a   = new PVector(0, 173);
          PVector b   = new PVector(width, 173);
          PVector c   = new PVector(width/2, 173+width*cos(radians(30)));

          //vengono aggiunte 3 linee all'Array per Koch
          lines.add(new KochLine(a, b));
          lines.add(new KochLine(b, c));
          lines.add(new KochLine(c, a)); 

          //viene aggiunto un triangolo all'Array per Sierpinski
          triangles.add(new SierpTri(a, b, c));
        }

        public void generate() { // funzione ricorsiva per la generazione del frattale

          //dichiara un secondo Array per entrambi i frattali che funge da elemento di ricorsione

          ArrayList recSierp = new ArrayList&lt;SierpTri&gt;();
          ArrayList recKoch = new ArrayList&lt;KochLine&gt;();

          /** Per ogni Triangolo presente all'interno dell'Array base inizializza 6 vettori
           che rappresentano i 3 vertici del triangolo e i 3 mid-point dei lati. Aggiunge
           al secondo Array tre triangoli secondo la regola dei triangoli di Sierpinski
           */
          for (SierpTri t : triangles) {

            PVector a = t.SierpA();
            PVector b = t.SierpB();
            PVector c = t.SierpC();
            PVector d = t.SierpD();
            PVector e = t.SierpE();
            PVector f = t.SierpF();

            recSierp.add(new SierpTri(a, d, e));
            recSierp.add(new SierpTri(d, b, f));
            recSierp.add(new SierpTri(e, f, c));
          }

          /** Per ogni linea presente all'interno dell'Array base inizializza 5 vettori
           che rappresentano i 5 nodi della linea generata dalla regola di Koch. Aggiunge
           al secondo Array per Koch le 4 linee generate dalla regola stessa e al secondo Array 
           per Sierpinski un triangolo generato tramite i 3 nodi centrali della regola di Koch
           */
          for (KochLine l : lines) { // funzione ricorsiva SnowFlake

            PVector a = l.kochA();                 
            PVector b = l.kochB();
            PVector c = l.kochC();
            PVector d = l.kochD();
            PVector e = l.kochE();

            recKoch.add(new KochLine(a, b));
            recKoch.add(new KochLine(b, c));
            recKoch.add(new KochLine(c, d));
            recKoch.add(new KochLine(d, e));

            recSierp.add(new SierpTri(b, c, d)); // aggiunge ogni nuovo triangolo generato al Sierpinski
          }

          // Ricorsione: sostituisce l'array originale con l'array ricorsivo
          lines = recKoch;
          triangles = recSierp;
        }

        // TEST PER I VALORI OSC

        public void testG(float theF) { // test per il gain, chiede un float

          gain2 = map(theF, -76.6, 17.6, 37, 600); // assegna al secondo valore di testGain un valore riscalato

          int gain = test1(theF); 
          // richiama una funzione di test

          /** funzione di switch che assegna ad ogni caso (generato dalla funzione di test
           in base al range dei valori) un livello di iterazione del frattale. Per ogni caso
           la funzione di generazione viene iterata una volta in più.
           Questa è la parte che genera il crash quando riceve il messaggio OSC. Quello che
           non capisco è come mai se generata con Keypressed la stessa funzione non da problemi
           mentre in questo modo genera un errore.
           */
          switch (gain) {
          case 0 : 
            background(255);
            init();
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 1 :
            background(255);
            init();
            generate();
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 2 :
            background(255);
            init();
            for (int i=0; i&lt;2; i++) { 
              generate();
            }
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 3 :
            background(255);
            init();
            for (int i=0; i&lt;3; i++) { 
              generate();
            }
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 4 :
            background(255);
            init();
            for (int i=0; i&lt;4; i++) { 
              generate();
            }
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 5 :
            background(255);
            init();
            for (int i=0; i&lt;5; i++) { 
              generate();
            }
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 6 :
            background(255);
            init();
            for (int i=0; i&lt;6; i++) { 
              generate();
            }
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          case 7 :
            background(255);
            init();
            for (int i=0; i&lt;7; i++) { 
              generate();
            }
            for (KochLine l : lines) { 
              l.display();
            }
            for (SierpTri t : triangles) { 
              t.display();
            }
            loadPixels();
            break;
          }
        }

        public void testF1(int theA) { // test primo oscillatore
          cycle = int((theA*255)/726); // riscalamento della frequenza tra 0 e 255
        }

        public void testF2(int theB) { // test secondo oscillatore
          rect = int((theB*255)/181);  // riscalamento della frequenza tra 0 e 255
        }

        public void testF3(int theC) { // test terzo oscillatore
          tri = int((theC*255)/2905);  // riscalamento della frequenza tra 0 e 255
        }

        void oscEvent(OscMessage theOscMessage) { // adress di eventuali messaggi non pluggati

          if (theOscMessage.isPlugged()==false) {
            println("### received an osc message.");
            println("### addrpattern\t"+theOscMessage.addrPattern());
            println("### typetag\t"+theOscMessage.typetag());
          }
        }

        // FUNZIONI

        /** funzione di test che genera 7 casi in base al range del valore ricevuto tramite OSC */

        int test1(float a) { 
          if (a &lt; -37) {
            return 0;
          }
          if (a &gt;= -37 &amp;&amp; a &lt; -16) {
            return 1;
          }
          if (a &gt;= -16 &amp;&amp; a &lt; -12) {
            return 2;
          }
          if (a &gt;= -12 &amp;&amp; a &lt; -8) {
            return 3;
          }
          if (a &gt;= -8 &amp;&amp; a &lt; -6) {
            return 4;
          }
          if (a &gt;= -6 &amp;&amp; a &lt; -4) {
            return 5;
          }
          if (a &gt;= -4 &amp;&amp; a &lt; -2) {
            return 6;
          }
          if (a &gt;= -2 &amp;&amp; a &lt; -0) {
            return 7;
          }
          return 7;
        }

        // keyPressed di test
        void keyPressed() {
          background(255);
          init();
          generate();
          for (KochLine l : lines) { 
            l.display();
          }
          for (SierpTri t : triangles) { 
            t.display();
          }
          loadPixels();
        }
</code></pre>

<p>THE QUESTION: 
The problem is that when I send via Max/Msp some test values for the "gain test" the patch instantly crashes, I tried cutting of most of the combinations of code lines trying to find the reason, but I couldn't manage to find any explanation for this so I'm here hoping someone can actually explain me what I'm doing wrong.<br />
Thank you very much for your help!</p>
]]></description>
   </item>
   <item>
      <title>Dynamically controlled particle system with Toxiclibs</title>
      <link>https://forum.processing.org/two/discussion/22940/dynamically-controlled-particle-system-with-toxiclibs</link>
      <pubDate>Mon, 05 Jun 2017 14:56:31 +0000</pubDate>
      <dc:creator>narner</dc:creator>
      <guid isPermaLink="false">22940@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm working on modifying the <a rel="nofollow" href="https://github.com/postspectacular/toxiclibs/blob/master/examples/physics/Attraction2D/Attraction2D.pde">Attraction2D example</a> from the <a rel="nofollow" href="http://toxiclibs.org/">Toxiclibs library</a> to be controlled by gestures from a Leap Motion sensor, as opposed to the mouse in the example.</p>

<p>I'm doing all my gesture recognition in an Open Frameworks app, and sending that over OSC.</p>

<p>When a "Gesture 0" event occurs, I call the method below to remove the <code>gestureAttractor</code> from the <code>physics</code> object:</p>

<pre><code>void resetAttraction() {
  if (gestureAttractor != null){
      physics.removeBehavior(gestureAttractor);
      println("ATTRACTOR NULL");
     } else {
        println("not null");
     }
}
</code></pre>

<p>If a "Gesture 1" event occurs, I call this method to create a new <code>gestureAttractor</code>, and add it back to the <code>physics</code> object:</p>

<p>void addAttraction(){
         if (gestureAttractor == null) {
             println("ATTRACTOR NULL");
             position1.set(340, 191);
             gestureAttractor = new AttractionBehavior2D(position1, 250, 0.9f);
             physics.addBehavior(gestureAttractor);
         } else {
           println("not null");
         }
    }</p>

<p>What seems to happen consistently is whenever the gesture state changes, I'll get a "Concurrent Modification Exception" crash at  <code>physics.update();</code> in the <code>draw</code> method.</p>

<p>I'm sure it has something to do with the way the lifecycle of these objects are handled, but I haven't been able to determine anything yet - anyone have any ideas?</p>

<p>Below is the entirety of the sketch:</p>

<pre><code>import toxi.geom.*;
import toxi.physics2d.*;
import toxi.physics2d.behaviors.*;

import oscP5.*;
import netP5.*;

OscP5 oscP5;

int NUM_PARTICLES = 750;

VerletPhysics2D physics;
//AttractionBehavior2D mouseAttractor;
AttractionBehavior2D gestureAttractor;


//Vec2D mousePos;
Vec2D position1;


boolean isGestureAttractorAdded;

void setup() {
  size(680, 382,P3D);
  // setup physics with 10% drag
  physics = new VerletPhysics2D();
  physics.setDrag(0.05f);
  physics.setWorldBounds(new Rect(0, 0, width, height));
  // the NEW way to add gravity to the simulation, using behaviors
  physics.addBehavior(new GravityBehavior2D(new Vec2D(0, 0.15f)));

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

  position1 = new Vec2D(340, 191);

  addAttraction();

  //gestureAttractor = new AttractionBehavior2D(position1, 250, 0.9f);
  //physics.addBehavior(gestureAttractor);
}

void addParticle() {
  VerletParticle2D p = new VerletParticle2D(Vec2D.randomVector().scale(5).addSelf(width / 2, 0));
  physics.addParticle(p);
  // add a negative attraction force field around the new particle
  physics.addBehavior(new AttractionBehavior2D(p, 20, -1.2f, 0.01f));
}

void draw() {
  background(255,0,0);
  noStroke();
  fill(255);
  if (physics.particles.size() &lt; NUM_PARTICLES) {
    addParticle();
  }
  physics.update();
  for (VerletParticle2D p : physics.particles) {
    ellipse(p.x, p.y, 5, 5);
  }
}

void mousePressed() {
  //position1 = new Vec2D(mouseX, mouseY);
   //create a new positive attraction force field around the mouse position (radius=250px)
  //gestureAttractor = new AttractionBehavior2D(position1, 250, 0.9f);
  //physics.addBehavior(gestureAttractor);

  //println(physics.behaviors);
}

void mouseDragged() {
  // update mouse attraction focal point
  //position1.set(mouseX, mouseY);
}

void mouseReleased() {
  // remove the mouse attraction when button has been released
  //physics.removeBehavior(gestureAttractor);
}


///// OSC RECEIVING

void oscEvent(OscMessage theOscMessage) {
  /* check if theOscMessage has the address pattern we are looking for. */

  if (theOscMessage.checkAddrPattern("/gesture_classification") == true)  {
    /* check if the typetag is the right one. */
    if(theOscMessage.checkTypetag("i")) {
      /* parse theOscMessage and extract the values from the osc message arguments. */
      int gestureClassLabel = theOscMessage.get(0).intValue();  
      println(" Gesture is: ", gestureClassLabel);

      if (gestureClassLabel == 0){   
        resetAttraction();
      } else if (gestureClassLabel == 1) {       
        addAttraction();
      } else if (gestureClassLabel == 2) {
          //physics.removeBehavior(gestureAttractor);
      } 
    }  
  } 

}

//////METHODS FOR SETTING POSITION / REMOVAL OF ATTRACTORS...

void resetAttraction() {
  if (gestureAttractor != null){
      physics.removeBehavior(gestureAttractor);
      println("ATTRACTOR NULL");
     } else {
        println("not null");
     }
 }

void addAttraction(){
     if (gestureAttractor == null) {
         println("ATTRACTOR NULL");
         position1.set(340, 191);
         gestureAttractor = new AttractionBehavior2D(position1, 250, 0.9f);
         physics.addBehavior(gestureAttractor);
     } else {
       println("not null");
     }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>oscP5 Message Recieved trigger function</title>
      <link>https://forum.processing.org/two/discussion/21129/oscp5-message-recieved-trigger-function</link>
      <pubDate>Fri, 03 Mar 2017 15:46:17 +0000</pubDate>
      <dc:creator>EtJA</dc:creator>
      <guid isPermaLink="false">21129@/two/discussions</guid>
      <description><![CDATA[<p>Hi there i´m sending a message from one to another sketch and i want the receiving sketch to trigger an function everytime it receives a message.</p>

<p>could i call a void oscEvent that only trigger when a new message comes in?
or is it easier to make a kind of if statement within draw?</p>
]]></description>
   </item>
   <item>
      <title>OSC multiple clients</title>
      <link>https://forum.processing.org/two/discussion/20836/osc-multiple-clients</link>
      <pubDate>Fri, 17 Feb 2017 00:16:13 +0000</pubDate>
      <dc:creator>G_Rocks</dc:creator>
      <guid isPermaLink="false">20836@/two/discussions</guid>
      <description><![CDATA[<p>HI,</p>

<p>I'm making a game with 3 computers (1 server en two clients). And when I use the following code i will get an error. And when I remove the float or the int, that one function will work, but when they are both active, it gives an error. I believe it has something to do with the string position, but I have no idea.</p>

<p>the error:
ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage
 to a method in your program. please check your code for any 
possible errors that might occur in the method where incoming
 OscMessages are parsed e.g. check for casting errors, possible
 nullpointers, array overflows ... .
method in charge : oscEvent  java.lang.reflect.InvocationTargetException</p>

<p>My code:</p>

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

OscP5 oscP5;
NetAddress pilot, gunner;

int shoot;
float deg;

void setup() {
  size (1000, 1000);

  oscP5 = new OscP5(this,12002);
  pilot = new NetAddress("localhost",12001);
  gunner = new NetAddress("localhost",12000);
}

void oscEvent(OscMessage theOscMessage){
  //print("Received an osc message");
  String msgType =  theOscMessage.addrPattern();

  float degValue = theOscMessage.get(0).floatValue();

  if(msgType.equals("/shoot"))
  {
    int shootValue = theOscMessage.get(0).intValue(); 
    shoot = shootValue; 
  }

  if(msgType.equals("/deg"))
  {

   deg = degValue; 
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Concurrent Modification Exception trying to add objects on OSC event</title>
      <link>https://forum.processing.org/two/discussion/11634/concurrent-modification-exception-trying-to-add-objects-on-osc-event</link>
      <pubDate>Thu, 09 Jul 2015 19:06:15 +0000</pubDate>
      <dc:creator>prismspecs</dc:creator>
      <guid isPermaLink="false">11634@/two/discussions</guid>
      <description><![CDATA[<p>I'm designing this generative visuals system that uses OSC data from a musician to produce these kind of abstract "asteroids" in real time. I'm running into this Concurrent Modification Exception which I'm assuming has to do with the fact that the OSC Event is another thread (or something? happening alongside my draw loop) and so maybe when iterating through my asteroid objects an asteroid is added, causing an error. I thought the synchronize trick would work, no such luck. Any help is appreciated!</p>

<p>Note: Just tried it with also protecting/removing the .remove() portion of the code, same error (although perhaps less frequent?)</p>

<pre><code>// OSC STUFF
volatile boolean isBusy = false;

/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
    if (theOscMessage.addrPattern().equals("/peter/rhythm")) {
        if (!isBusy)
        asteroids.add(new Asteroid(0));
    }
}


// DRAW STUFF
void wormhole() {
    pg.background(bgColor, bgTrans);

    // there are stars from last scene, animate those suckers
    for (Star s : stars) {
        s.display();
    }

    isBusy = true;
    // update, display asteroids
    synchronized (asteroids) {
        for (Asteroid a : asteroids) {
            a.update();
            a.display();
        }
    }
    isBusy = false;
}


// DELETING ASTEROIDS STUFF FROM DRAW() maybe this needs synch too?
  // destroy anything that is offscreen
  for (int i = asteroids.size() - 1; i &gt;= 0; i--) {
    Asteroid a = asteroids.get(i);
    if (a.dead()) {
      asteroids.remove(i);
    }
  }


// ASTEROID class
float asteroidTrans = 120;  // global transparency modifier for asteroids

class Asteroid {
  PVector pos;
  color cFill, cStroke;

  float r;  // rotation
  float rotateSpeed = .005;

  float sw = 2; //strokeWeight

  float ld = 5; // line distance

  float p;  // phase
  float pRate = .3;  // phase rate
  float pAdjust;  // use this number to add to s [or any other value)

  float speed = 1;
  float s = 1;  // starting size
  float growthRate = .05; // growth per frame

  int type = 0; // type of asteroid

  // properties
  // phase pulsates size of asteroid
  // corona gives it a circular outline
  // death color makes it change space bg color on impact w screen

  // behaviors
  boolean ROTATE, PHASE;
  // shape types
  boolean BOX, SPHERE, LINES, CORONA, TRI;
  // on death/ birth
  boolean DEATH_COLOR;
  // extras

  Asteroid(int type) {
    this.type = type;

    pos = new PVector(random(width), random(height), far);

    // randomize its initial rotation
    r = random(TWO_PI);

    switch (type) {
    case 0: // black cube
      cFill = color(0);
      cStroke = color(255);
      ROTATE = true;
      BOX = true;
      break;
    case 1: // colorful, pulsating circles, on death make bg that color
      sw = 0;

      // random colors
      cFill = color(random(255), random(255), random(255), random(20, 255));
      cStroke = cFill;

      ROTATE = true;
      PHASE = true;
      SPHERE = true;
      CORONA = true;
      DEATH_COLOR = true;
      break;
    case 2: // line creature..?
      LINES = true;
      PHASE = true;
      //CORONA = true;
      //pRate = .001;
      ld = 20;
      sw = 1;
      cStroke = color(255);
      break;
    case 3: // triangles
      TRI = true;
      ROTATE = true;
      PHASE = true;
      cFill = color(255);
      rotateSpeed = .01;
      break;

    }

  }

  void update() {
    // all asteroid types move towards you (and grow)
    pos.z += speed * hyperspaceModifier;
    s += growthRate * hyperspaceModifier;

    // rotating asteroids
    if (ROTATE) {
      r += rotateSpeed * hyperspaceModifier;
    }

    if (PHASE) {
      p += pRate; // inc phase
      pAdjust += sin(p) * .5;
    }
  }

  void display() {

    // TRIANGLE
    if (TRI) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      if (ROTATE) {
        pg.rotateZ(r);
      }
      pg.rotateX(3 * PI / 2);
      pg.stroke(255);
      if (PHASE) {
        float r = map(sin(p), -1, 1, 0, 255);
        float g = map(cos(p), -1, 1, 0, 255);
        float b = map(tan(p), -1, 1, 0, 255);
        cFill = color(r, g, b);
      }
      pg.fill(cFill);

      pg.beginShape(TRIANGLES);
      pg.vertex(-12, -12, -12);
      pg.vertex( 12, -12, -12);
      pg.vertex(   0,    0,  12);

      pg.vertex( 12, -12, -12);
      pg.vertex( 12,  12, -12);
      pg.vertex(   0,    0,  12);

      pg.vertex( 12, 12, -12);
      pg.vertex(-12, 12, -12);
      pg.vertex(   0,   0,  12);

      pg.vertex(-12,  12, -12);
      pg.vertex(-12, -12, -12);
      pg.vertex(   0,    0,  12);
      pg.endShape();

      //pg.triangle(0, -10, 8, 10, -8, 10);
      pg.popMatrix();
    }

    // LINE
    if (LINES) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      pg.stroke(cStroke);
      pg.strokeWeight(sw);

      int segments = 8;

      PVector[] linePV = new PVector[segments];
      linePV[0] = new PVector(0, 0, 0);
      for (int i = 1; i &lt; segments; i++) {
        float x = cos( p + (segments / TWO_PI * i)) * ld * (i * .1);
        float y = sin( p + (segments / TWO_PI * i)) * ld * (i * .1);
        float z = linePV[i - 1].z - ld;

        linePV[i] = new PVector(x, y, z);

        pg.line(linePV[i - 1].x, linePV[i - 1].y, linePV[i - 1].z, x, y, z);
      }

      pg.popMatrix();
    }

    // CORONA
    if (CORONA) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      pg.stroke(cStroke, asteroidTrans);
      pg.noFill();
      pg.strokeWeight(sw + 4 + pAdjust);
      pg.ellipse(0, 0, (s + pAdjust) * 1.3, (s + pAdjust) * 1.3);
      pg.popMatrix();
    }

    // BOX
    if (BOX) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      if (ROTATE) rotate();
      pg.fill(cFill, asteroidTrans);
      pg.strokeWeight(sw);
      pg.stroke(cStroke);
      pg.box(s + pAdjust);
      pg.popMatrix();
    }

    // SPHERE
    if (SPHERE) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      pg.strokeWeight(sw);
      pg.stroke(cStroke);
      pg.fill(cFill, asteroidTrans);
      //pg.sphereDetail(7);
      //if (ROTATE) rotate();
      //pg.sphere(s + pAdjust);
      pg.ellipse(0, 0, s + pAdjust, s + pAdjust);
      pg.popMatrix();
    }
  }

  boolean dead() {
    // if object gets totally offscreen...
    if (pos.z &gt; 1000) {
      // DEATH COLOR asteroids change bg color on impact
      if (DEATH_COLOR) {
        bgColor = cFill;
      }
      return true;  // destroy object
    } else {
      return false;
    }
  }

  // if this asteroid is a rotater
  void rotate() {
    pg.rotateY(r);
    pg.rotateZ(r * 2);
    pg.rotateX(r * 3);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>OSC Reciever Issue</title>
      <link>https://forum.processing.org/two/discussion/20250/osc-reciever-issue</link>
      <pubDate>Sat, 14 Jan 2017 00:44:47 +0000</pubDate>
      <dc:creator>omercho</dc:creator>
      <guid isPermaLink="false">20250@/two/discussions</guid>
      <description><![CDATA[<p>Hello processing world! (this is my first post here)</p>

<p>I have a problem with the OSC reciever of oscP5 library. I can see the messges I'm receiving from SuperCollider. I can set variables in processig. Also I can send back the recieved messages. But unfortunetly I can not draw anything with that messages. 
I tried 4 different methods and still nothing. Please some help!</p>

<p>Thanks a lot..!</p>

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

    OscP5 oscP5;
    NetAddress myRemoteLocation;
    NetAddress superCollider;

    void setup() {
      size(700, 500);
      background(0);

      oscP5 = new OscP5(this, 12000);
      myRemoteLocation = new NetAddress("127.0.0.2", 12000);
      superCollider = new NetAddress("192.168.1.4", 57120);

      oscP5.plug(this, "test3", "/test3");
    }

    void draw() {
    }

    void mousePressed() {

      fill(250);
      rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
    }

    void oscEvent(OscMessage theOscMessage) {
      /* check if theOscMessage has the address pattern we are looking for. */
      if (theOscMessage.checkAddrPattern("/test")==true) {
        /* check if the typetag is the right one. */
        if (theOscMessage.checkTypetag("ii")) {

          /* parse theOscMessage and extract the values from the osc message arguments. */
          int val01 = theOscMessage.get(0).intValue();  // get the first osc argument
          int val02 = theOscMessage.get(1).intValue(); // get the second osc argument


          fill(250);
          rect(random(0, width), random(0, height), random(50, 200), random(50, 200));

          OscMessage myMessage = new OscMessage("/testBack");
          myMessage.add(val01); /* add an int to the osc message */
          myMessage.add(val02);
          oscP5.send(myMessage, superCollider);
        }
      }

      /* check if theOscMessage has the address pattern we are looking for. */
      String addr = theOscMessage.addrPattern();
      int val0 = theOscMessage.get(0).intValue(); 
      if (addr.equals("/test2")) {
        fill(250);
        rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
      }
      if (theOscMessage.checkAddrPattern("/test4")==true) {
        /* parse theOscMessage and extract the values from the osc message arguments. */
        int val01 = theOscMessage.get(0).intValue();  // get the first osc argument
        int val02 = theOscMessage.get(1).intValue(); // get the second osc argument
        fill(150);
        ellipse(20, 20, 50, 50);


        OscMessage myMessage = new OscMessage("/testBack4");
        myMessage.add(val01); /* add an int to the osc message */
        myMessage.add(val02);
        oscP5.send(myMessage, superCollider);
      }
    }

    public void test3(int theA, int theB) {
      println("### plug event method. received a message /test3.");
      println(" 2 ints received: " +theA+ ", " +theB);  

      fill(250);
      rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>oscP5 parse to float trouble</title>
      <link>https://forum.processing.org/two/discussion/19386/oscp5-parse-to-float-trouble</link>
      <pubDate>Tue, 29 Nov 2016 10:13:11 +0000</pubDate>
      <dc:creator>marco_girardini</dc:creator>
      <guid isPermaLink="false">19386@/two/discussions</guid>
      <description><![CDATA[<p>hello everyone! I'm trying to get a data (named "media") from my Raspberry PI to my Android phone using processing so I' ve decided to use oscP5 lybrary. I've successfully connected them (the android sketch receives that data) but I just can't manage to parse it into float format from the oscMessage format. Could someone explain me how should I do? This is the sketch. thank you</p>

<p>import g4p_controls.*;
import processing.sound.*;
import oscP5.*;
import netP5.*;</p>

<p>int screenX=900;
int screenY=600;</p>

<p>int letture,xInterfaccia=0,y,limit;
float somma,media,oldMedia=500;
boolean mediaAvailable;</p>

<p>OscP5 osc;
NetAddress addr;
SoundFile file;</p>

<p>void setup(){
  size(900,600);
  background(150,0,0);
  while(y&lt;screenY){
    stroke(0);
    line(0,y,screenX,y);
    fill(255);
    textSize(11);
    text(int(1000-map(y,0,screenY,0,1000)),screenX-40,y);
    y=y+50;
  }
  y=0;
  osc = new OscP5(this, 12345);
  addr = new NetAddress("192.168.1.24",12345);
 // file = new SoundFile(this, "alarm.mp3");
}</p>

<p>void draw(){   <strong>//I've posted even the draw but it doesn't matte, it works fine. i get some troubles with oscEvent()</strong></p>

<p>if(xInterfaccia&gt;screenX-35){                                   //ripristino schermata una volta terminata
        saveFrame("SQM-##.png");
        background(150,0,0);
        while(y&lt;screenY){
           stroke(0);
           line(0,y,screenX,y);
           fill(255);
           textSize(11);
           text(int(1000-map(y,0,screenY,0,1000)),screenX-40,y);
           y=y+50;
       }
       xInterfaccia=0;
       y=0;
  }</p>

<pre><code> if(mediaAvailable) {
    println(media);
    fill(0);                                      //disegna grafico
    if(oldMedia&gt;media){
      triangle(xInterfaccia,screenY-oldMedia,xInterfaccia,screenY-media,xInterfaccia+10,screenY-media);
      rect(xInterfaccia,screenY,10,-int(media));
    }
    else if(oldMedia&lt;media){
      triangle(xInterfaccia,screenY-oldMedia,xInterfaccia+10,screenY-oldMedia,xInterfaccia+10,screenY-media);
      rect(xInterfaccia,screenY,10,-int(oldMedia));
    }
    else
      rect(xInterfaccia,screenY,10,-int(oldMedia));

    oldMedia=media;
    fill(255);
    rotate(-PI/2);
    translate(-screenY,xInterfaccia+9);
    fill(255);
    textSize(9);
    text(hour()+":"+minute()+"   "+nf(map(media,0,screenY,0,1000),3,2),0,0);
    xInterfaccia+=10;
    rotate(PI/2);
    translate(screenY,-xInterfaccia-9);
    if(media&gt;screenY-limit){
      file.play();
    }
    mediaAvailable=false;
</code></pre>

<p>}
}</p>

<p>void oscEvent(OscMessage theMessage) {
 mediaAvailable=true;
}</p>
]]></description>
   </item>
   <item>
      <title>touchOsc and Processing 3.2.3?</title>
      <link>https://forum.processing.org/two/discussion/19283/touchosc-and-processing-3-2-3</link>
      <pubDate>Thu, 24 Nov 2016 21:41:43 +0000</pubDate>
      <dc:creator>slow_izzm</dc:creator>
      <guid isPermaLink="false">19283@/two/discussions</guid>
      <description><![CDATA[<p>What do I need to do in order to get touchOsc working with processing 3.2.3? I see that my sketch is listening to port 31415, I have my touchOsc app sending out to port 31415, but I am getting nothing. Processing code below ... thank you.</p>

<p>*Edit - I'm not having any luck in 2.2.1 either.</p>

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

OscP5 oscP5;

float redFade;

void setup() {
  size(480, 360);
  oscP5 = new OscP5(this, 31415);
}

void draw() {
  background(33);

  //red rect
  rectMode(CENTER);
  pushStyle();
  fill(0);
  stroke(42, 42, 42);
  rect(width/2, height/2, 255, 67);
  fill(255, 15, 15);
  rect(width/2, height/2, -redFade, 67);
  popStyle();

}

void oscEvent(OscMessage theOscMessage) {
  String addr = theOscMessage.addrPattern();
  float val = theOscMessage.get(0).floatValue();

  if (addr.equals("/1/redFade")) { redFade = val;}

  print("### received an osc message.");
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Init new objec from Class via OSCp5</title>
      <link>https://forum.processing.org/two/discussion/18776/init-new-objec-from-class-via-oscp5</link>
      <pubDate>Sat, 29 Oct 2016 04:39:17 +0000</pubDate>
      <dc:creator>miquel_parera</dc:creator>
      <guid isPermaLink="false">18776@/two/discussions</guid>
      <description><![CDATA[<p>Hello.</p>

<p>Some time ago I am trying to create and destroy objects of classes and modify some of its parameters via OSC messages. I tried it with ArrayLists with controlEvents GUI and it works, but there is no way with OSC.</p>

<p>I made this supermegasimple code if someone wants to implement a solution inside:</p>

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

OscP5 oscP5;
NetAddress myRemoteLocation;

circle obj1;

void setup()
{
  size(800,600);
  oscP5 = new OscP5(this,12000);
}

void draw()
{
  background(0);
}

void oscEvent(final OscMessage theOscMessage) {
    if(theOscMessage.checkAddrPattern("/circle")==true) {
     if(theOscMessage.checkTypetag("i")) { 
       // /circle name create a circle with this name
       // /circle name erase destroy this circle
     }
    }
}

class circle {
  circle(){}
  void display(){
    ellipse(10,10,50,50);
  }
}
</code></pre>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Problem stablishing communication via OSC between mac and ubuntu</title>
      <link>https://forum.processing.org/two/discussion/18535/problem-stablishing-communication-via-osc-between-mac-and-ubuntu</link>
      <pubDate>Thu, 13 Oct 2016 19:52:38 +0000</pubDate>
      <dc:creator>rojele</dc:creator>
      <guid isPermaLink="false">18535@/two/discussions</guid>
      <description><![CDATA[<p>Hi, all,</p>

<p>I’m trying to communicate with oscp5 via ethernet, with a simple example, between mac and ubuntu.
As mac is receiving, not the same with ubuntu. I’m pretty new with ubuntu but, first of all i’ve set the ip for the ubuntu:</p>

<pre><code>          sudo ifconfig enp8s0 192.168.1.6 netmask 255.255.255.0
</code></pre>

<p>(As enp8s0 is the ethernet id )</p>

<p>My ip on the mac is 192.168.1.3</p>

<p>And here are the codes:</p>

<p>In ubuntu:</p>

<pre><code>  /**
   * oscP5sendreceive by andreas schlegel
   * example shows how to send and receive osc messages.
   * oscP5 website at <a href="http://www.sojamo.de/oscP5" target="_blank" rel="nofollow">http://www.sojamo.de/oscP5</a>
   */

  import oscP5.*;
  import netP5.*;

  OscP5 oscP5;
  NetAddress myRemoteLocation;
  String ipMac="192.168.1.3";
  String ipUb="192.168.1.5";
  int macPort = 12000;
  int ubPort=57120;

  void setup() {
    size(400,400);
    frameRate(25);
    oscP5 = new OscP5(this,macPort);
    myRemoteLocation = new NetAddress(ipMac,ubPort);
  }


  void draw() {
    background(0);  
  }

  void mousePressed() {
    OscMessage myMessage = new OscMessage("/test");
    myMessage.add(123);
    oscP5.send(myMessage, myRemoteLocation);
  }


  void oscEvent(OscMessage theOscMessage) {
    print("### received an osc message.");
    print(" addrpattern: "+theOscMessage.addrPattern());
    println(" typetag: "+theOscMessage.typetag());
  }
</code></pre>

<p>In mac:</p>

<pre><code>  /**
   * oscP5sendreceive by andreas schlegel
   * example shows how to send and receive osc messages.
   * oscP5 website at <a href="http://www.sojamo.de/oscP5" target="_blank" rel="nofollow">http://www.sojamo.de/oscP5</a>
   */

  import oscP5.*;
  import netP5.*;

  OscP5 oscP5;
  NetAddress myRemoteLocation;
  String ipMac="192.168.1.3";
  String ipUb="192.168.1.5";
  int macPort = 12000;
  int ubPort=57120;

  void setup() {
    size(400,400);
    frameRate(25);
    oscP5 = new OscP5(this,ubPort);
    myRemoteLocation = new NetAddress(ipUb,macPort);
  }


  void draw() {
    background(0);  
  }

  void mousePressed() {
    OscMessage myMessage = new OscMessage("/test");
    myMessage.add(123); /* add an int to the osc message */
    oscP5.send(myMessage, myRemoteLocation); 
  }


  void oscEvent(OscMessage theOscMessage) {
    float value = theOscMessage.get(0).floatValue();
    println(" value: "+value);

  }
</code></pre>

<p>Any clue or advice will be very very welcome. A lot of thanks!</p>
]]></description>
   </item>
   <item>
      <title>Android App is not establishing the connection.</title>
      <link>https://forum.processing.org/two/discussion/18444/android-app-is-not-establishing-the-connection</link>
      <pubDate>Fri, 07 Oct 2016 14:35:22 +0000</pubDate>
      <dc:creator>gavanpreet28</dc:creator>
      <guid isPermaLink="false">18444@/two/discussions</guid>
      <description><![CDATA[<p>I have created Android app as tcp client and my pc is acting as tcp server(processing in java mode).I am using oscP5 library.</p>

<p>When i try to run android app on mobile (with Wifi or mobile data 'on'), black screen will appear. After few minutes, app got loaded with error (TcpClient IOException while trying to create a new socket processing).</p>

<p>But when i load the android app without internet connection, it works normally. But, of course, it's of no use.</p>

<p>Also, when i run both client and server in Java mode, everything works fine.</p>

<p>I have tried these things:</p>

<ul>
<li>PC firewall off.</li>
<li>App has internet permission. I also checked Android manifest. </li>
<li>Changes the ip and port.</li>
<li>Checked the 'security type' of internet connection. Its same on mobile and PC.</li>
</ul>

<p>Kindly help.</p>

<p>TCP Server</p>

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

    ControlP5 cp5;
    OscP5 oscP5tcpServer;
    OscMessage theOscMessage;
    String s = "";

    void setup() {
      size(360, 360);
      background(164);
      oscP5tcpServer = new OscP5(this, 12345, OscP5.TCP);
      PFont font = createFont("arial", 20); 
      cp5 = new ControlP5(this);
      cp5.addTextfield("output")
        .setPosition(20, 100)
        .setSize(200, 40)
        .setFont(font)
        .setFocus(true)
        .setColor(color(255, 0, 0));
        textFont(font);}

    void oscEvent (OscMessage theOscMessage) {
      String thirdValue = theOscMessage.get(0).stringValue();
      s = thirdValue ;
      if (theOscMessage.checkAddrPattern("/test")==true) {
        println(thirdValue);}}

    void draw() {
      cp5.get(Textfield.class, "output").setText(s);}
</code></pre>

<hr />

<p>TCP client</p>

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

ControlP5 cp5;
OscMessage myMessage;
OscP5 oscP5tcpClient;

void setup() {
  size(360, 360);
  cp5 = new ControlP5(this);
  oscP5tcpClient = new OscP5( this, "141.44.219.124", 12345, OscP5.TCP);

  cp5.addButton("colorA")
    .setPosition(100, 100)
    .setSize(150, 39);

  cp5.addButton("colorB")
    .setPosition(100, 140)
    .setSize(150, 39);}

void draw() {
  background(0);}

public void colorA() {
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add("Gavanpreet Singh"); /* add a string to the osc message */
  oscP5tcpClient.send(myMessage);}

public void colorB() {
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add("InDP Project"); /* add a string to the osc message */
  oscP5tcpClient.send(myMessage);}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Open sound control between tablet and computer message error (works on two computers)</title>
      <link>https://forum.processing.org/two/discussion/18348/open-sound-control-between-tablet-and-computer-message-error-works-on-two-computers</link>
      <pubDate>Thu, 29 Sep 2016 21:23:17 +0000</pubDate>
      <dc:creator>kristaannie</dc:creator>
      <guid isPermaLink="false">18348@/two/discussions</guid>
      <description><![CDATA[<p>Hey! I was able to get this code to work on two computers, but it's not working at all when I try to run the sketch independent of the browser on my tablet. I'm wondering if this has something to do with the port number or android mode?</p>

<p>Here is the code on my tablet:</p>

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


    Buttons button1;
    Buttons button2;

    OscP5 oscP5;
    NetAddress myRemoteLocation;

    void setup() {
      size(600,800);
      frameRate(25);
      /* start oscP5, listening for incoming messages at port 12000 */
      oscP5 = new OscP5(this,12000);



      myRemoteLocation = new NetAddress("192.168.1.179",12000);


      button1 = new Buttons();
      button1.x = 100;
      button1.y = 100;
      button1.w = 100;
      button1.h = 100;

      button2 = new Buttons();
      button2.x = 250;
      button2.y = 100;
      button2.w = 100;
      button2.h = 100;

    }


    void draw() {
      background(0);  
      rectMode(CENTER);

      fill(squareColor, 0, 0);

     button1.display("hello");

     button2.display("fractured");

    }

    void mousePressed() {
       button1.clicked("hello");
       button2.clicked("testing");

    }

    void clicked(String wordMessage){
      float d = dist(x, y, mouseX, mouseY);
      if (d &lt; 50) { 
       boxBackground = 255;
       OscMessage myMessage = new OscMessage(wordMessage);
       oscP5.send(myMessage, myRemoteLocation);
       println(myMessage);
      }
</code></pre>

<p>Here is the code on my computer:</p>

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

    int circleColor = 200;

    OscP5 oscP5;
    NetAddress myRemoteLocation;

    void setup() {
      size(400,400);
      frameRate(25);
      oscP5 = new OscP5(this,12000);

      myRemoteLocation = new NetAddress("192.168.1.128",12000);
    }


    void draw() {
      background(0);  
      rectMode(CENTER);

      fill(circleColor, 0, 0);
      ellipse(width/2, height/2, 100, 100);



    }


    void oscEvent(OscMessage theOscMessage) {

      print("### received an osc message.");
      //print(" addrpattern: "+theOscMessage.addrPattern());
      println(" typetag: "+theOscMessage.typetag());

      if(theOscMessage.checkAddrPattern("poopin")==true) {
        println("it worked!");

      } else if (theOscMessage.checkAddrPattern("hello")==true) {
       println("yay, it worked!");
      }

    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Receiving messages from mind wave mobile via thinkgearconnector</title>
      <link>https://forum.processing.org/two/discussion/18048/receiving-messages-from-mind-wave-mobile-via-thinkgearconnector</link>
      <pubDate>Fri, 02 Sep 2016 11:23:52 +0000</pubDate>
      <dc:creator>precociousmouse</dc:creator>
      <guid isPermaLink="false">18048@/two/discussions</guid>
      <description><![CDATA[<p>Hi all</p>

<p>I am working on a little project which requires reading out the data stream from a neurosky mind wave mobile. The current state of the project is: I have the headset connected to my mac through the installed thinkgearconnector over bluetooth. I also have a processing sketch which sets up a tcp connection to the thinkgearconnector using the oscP5 library.</p>

<p>I know there is a certain level of communication through the system as when I run the sketch, thinkgearconnector shows that it is connected as a client and it wakes the headset pairing. My problem is I am using oscEvent to receive any traffic but I am not receiving anything, and currently I am just printing a period to the console as a test.</p>

<p>Nothing…</p>

<p>Anyone else having similar issues? I know that there was a neurosky lib for processing but it seems to be deprecated. I also know that the headset is working as it connects to the deep applications supplied with the device through the thinkgearconnector.</p>

<p>Any help gratefully received</p>

<p>Caleb</p>
]]></description>
   </item>
   <item>
      <title>How to respond with each point seperate in the spiral</title>
      <link>https://forum.processing.org/two/discussion/17123/how-to-respond-with-each-point-seperate-in-the-spiral</link>
      <pubDate>Mon, 13 Jun 2016 12:37:09 +0000</pubDate>
      <dc:creator>Dom1</dc:creator>
      <guid isPermaLink="false">17123@/two/discussions</guid>
      <description><![CDATA[<p>Hello together,
i am a student from Germany and my english isn´t the best. Sorry for that. I need your help for a project named visual music. I havent so much experience in processing, so i hope you can help me.</p>

<p>My code interprets data from cSound with Processing. The code works, but now i want to change the colour and size values of each generated point in my spiral. It should change them in addiction to the imported data ( int circle_color_r, circle_color_g, circle_color_b and float value). Here is my (Processing)code. Do you have a solution for me?</p>

<pre><code>import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;

int circle_color_r ;
int circle_color_g ;
int circle_color_b ;
float ang=0;
int mx,my;
float value;
float size;

void setup(){
  size(500,500);
  background(0);
  frameRate(100);
  mx=width/2;
  my=height/2;
  oscP5 = new OscP5(this,12000); //Portangabe  
}

void draw(){
  strokeWeight(size); //stärke der Punkte
  rect(0,0,width,height);
  float ray=0.2;
  ang-=1.1; //Winkelgeschwindigkeit

  for(int i=0;i&lt;650;i++){
    ray*=1.0022;
    ray+=0.2;
    float maxray = ray*1.1;//streuung
    float a = radians(ang+i);

    stroke(circle_color_r, circle_color_g, circle_color_b); 
    point(mx+ cos(a)*random(ray,maxray),my+sin(a)*random(ray,maxray)); 
  }
   this.size = value*10;
   saveFrame();
 }
void oscEvent(OscMessage theOscMessage) {
   if(theOscMessage.checkAddrPattern("/freq")==true)
  {
   value = theOscMessage.get(0).floatValue();
  print(value);
  }
  if(theOscMessage.checkAddrPattern("/color")==true)
  {
   circle_color_r = theOscMessage.get(0).intValue();
   circle_color_g = theOscMessage.get(1).intValue();
   circle_color_b = theOscMessage.get(2).intValue();
print(circle_color_r);
  } 
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Changes in code don't apply (Python)</title>
      <link>https://forum.processing.org/two/discussion/16284/changes-in-code-don-t-apply-python</link>
      <pubDate>Wed, 27 Apr 2016 12:59:00 +0000</pubDate>
      <dc:creator>michizac</dc:creator>
      <guid isPermaLink="false">16284@/two/discussions</guid>
      <description><![CDATA[<p>I have this problem: I am editing the code in a class of my sketch but the changes are not registered by the sketch neither when I save the sketch nor when I re-run it. The only way to have the changes apply is to reload the entire sketch. Is this a new bug?</p>

<p>It might be related to the oscP5 library. This is the sketch:</p>

<pre><code>add_library('oscP5')

class Listen(OscEventListener):
     def oscEvent(_, m):
        global col, msg
        col = m.arguments()
        print col
        print 'Received oscEvent:', m.addrPattern(), col, m.typetag()

def setup():
    size(400, 400)
    background(255)
    portR = 7407
    oscR = OscP5(this, portR)
    oscR.addListener(Listen())

def draw(): pass 
</code></pre>

<p>whenever I edit the Listen class nothing happens unless i reload the sketch</p>
]]></description>
   </item>
   <item>
      <title>receive osc</title>
      <link>https://forum.processing.org/two/discussion/15995/receive-osc</link>
      <pubDate>Wed, 13 Apr 2016 00:25:38 +0000</pubDate>
      <dc:creator>michizac</dc:creator>
      <guid isPermaLink="false">15995@/two/discussions</guid>
      <description><![CDATA[<p>I am having troubles receiving messages with the oscP5 library. from the Java example, I got this setup in python</p>

<pre><code>        from oscP5 import *
        from netP5 import * 



        print 
        def setup():
            size(400, 400)
            background(0)
            port1 = 12000
            oscP5 = OscP5(this, port1)
            loc = NetAddress('127.0.0.1', 12000)


        def draw():pass 



        def oscEvent(OscMessage):
           msg = OscMessage
           print "### received an osc message." 
           print  " addrpattern: %s " % msg.addrPattern()
           print  " typetag:%s " % msg.typetag()
</code></pre>

<p>While sending messages works fine, for some reason this doesn't. I think there is something wrong with the way I assign the value in the oscEvent function. Any idea?
Thanks</p>
]]></description>
   </item>
   <item>
      <title>Combine use of oscP5 and Fisica</title>
      <link>https://forum.processing.org/two/discussion/15969/combine-use-of-oscp5-and-fisica</link>
      <pubDate>Mon, 11 Apr 2016 17:12:19 +0000</pubDate>
      <dc:creator>caggen96</dc:creator>
      <guid isPermaLink="false">15969@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>to make this fast: i'm a noob at processing and programming in general (started a couple of weeks ago), but I LOVE IT! Very fun so far.</p>

<p>My problem with this game I'm trying to create is, well I want to be able to control the "FBox player" (a rectangle that serves as the player) using oscP5. When I move the "//Player" part into draw I'm able to do it but it generates LOTS of boxes and trying to use background() to clean doesn't work. Can anyone help me out with this issue?</p>

<p>To sum up: let me control the box without the program generating hundreds of boxes:)</p>

<p>Many thanks in advance!</p>

<pre><code>OscP5 oscP5;

FWorld world;

float x, y, inputX, inputY;

void setup() {

size(500, 500);

Fisica.init(this);  
world = new FWorld();
world.setEdges();
world.setEdgesRestitution(0.5);

oscP5 = new OscP5(this, 12000);

 // Player
FBox player = new FBox(80, 20);
player.setPosition(x, 450);
world.add(player);

 // Ball
FCircle ball = new FCircle(25);
ball.setPosition(250, 250);
world.add(ball);
}

void draw() {
background(0, 150, 150);

world.step();
world.draw();

x = lerp(x, inputX, 0.08f);
 // y = lerp(y, inputY, 0.08f);

}

void oscEvent(OscMessage msg) {
if (msg.checkAddrPattern("/multi/1")) {
inputX = msg.get(0).floatValue() * width;
 // inputY = msg.get(1).floatValue() * height;

println(x + " " + y);
</code></pre>

<p>}
  }</p>
]]></description>
   </item>
   </channel>
</rss>