xxxxxxxxxx
import ddf.minim.*;
import oscP5.*;
import netP5.*;
float x;
float y;
Minim minim;
AudioInput input;
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup () {
// Sketch einstellen
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this, 13000);
size (320, 240);
smooth();
stroke (255, 25);
noFill ();
// Startposition festlegen
x = 0;
y = 20;
// Audiotoolkit anlegen
minim = new Minim (this);
input = minim.getLineIn (Minim.STEREO, 512);
background (0);
/* 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.
*/
//only remote address and port matter for transmitting
myRemoteLocation = new NetAddress("127.0.0.1", 12001);
}
void draw () {
int i =0;
// Kreisgröße Abhängig von Lautstärke
float dim = input.mix.level () * width;
// Kreis x-Position verschieben
// Kreis zeichnen
if (dim >= 60) {
System.out.println("laut genug "+dim);
OscMessage myMessage = new OscMessage("/laut genug");
myMessage.add(1);
oscP5.send(myMessage, myRemoteLocation);
}
else {
// OscMessage myMessage = new OscMessage("/");
// myMessage.add(0);
// oscP5.send(myMessage, myRemoteLocation);
}
}
void oscEvent(OscMessage theOscMessage) {
/* print the address pattern and the typetag of the received OscMessage */
print("### received an osc message.");
print(" addrpattern: "+theOscMessage.addrPattern());
println(" typetag: "+theOscMessage.typetag());
}