Permalink
Browse files

started working on 2.0.0 version

  • Loading branch information...
1 parent 624d596 commit 8a6a4bdbae3f4e10662358ef45b43d1774a15713 @sojamo committed Jul 21, 2013
Showing with 10,819 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +7 −0 data/README
  3. +73 −0 examples/oscP5broadcastClient/oscP5broadcastClient.pde
  4. +27 −0 examples/oscP5broadcastTester/oscP5broadcastTester.pde
  5. +73 −0 examples/oscP5broadcaster/oscP5broadcaster.pde
  6. +69 −0 examples/oscP5bundle/oscP5bundle.pde
  7. +38 −0 examples/oscP5flush/oscP5flush.pde
  8. +55 −0 examples/oscP5message/oscP5message.pde
  9. +51 −0 examples/oscP5multicast/oscP5multicast.pde
  10. +45 −0 examples/oscP5oscArgument/oscP5oscArgument.pde
  11. +65 −0 examples/oscP5parsing/oscP5parsing.pde
  12. +82 −0 examples/oscP5plug/oscP5plug.pde
  13. +72 −0 examples/oscP5properties/oscP5properties.pde
  14. +51 −0 examples/oscP5sendReceive/oscP5sendReceive.pde
  15. +59 −0 examples/oscP5tcp/oscP5tcp.pde
  16. +6 −0 lib/README
  17. +8 −0 pom.xml
  18. +171 −0 resources/build.properties
  19. +386 −0 resources/build.xml
  20. BIN resources/code/ExampleTaglet.class
  21. +231 −0 resources/code/ExampleTaglet.java
  22. BIN resources/code/ant-contrib-1.0b3.jar
  23. +18 −0 resources/code/doc.sh
  24. +46 −0 resources/install_instructions.txt
  25. +49 −0 resources/library.properties
  26. +310 −0 resources/stylesheet.css
  27. +337 −0 src/main/java/netP5/AbstractMulticast.java
  28. +498 −0 src/main/java/netP5/AbstractTcpClient.java
  29. +317 −0 src/main/java/netP5/AbstractTcpServer.java
  30. +199 −0 src/main/java/netP5/AbstractUdpClient.java
  31. +271 −0 src/main/java/netP5/AbstractUdpServer.java
  32. +470 −0 src/main/java/netP5/Bytes.java
  33. +153 −0 src/main/java/netP5/Logger.java
  34. +116 −0 src/main/java/netP5/Multicast.java
  35. +130 −0 src/main/java/netP5/NetAddress.java
  36. +169 −0 src/main/java/netP5/NetAddressList.java
  37. +154 −0 src/main/java/netP5/NetInfo.java
  38. +34 −0 src/main/java/netP5/NetListener.java
  39. +148 −0 src/main/java/netP5/NetMessage.java
  40. +55 −0 src/main/java/netP5/NetP5.java
  41. +222 −0 src/main/java/netP5/NetPlug.java
  42. +65 −0 src/main/java/netP5/NetStatus.java
  43. +705 −0 src/main/java/netP5/StringUtils.java
  44. +214 −0 src/main/java/netP5/TcpClient.java
  45. +67 −0 src/main/java/netP5/TcpPacket.java
  46. +38 −0 src/main/java/netP5/TcpPacketListener.java
  47. +177 −0 src/main/java/netP5/TcpServer.java
  48. +49 −0 src/main/java/netP5/UdpClient.java
  49. +41 −0 src/main/java/netP5/UdpPacketListener.java
  50. +151 −0 src/main/java/netP5/UdpServer.java
  51. +228 −0 src/main/java/oscP5/OscArgument.java
  52. +189 −0 src/main/java/oscP5/OscBundle.java
  53. +37 −0 src/main/java/oscP5/OscEventListener.java
  54. +708 −0 src/main/java/oscP5/OscMessage.java
  55. +355 −0 src/main/java/oscP5/OscNetManager.java
  56. +941 −0 src/main/java/oscP5/OscP5.java
  57. +143 −0 src/main/java/oscP5/OscPacket.java
  58. +245 −0 src/main/java/oscP5/OscPatcher.java
  59. +258 −0 src/main/java/oscP5/OscPlug.java
  60. +319 −0 src/main/java/oscP5/OscProperties.java
  61. +63 −0 src/main/java/oscP5/OscStatus.java
  62. +24 −0 src/main/java/oscP5/changelog.txt
  63. +170 −0 web/index.html
  64. +363 −0 web/stylesheet.css
