Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleBeispiel OSC Senden
collapsetrue
import oscP5.*; // Import the OSC Libary
import netP5.*; // Import the net Library
OscP5 oscP5; // Make an instance of the OSC Library
NetAddress myRemoteLocation; // Set a net Address

void setup()
{
  size(400, 400);
  oscP5 = new OscP5(this, 0000); // start oscP5, listening for incoming messages at port 12000
  myRemoteLocation = new NetAddress("172.31.224.95", 1111); // The Address defined here is the Address of the Receiver
}

void draw()
{
  background(0);
  sendOSC(255);
}

void sendOSC(int theData)
{
  OscMessage myMessage = new OscMessage("Moritz"); // New Message
  myMessage.add(theData); // Add Data
  oscP5.send(myMessage, myRemoteLocation); // Send Message
}

Code Block
languagejava
titleBeispiel OSC Empfangen
collapsetrue
import oscP5.*;
import netP5.*;
OscP5 oscP5; //NetAddress
myRemoteLocation;
void setup()
{
  size(800, 400);
  oscP5 = new OscP5(this, 7777); //myRemoteLocation = new NetAddress("localhost",12000);
}
}

void draw()
{
}

void oscEvent(OscMessage theOscMessage)
{
  print("### received an osc message.");
  println(" addrpattern: "+theOscMessage.addrPattern());
  //print(" typetag: "+theOscMessage.typetag());
  //print(millis());
  if (theOscMessage.addrPattern().equals("/CoM"))
  {
    println(theOscMessage.get(0).stringValue()+" "+theOscMessage.get(1).stringValue()+" "+theOscMessage.get(2).stringValue());
  }
}