-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing tcp, udp, multicast and updating examples
- Loading branch information
Showing
46 changed files
with
2,290 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ target/ | |
.classpath | ||
.project | ||
.settings/ | ||
distribution/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
* binary hosting | ||
1) http://bintray.com | ||
2) http://www.sojamo.de/libraries/oscP5/oscP5.zip (this is where the most recent distribution is hosted which is also accessed by the PDE's Library Manager) | ||
3) code.google.com/p/oscp5/downloads (currently used as archive) | ||
|
||
* zeroconf | ||
http://stackoverflow.com/questions/1233204/are-there-any-other-java-libraries-for-bonjour-zeroconf-apart-from-jmdns | ||
http://stackoverflow.com/questions/13637613/bonjour-client-java | ||
http://android.noisepages.com/2010/02/yes-android-can-do-zeroconfbonjour-jmdns/ | ||
http://www.zeroconf.org/ | ||
http://jmdns.sourceforge.net/ | ||
|
||
* A list of alternative networking libraries | ||
http://stackoverflow.com/questions/788786/how-to-write-a-complete-server-client-communication-using-java-nio | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
examples/basics-without-comments/oscP5listener/oscP5listener.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
NetAddress receiver; | ||
|
||
void setup() { | ||
|
||
size( 400 , 400 ); | ||
|
||
osc = new OscP5( this , 12000 ); | ||
receiver = new NetAddress( "127.0.0.1" , 12000 ); | ||
|
||
osc.addListener( new OscEventListener() { | ||
public void oscEvent(OscMessage m) { | ||
println("got a message : "+ m.getAddress() ); | ||
} | ||
}); | ||
|
||
} | ||
|
||
|
||
void draw() { | ||
background(0); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send( receiver , "/test" , 1 , 2 , 3 ); | ||
} | ||
|
||
|
||
|
48 changes: 48 additions & 0 deletions
48
examples/basics-without-comments/oscP5parse/oscP5parse.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
NetAddress receiver; | ||
|
||
void setup() { | ||
size( 400 , 400 ); | ||
osc = new OscP5( this , 12000 ); | ||
receiver = new NetAddress( "127.0.0.1" , 12000 ); | ||
|
||
} | ||
|
||
|
||
void draw() { | ||
background(0); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send( receiver , "/test" , 1 , 2.0 , "three" , new byte[] {0x00 , 0x10 , 0x20 }, true , false , 100); | ||
} | ||
|
||
|
||
void oscEvent( OscMessage m) { | ||
|
||
if( m.getAddress().equals("/test") ) { | ||
|
||
int v0 = m.intValue( 0 ); | ||
float v1 = m.floatValue( 1 ); | ||
String v2 = m.stringValue( 2 ); | ||
byte[] v3 = m.bytesValue( 3 ); | ||
boolean v4 = m.booleanValue( 4 ); | ||
boolean v5 = m.booleanValue( 5 ); | ||
int v6 = m.intValue( 6 ); | ||
|
||
println( "Address\t" + m.getAddress() ); | ||
|
||
println( "Typetag\t" + m.getTypetag() ); | ||
|
||
println( "Arguments\t" + v0 +" , "+ v1 +" , "+ v2 +" , "+ v3 +" , "+ v4 +" , "+ v5 +" , "+v6); | ||
|
||
for( Object o : m.getArguments() ) { | ||
println( o.getClass().getSimpleName() + "\t" + o ); | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
NetAddress receiver; | ||
|
||
void setup() { | ||
size(400, 400); | ||
|
||
osc = new OscP5(this, 12000); | ||
receiver = new NetAddress("127.0.0.1", 12000); | ||
osc.plug(this, "test", "/test"); | ||
} | ||
|
||
void test(float f) { | ||
println("got a test "+f); | ||
s0 = f; | ||
} | ||
|
||
float s0, s1; | ||
void draw() { | ||
background(0); | ||
s1 += (s0-s1)* 0.05; | ||
ellipse( width/2, height/2, s1, s1 ); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send(receiver, "/test", random( 100, 400 ) ); | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
examples/basics-without-comments/oscP5properties/oscP5properties.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 oscP5; | ||
|
||
void setup() { | ||
size(400,400); | ||
oscP5 = new OscP5(this,12000); | ||
/* TODO */ | ||
} | ||
|
||
|
||
void draw() { | ||
background(0); | ||
} | ||
|
45 changes: 45 additions & 0 deletions
45
examples/basics-without-comments/oscP5receive/oscP5receive.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
|
||
NetAddress receiver; | ||
|
||
void setup() { | ||
size(400,400); | ||
osc = new OscP5( this , 12000 ); | ||
receiver = new NetAddress( "127.0.0.1" , 12000 ); | ||
} | ||
|
||
|
||
float x0,x1; | ||
float y0,y1; | ||
float r0,r1; | ||
|
||
void draw() { | ||
background(0); | ||
x1 += (x0-x1)* 0.05; | ||
y1 += (y0-y1)* 0.05; | ||
r1 += (r0-r1)* 0.05; | ||
translate(x1 , y1 ); | ||
rotate( r1 ); | ||
rect( 0 , 0 , 100 , 100 ); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send( receiver , "/change" , random(100,300) , random(100,300) , random(-PI,PI) ); | ||
} | ||
|
||
void oscEvent( OscMessage m ) { | ||
print( "Received an osc message" ); | ||
print( ", address pattern: " + m.getAddress( ) ); | ||
print( ", typetag: " + m.getTypetag( ) ); | ||
if(m.getAddress( ).equals("/change") && m.getTypetag().equals("fff")) { | ||
/* transfer receivd values to local variables */ | ||
x0 = m.floatValue(0); | ||
y0 = m.floatValue(1); | ||
r0 = m.floatValue(2); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
|
||
NetAddress receiver; | ||
|
||
float r,g,b; | ||
|
||
void setup() { | ||
size( 400 , 400 ); | ||
|
||
osc = new OscP5( this , 12000 ); | ||
receiver = new NetAddress( "127.0.0.1" , 12000 ); | ||
} | ||
|
||
void draw() { | ||
background( r , g , b ); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send( receiver , "/test" , random( 255 ) , random( 255 ) , random( 255 ) ); | ||
} | ||
|
||
void oscEvent( OscMessage m ) { | ||
if( m.getAddress().equals( "/test") ) { | ||
r = m.floatValue( 0 ); | ||
g = m.floatValue( 1 ); | ||
b = m.floatValue( 2 ); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
NetAddress receiver; | ||
|
||
void setup() { | ||
|
||
size( 400 , 400 ); | ||
|
||
osc = new OscP5( this , 12000 ); | ||
receiver = new NetAddress( "127.0.0.1" , 12000 ); | ||
|
||
osc.addListener( new OscEventListener() { | ||
public void oscEvent(OscMessage m) { | ||
println("got a message : "+ m.getAddress() ); | ||
} | ||
}); | ||
|
||
} | ||
|
||
|
||
void draw() { | ||
background(0); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send( receiver , "/test" , 1 , 2 , 3 ); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
NetAddress receiver; | ||
|
||
void setup() { | ||
size( 400 , 400 ); | ||
osc = new OscP5( this , 12000 ); | ||
receiver = new NetAddress( "127.0.0.1" , 12000 ); | ||
|
||
} | ||
|
||
|
||
void draw() { | ||
background(0); | ||
} | ||
|
||
void mousePressed() { | ||
osc.send( receiver , "/test" , 1 , 2.0 , "three" , new byte[] {0x00 , 0x10 , 0x20 }, true , false , 100); | ||
} | ||
|
||
|
||
void oscEvent( OscMessage m) { | ||
|
||
if( m.getAddress().equals("/test") ) { | ||
|
||
int v0 = m.intValue( 0 ); | ||
float v1 = m.floatValue( 1 ); | ||
String v2 = m.stringValue( 2 ); | ||
byte[] v3 = m.bytesValue( 3 ); | ||
boolean v4 = m.booleanValue( 4 ); | ||
boolean v5 = m.booleanValue( 5 ); | ||
int v6 = m.intValue( 6 ); | ||
|
||
println( "Address\t" + m.getAddress() ); | ||
|
||
println( "Typetag\t" + m.getTypetag() ); | ||
|
||
println( "Arguments\t" + v0 +" , "+ v1 +" , "+ v2 +" , "+ v3 +" , "+ v4 +" , "+ v5 +" , "+v6); | ||
|
||
for( Object o : m.getArguments() ) { | ||
println( o.getClass().getSimpleName() + "\t" + o ); | ||
} | ||
println(); | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* oscP5plug | ||
* example shows how to link an osc message to a function of an object. | ||
* | ||
* by Andreas Schlegel, 2013 | ||
* www.sojamo.de/libraries/oscP5 | ||
* | ||
*/ | ||
|
||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 osc; | ||
NetAddress receiver; | ||
|
||
void setup() { | ||
size(400,400); | ||
|
||
/* start oscP5, listening for incoming messages at port 12000 */ | ||
osc = new OscP5(this,12000); | ||
|
||
/* we will send osc message to ourself */ | ||
receiver = new NetAddress("127.0.0.1",12000); | ||
|
||
/* plug function test of this (the main sketch object) to osc message /test */ | ||
osc.plug(this, "test" , "/test"); | ||
} | ||
|
||
// expects an osc packet with address pattern /test and typetag f | ||
void test(float f) { | ||
println("got a test "+f); | ||
s0 = f; /* transfer received value to local variable */ | ||
} | ||
|
||
float s0,s1; | ||
void draw() { | ||
background(0); | ||
s1 += (s0-s1)* 0.05; | ||
ellipse( width/2 , height/2 , s1 , s1 ); | ||
} | ||
|
||
void mousePressed() { | ||
/* send an osc message to receiver */ | ||
osc.send(receiver, "/test" , random( 100 , 400 ) ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
import oscP5.*; | ||
import netP5.*; | ||
|
||
OscP5 oscP5; | ||
|
||
void setup() { | ||
size(400,400); | ||
oscP5 = new OscP5(this,12000); | ||
/* TODO */ | ||
} | ||
|
||
|
||
void draw() { | ||
background(0); | ||
} | ||
|
Oops, something went wrong.