|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oscP5.OscPatcher oscP5.OscPacket oscP5.OscMessage
public class OscMessage
An OSC message consists of an OSC Address Pattern, an OSC Type Tag String and the OSC arguments.
/** * oscP5sendreceive by andreas schlegel * example shows how to send and receive 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 */ /* 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()); }
Constructor Summary | |
---|---|
OscMessage(int theAddrInt)
|
|
OscMessage(int theAddrPattern,
Object[] theArguments)
|
|
OscMessage(OscMessage theOscMessage)
|
|
OscMessage(String theAddrPattern)
|
|
OscMessage(String theAddrPattern,
Object[] theArguments)
|
Method Summary | |
---|---|
OscMessage |
add()
add values to an osc message. |
OscMessage |
add(boolean theValue)
|
OscMessage |
add(Boolean theValue)
|
OscMessage |
add(byte[] theArray)
|
OscMessage |
add(char theValue)
|
OscMessage |
add(char[] theArray)
|
OscMessage |
add(Character theValue)
|
OscMessage |
add(double theValue)
|
OscMessage |
add(Double theValue)
|
OscMessage |
add(float theValue)
|
OscMessage |
add(Float theValue)
|
OscMessage |
add(float[] theArray)
|
OscMessage |
add(int theValue)
|
OscMessage |
add(int[] theArray)
|
OscMessage |
add(Integer theValue)
|
OscMessage |
add(int channel,
int status,
int value1,
int value2)
|
OscMessage |
add(Object[] theArray)
|
OscMessage |
add(String theValue)
|
OscMessage |
add(String[] theArray)
|
OscMessage |
addArguments(Object[] theArguments)
add a list of arguments to an exisiting set of arguments. |
int |
addrInt()
returns the address pattern of the osc message as int. |
String |
addrPattern()
|
Object[] |
arguments()
|
boolean |
checkAddrPattern(String theAddrPattern)
check if an address pattern equals a specific address pattern you are looking for. |
boolean |
checkTypetag(String theTypeTag)
|
void |
clear()
clear and reset an OscMessage for reuse. |
void |
clearArguments()
clears the arguments in a message, but keeps the address the address pattern. |
OscArgument |
get(int theIndex)
get a value at a specific position in the osc message. |
byte[] |
getAddrPatternAsBytes()
|
byte[] |
getBytes()
|
byte[] |
getTypetagAsBytes()
|
boolean |
isPlugged()
|
static byte[] |
makeBlob(byte[] b)
|
void |
print()
|
void |
printData()
|
void |
set(int theIndex,
Object theObject)
TODO set should enable the programmer to set values of an existing osc message. |
void |
setAddrPattern(int theAddrPattern)
|
void |
setAddrPattern(String theAddrPattern)
set the address pattern of an osc message. |
void |
setArguments(Object[] theArguments)
set the arguments of the osc message using an object array. |
long |
timetag()
get the timetag of an osc message. |
String |
toString()
|
String |
typetag()
returns the typetag of the osc message. |
Methods inherited from class oscP5.OscPacket |
---|
address, netaddress, netAddress, port, tcpConnection |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public OscMessage(OscMessage theOscMessage)
theOscMessage
- OscMessagepublic OscMessage(String theAddrPattern)
theAddrPattern
- Stringpublic OscMessage(int theAddrInt)
theAddrInt
- intpublic OscMessage(String theAddrPattern, Object[] theArguments)
theAddrPattern
- StringtheArguments
- Object[]public OscMessage(int theAddrPattern, Object[] theArguments)
theAddrPattern
- inttheArguments
- Object[]Method Detail |
---|
public void clear()
public void clearArguments()
public void set(int theIndex, Object theObject)
public boolean checkTypetag(String theTypeTag)
theTypeTag
- String
/** * oscP5parsing by andreas schlegel * example shows how to parse incoming osc messages "by hand". * it is recommended to take a look at oscP5plug for an * alternative and more convenient way to parse 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() { /* create a new osc message object */ 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 */ /* send the message */ oscP5.send(myMessage, myRemoteLocation); } void oscEvent(OscMessage theOscMessage) { /* check if theOscMessage has the address pattern we are looking for. */ if(theOscMessage.checkAddrPattern("/test")==true) { /* check if the typetag is the right one. */ if(theOscMessage.checkTypetag("ifs")) { /* parse theOscMessage and extract the values from the osc message arguments. */ int firstValue = theOscMessage.get(0).intValue(); float secondValue = theOscMessage.get(1).floatValue(); String thirdValue = theOscMessage.get(2).stringValue(); print("### received an osc message /test with typetag ifs."); println(" values: "+firstValue+", "+secondValue+", "+thirdValue); return; } } println("### received an osc message. with address pattern "+theOscMessage.addrPattern()); }
public boolean checkAddrPattern(String theAddrPattern)
theAddrPattern
- String
/** * oscP5parsing by andreas schlegel * example shows how to parse incoming osc messages "by hand". * it is recommended to take a look at oscP5plug for an * alternative and more convenient way to parse 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() { /* create a new osc message object */ 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 */ /* send the message */ oscP5.send(myMessage, myRemoteLocation); } void oscEvent(OscMessage theOscMessage) { /* check if theOscMessage has the address pattern we are looking for. */ if(theOscMessage.checkAddrPattern("/test")==true) { /* check if the typetag is the right one. */ if(theOscMessage.checkTypetag("ifs")) { /* parse theOscMessage and extract the values from the osc message arguments. */ int firstValue = theOscMessage.get(0).intValue(); float secondValue = theOscMessage.get(1).floatValue(); String thirdValue = theOscMessage.get(2).stringValue(); print("### received an osc message /test with typetag ifs."); println(" values: "+firstValue+", "+secondValue+", "+thirdValue); return; } } println("### received an osc message. with address pattern "+theOscMessage.addrPattern()); }
public void setAddrPattern(String theAddrPattern)
theAddrPattern
- Stringpublic void setAddrPattern(int theAddrPattern)
theAddrPattern
- intpublic void setArguments(Object[] theArguments)
theArguments
- Object[]public OscMessage addArguments(Object[] theArguments)
theArguments
- public String addrPattern()
public int addrInt()
public String typetag()
public long timetag()
public Object[] arguments()
public byte[] getAddrPatternAsBytes()
public byte[] getTypetagAsBytes()
public byte[] getBytes()
getBytes
in class OscPacket
public OscMessage add()
/** * 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()); }
public OscMessage add(int theValue)
theValue
- intpublic OscMessage add(String theValue)
theValue
- Stringpublic OscMessage add(float theValue)
theValue
- floatpublic OscMessage add(double theValue)
theValue
- doublepublic OscMessage add(boolean theValue)
theValue
- booleanpublic OscMessage add(Boolean theValue)
theValue
- Booleanpublic OscMessage add(Integer theValue)
theValue
- Integerpublic OscMessage add(Float theValue)
theValue
- Floatpublic OscMessage add(Double theValue)
theValue
- Doublepublic OscMessage add(Character theValue)
theValue
- Characterpublic OscMessage add(char theValue)
theValue
- charpublic OscMessage add(int channel, int status, int value1, int value2)
channel
- intstatus
- intvalue1
- intvalue2
- intpublic OscMessage add(int[] theArray)
theArray
- int[]public OscMessage add(char[] theArray)
theArray
- char[]public OscMessage add(float[] theArray)
theArray
- float[]public OscMessage add(String[] theArray)
theArray
- String[]public OscMessage add(byte[] theArray)
theArray
- byte[]public OscMessage add(Object[] theArray)
theArray
- Object[]public static byte[] makeBlob(byte[] b)
b
- byte[]
public OscArgument get(int theIndex)
theIndex
- int
public final String toString()
toString
in class Object
public boolean isPlugged()
public void print()
public void printData()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |