summaryrefslogtreecommitdiffstats
path: root/libraries/oscP5/examples/oscP5properties/oscP5properties.pde
blob: a0756fee0453ecdbe184b3942d0f3657caaf2520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
 * oscP5properities by andreas schlegel
 * example shows how to use osc properties. 
 * if you need more specific settings for your osc session,
 * osc properties serves your needs.
 * oscP5 website at http://www.sojamo.de/oscP5
 */
import oscP5.*;
import netP5.*;

OscP5 oscP5;

void setup() {
  size(400,400);
  frameRate(25);

  /* create a new osc properties object */
  OscProperties properties = new OscProperties();
  
  /* set a default NetAddress. sending osc messages with no NetAddress parameter 
   * in oscP5.send() will be sent to the default NetAddress.
   */
  properties.setRemoteAddress("127.0.0.1",12000);
  
  /* the port number you are listening for incoming osc packets. */
  properties.setListeningPort(12000);
  
  
  /* Send Receive Same Port is an option where the sending and receiving port are the same.
   * this is sometimes necessary for example when sending osc packets to supercolider server.
   * while both port numbers are the same, the receiver can simply send an osc packet back to
   * the host and port the message came from.
   */
  properties.setSRSP(OscProperties.ON);
  
  /* set the datagram byte buffer size. this can be useful when you send/receive
   * huge amounts of data, but keep in mind, that UDP is limited to 64k
  */
  properties.setDatagramSize(1024);
  
  /* initialize oscP5 with our osc properties */
  oscP5 = new OscP5(this,properties);    
  
  /* print your osc properties */
  println(properties.toString());
}



void mousePressed() {
  /* create a new osc message with address pattern /test */
  OscMessage myMessage = new  OscMessage("/test");
  myMessage.add(200);
  
  /* send the osc message to the default netAddress, set in the OscProperties above.*/
  oscP5.send(myMessage);
}


void draw() {
  background(0);  
}



/* 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());
}