View
@@ -0,0 +1,4 @@
+target/
+.classpath
+.project
+.settings/
View
@@ -0,0 +1,7 @@
+the data folder:
+If your library is using files like images, sound files,
+any data file, etc., put them into the data folder.
+When coding your library you can use processing's internal loading
+functions like loadImage(), loadStrings(), etc. to load files
+located inside the data folder into your library.
+
@@ -0,0 +1,73 @@
+/**
+ * oscP5broadcastClient by andreas schlegel
+ * an osc broadcast client.
+ * an example for broadcast server is located in the oscP5broadcaster exmaple.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+
+OscP5 oscP5;
+
+/* a NetAddress contains the ip address and port number of a remote location in the network. */
+NetAddress myBroadcastLocation;
+
+void setup() {
+ size(400,400);
+ frameRate(25);
+
+ /* create a new instance of oscP5.
+ * 12000 is the port number you are listening for incoming osc messages.
+ */
+ oscP5 = new OscP5(this,12000);
+
+ /* create a new NetAddress. a NetAddress is used when sending osc messages
+ * with the oscP5.send method.
+ */
+
+ /* the address of the osc broadcast server */
+ myBroadcastLocation = new NetAddress("127.0.0.1",32000);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* create a new OscMessage with an address pattern, in this case /test. */
+ OscMessage myOscMessage = new OscMessage("/test");
+ /* add a value (an integer) to the OscMessage */
+ myOscMessage.add(100);
+ /* send the OscMessage to a remote location specified in myNetAddress */
+ oscP5.send(myOscMessage, myBroadcastLocation);
+}
+
+
+void keyPressed() {
+ OscMessage m;
+ switch(key) {
+ case('c'):
+ /* connect to the broadcaster */
+ m = new OscMessage("/server/connect",new Object[0]);
+ oscP5.flush(m,myBroadcastLocation);
+ break;
+ case('d'):
+ /* disconnect from the broadcaster */
+ m = new OscMessage("/server/disconnect",new Object[0]);
+ oscP5.flush(m,myBroadcastLocation);
+ break;
+
+ }
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+ /* get and print the address pattern and the typetag of the received OscMessage */
+ println("### received an osc message with addrpattern "+theOscMessage.addrPattern()+" and typetag "+theOscMessage.typetag());
+ theOscMessage.print();
+}
@@ -0,0 +1,27 @@
+import controlP5.*;
+
+
+ControlP5 controlP5;
+
+int myColorBackground = color(0,0,0);
+
+int knobValue = 100;
+
+void setup() {
+ size(400,400);
+ smooth();
+ controlP5 = new ControlP5(this);
+ controlP5.addKnob("knob",100,200,128,100,160,40);
+ controlP5.addKnob("knobValue",0,255,128,100,240,40);
+}
+
+void draw() {
+ background(myColorBackground);
+ fill(knobValue);
+ rect(0,0,width,100);
+}
+
+void knob(int theColor) {
+ myColorBackground = color(theColor);
+ println("a knob event. setting background to "+theColor);
+}
@@ -0,0 +1,73 @@
+/**
+ * oscP5broadcaster by andreas schlegel
+ * an osc broadcast server.
+ * osc clients can connect to the server by sending a connect and
+ * disconnect osc message as defined below to the server.
+ * incoming messages at the server will then be broadcasted to
+ * all connected clients.
+ * an example for a client is located in the oscP5broadcastClient exmaple.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddressList myNetAddressList = new NetAddressList();
+/* listeningPort is the port the server is listening for incoming messages */
+int myListeningPort = 32000;
+/* the broadcast port is the port the clients should listen for incoming messages from the server*/
+int myBroadcastPort = 12000;
+
+String myConnectPattern = "/server/connect";
+String myDisconnectPattern = "/server/disconnect";
+
+
+void setup() {
+ oscP5 = new OscP5(this, myListeningPort);
+ frameRate(25);
+}
+
+void draw() {
+ background(0);
+}
+
+void oscEvent(OscMessage theOscMessage) {
+ /* check if the address pattern fits any of our patterns */
+ if (theOscMessage.addrPattern().equals(myConnectPattern)) {
+ connect(theOscMessage.netAddress().address());
+ }
+ else if (theOscMessage.addrPattern().equals(myDisconnectPattern)) {
+ disconnect(theOscMessage.netAddress().address());
+ }
+ /**
+ * if pattern matching was not successful, then broadcast the incoming
+ * message to all addresses in the netAddresList.
+ */
+ else {
+ oscP5.send(theOscMessage, myNetAddressList);
+ }
+}
+
+
+ private void connect(String theIPaddress) {
+ if (!myNetAddressList.contains(theIPaddress, myBroadcastPort)) {
+ myNetAddressList.add(new NetAddress(theIPaddress, myBroadcastPort));
+ println("### adding "+theIPaddress+" to the list.");
+ } else {
+ println("### "+theIPaddress+" is already connected.");
+ }
+ println("### currently there are "+myNetAddressList.list().size()+" remote locations connected.");
+ }
+
+
+
+private void disconnect(String theIPaddress) {
+if (myNetAddressList.contains(theIPaddress, myBroadcastPort)) {
+ myNetAddressList.remove(theIPaddress, myBroadcastPort);
+ println("### removing "+theIPaddress+" from the list.");
+ } else {
+ println("### "+theIPaddress+" is not connected.");
+ }
+ println("### currently there are "+myNetAddressList.list().size());
+ }
@@ -0,0 +1,69 @@
+/**
+ * oscP5bundle by andreas schlegel
+ * an osc broadcast server.
+ * example shows how to create and send osc bundles.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+ size(400,400);
+ frameRate(25);
+ /* start oscP5, listening for incoming messages at port 12000 */
+ oscP5 = new OscP5(this,12000);
+
+ /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+ * an ip address and a port number. myRemoteLocation 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",12000);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* create an osc bundle */
+ OscBundle myBundle = new OscBundle();
+
+ /* createa new osc message object */
+ OscMessage myMessage = new OscMessage("/test");
+ myMessage.add("abc");
+
+ /* add an osc message to the osc bundle */
+ myBundle.add(myMessage);
+
+ /* reset and clear the myMessage object for refill. */
+ myMessage.clear();
+
+ /* refill the osc message object again */
+ myMessage.setAddrPattern("/test2");
+ myMessage.add("defg");
+ myBundle.add(myMessage);
+
+ myBundle.setTimetag(myBundle.now() + 10000);
+ /* send the osc bundle, containing 2 osc messages, to a remote location. */
+ oscP5.send(myBundle, myRemoteLocation);
+}
+
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+ /* print the address pattern and the typetag of the received OscMessage */
+ print("### received an osc message.");
+ print(" addrpattern: "+theOscMessage.addrPattern());
+ print(" typetag: "+theOscMessage.typetag());
+ println(" timetag: "+theOscMessage.timetag());
+}
@@ -0,0 +1,38 @@
+ /**
+ * oscP5flush by andreas schlegel
+ * example shows how to send osc messages without having to instantiate an oscP5 object.
+ * this can be useful if you are not listening for incoming messages and you
+ * want to avoid to have the additional oscP5 thread running listening for incoming
+ * message (which you wont need if you are only sending messages).
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+
+NetAddress myRemoteLocation;
+void setup() {
+ size(400,400);
+ frameRate(25);
+ /* set up a remote location */
+ myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* create a new OscMessage with an address pattern, in this case /test. */
+ OscMessage myOscMessage = new OscMessage("/test");
+
+ /* add a value (an integer) to the OscMessage */
+ myOscMessage.add(100);
+
+ /* send the OscMessage to the remote location.
+ */
+ OscP5.flush(myOscMessage,myRemoteLocation);
+}
@@ -0,0 +1,55 @@
+/**
+ * oscP5message by andreas schlegel
+ * example shows how to create osc messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+ size(400,400);
+ frameRate(25);
+ /* start oscP5, listening for incoming messages at port 12000 */
+ oscP5 = new OscP5(this,12000);
+
+ /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+ * an ip address and a port number. myRemoteLocation 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",12000);
+}
+
+
+void draw() {
+ background(0);
+}
+
+void mousePressed() {
+ /* in the following different ways of creating osc messages are shown by example */
+ OscMessage myMessage = new OscMessage("/test");
+
+ myMessage.add(123); /* add an int to the osc message */
+ myMessage.add(12.34); /* add a float to the osc message */
+ myMessage.add("some text"); /* add a string to the osc message */
+ myMessage.add(new byte[] {0x00, 0x01, 0x10, 0x20}); /* add a byte blob to the osc message */
+ myMessage.add(new int[] {1,2,3,4}); /* add an int array to the osc message */
+
+ /* send the message */
+ oscP5.send(myMessage, myRemoteLocation);
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+ /* print the address pattern and the typetag of the received OscMessage */
+ print("### received an osc message.");
+ print(" addrpattern: "+theOscMessage.addrPattern());
+ println(" typetag: "+theOscMessage.typetag());
+}
Oops, something went wrong.

0 comments on commit 8a6a4bd

Please sign in to comment.