sojamo / oscp5 Goto Github PK
View Code? Open in Web Editor NEWAn Open Sound Control (OSC) implementation for Java and Processing
License: GNU Lesser General Public License v2.1
An Open Sound Control (OSC) implementation for Java and Processing
License: GNU Lesser General Public License v2.1
It would be helpful to have this package in Maven to include as my project as a dependency. I can find this listed in maven however when I try to get Maven to download dependent packages it can't seem to find this one. I dug in a bit further, though there is a Maven page for this project I can't seem to find this dependency hosted anywhere on internet. It would be much appreciated if you could republish the Maven package for people to use in their projects.
Thanks
Hi, I am not getting proper timetag with OSC bundle. Sender timetag differs to recieved timetag() extracted from OSC message.
Minimal code example:
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup() {
size(400, 400);
frameRate(60);
oscP5 = new OscP5(this, 12000);
myRemoteLocation = new NetAddress("127.0.0.1", 12000);
}
void draw() {
background(0);
}
void mousePressed() {
OscBundle myBundle = new OscBundle();
OscMessage myMessage = new OscMessage("/test");
myMessage.add("abc");
myBundle.add(myMessage);
long ts = System.currentTimeMillis();
println("timetag send: "+ setTimetag(ts)+" millis: "+ts);
myBundle.setTimetag( System.currentTimeMillis() );
oscP5.send(myBundle, myRemoteLocation);
}
// incoming osc message are forwarded to the oscEvent method.
void oscEvent(OscMessage theOscMessage) {
println("timetag recieved : "+ theOscMessage.timetag() );
}
long setTimetag(long theTime) {
final long secsSince1900 = theTime / 1000;
final long secsFractional = ((theTime % 1000) << 32) / 1000;
long l = (secsSince1900 << 32) | secsFractional;
return l;
}
This produces:
When creating the OSC message:
timetag: 7231581490502040551 millis: 1683733773069
When the message is recieved:
timetag : -1727627929977226265
Why there is a negative sign? In what format is the timetag? Why is it not the same when setting it?
Can you clarify please? Thanks!
I am using the oscP5 library. I want to set a server from my computer(macosx) and I want other computers to connect to my server. Since the ip address is constantly changing I thought it would be better to put the name of my machine instead.
this is the client code :
myBroadcastLocation = new NetAddress("MyName-MacBook-Pro.local", 32000);
I already tested this way between macs and it works perfectly. Now I'm wondering if it also works if the client is windows?
I'd like to reconnect a TCP client (in oscP5) to a TCP server (scsynth).
I am unsure how to get there, though I found that there is a reconnect
method in TCP server but I don't know
TCPClient
instance from an oscP5 object instantiated viaoscP5 = new OscP5(this, "127.0.0.1", 57110, OscP5.TCP);
Hello,
I'm trying to work with Processing and Pure Data using OSC Protocol . Looking for some examples in "basic" folder I found the osc.send parameters are wrong osc.send( receiver , "/test" , random( 255 ) , random( 255 ) , random( 255 ) );
and the sketch does not run.
In the example sketches on OscP5 website the object osc.send present different parameters oscP5.send(myMessage, myRemoteLocation)
.
Am I doing something wrong?
Thanks!
There is a bug in the method parseBundle()
in OscPatcher where you choose the wrong data map. Instead of the one you just split, you take the bundle map:
...
m0.put( "data" , Bytes.copy( bytes , myPosition , myMessageLength ) );
m0.put( "socket-ref" , m.get( "socket-ref" ) );
m0.put( "socket-address" , m.get( "socket-address" ) );
m0.put( "socket-port" , m.get( "socket-port" ) );
m0.put( "local-port" , m.get( "local-port" ) );
messages.add( new OscMessage( m ) );
...
So it should be:
messages.add( new OscMessage( m0 ) );
Took me some hours to notice this bug.
Cheers Florian
Hello,
I'm trying to find a way to know if OscP5 managed to connect to the provided listening port (meaning that if the port has already been claimed by another application and I won't receive anything I want to know it).
The lib doesn't output any error in that case and I couldn't find any method/variable containing this information.
Did I miss something or is this feature absent from the lib ?
Thanks
I tried to receive an OSC Bundle but instead of getting an OSC Bundle, I just receive the messages in the bundle. So the method void oscEvent(OscMessage theOscMessage)
is called multiple times.
Is there something I am missing?
In a C# OSC library I receive the data like this which is way more intuitive:
Cheers Florian
Hello, I try to make a pullrequest but like usual I fail.
My suggestion is add method to the class OscArgument, to manipulate this one easily:
public Object get() {
return value;
}
public String getTypetag() {
if(value instanceof Integer) return "i" ;
else if(value instanceof Float) return "f";
else if(value instanceof Charracter) return "r";
else if(value instanceof String) return "S";
else if(value instanceof Double) return "d";
else if(value instanceof Long) return "l";
else if(value instanceof Boolean) return "b";
else if(value instanceof byte[]) return "byte array or blod value";
else return "Midi value";
}
When I try to send many OSC messages at once, it seems the oscEvent method only listens to some of the messages (around anywhere between 20 and 50 out of around 200) so and disregards the rest.
Below there is quick code to test this on Android. When run on a device this will print to the run console all incoming OSC messages. here it is showing only 27 messages captured by the oscEvent method:
I am sending 200 messages each with a unique address (loading a preset on a computer, this preset should update all the parameters on the Android device).
Steps to recreate:
1 - Run below code on Android device
2 - Update preset on OSC capable music synthesizer vsti plugin on the computer
Expected result: all addresses and messages caught by oscEvent method and logged in run console.
Actual result: only a fraction of the messages are caught.
Using network sniffing with Wireshark, I can confirm that the source is sending all these messages and Wireshark is picking them up in an orderly fashion:
Quick testing code:
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import netP5.NetAddress;
import oscP5.OscMessage;
import oscP5.OscP5;
public class MainActivity extends AppCompatActivity {
int evenCount = 0;
OscP5 oscP5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
oscLink();
}
void oscLink(){
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
oscP5 = new OscP5(this,9000);
}
public void oscEvent(OscMessage theOscMessage) {
evenCount = evenCount + 1;
System.out.println(" addrpattern: " + theOscMessage.addrPattern());
System.out.println(" typetag: " + theOscMessage.typetag());
System.out.println(" msg: " + theOscMessage.get(0).intValue());
System.out.println(evenCount);
}
}
Hello,
I try to send message, but I found a different limit for each type of argument.
That's depend of my computer or it's a limit of the OSC ? It(s possible to increase this limit ?
Or don't stop Processing and just limit the the size of the package must be sent and print a warning to inform the user ?
and thx for your work.
Processing 3.3.4 OS Sierra Osc 2.0.4
String limit 1524 java.lang.ArrayIndexOutOfBoundsException
Array float limit 1842 Could not send datagram java.net.SocketException: Message too long
Array int limit 306 java.lang.ArrayIndexOutOfBoundsException
Boolean limit 9207 Could not send datagram java.net.SocketException: Message too long
Here the little sketch I code to find the limit.
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
// OscP5 osc_receive_controller ;
void setup() {
size(400,400);
/* start oscP5, listening for incoming messages at port 12000 */
int port = 10_000 ;
oscP5 = new OscP5(this,port);
myRemoteLocation = new NetAddress("127.0.0.1",port);
}
void draw() {
background(0);
send() ;
}
int count_send = 0 ;
String string_limit = ("");
void send() {
count_send++ ;
OscMessage myMessage = new OscMessage("test");
/*
string_limit = string_limit + "a" ;
myMessage.add(string_limit); // add an int to the osc message
println("String limit", string_limit.length()) ;
*/
boolean [] bool_limit = new boolean[count_send];
for(int i = 0 ; i < bool_limit.length ; i++) {
bool_limit[i] = true ;
myMessage.add(bool_limit[i]); // add an int to the osc message
}
println("Boolean limit", bool_limit.length);
/*
int [] array_int = new int[count_send] ;
for(int i = 0 ; i < count_send ; i++) {
// array_int[i] = floor(random(MAX_INT)) ;
array_int[i] = i ;
}
myMessage.add(array_int); // add an int to the osc message
println("Array int limit", array_int.length) ;
*/
/*
float [] array_float = new float[count_send] ;
for(int i = 0 ; i < count_send ; i++) {
// array_int[i] = floor(random(MAX_INT)) ;
array_float[i] = i ;
}
myMessage.add(array_float); // add an int to the osc message
println("Array float limit", array_float.length) ;
*/
/*
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);
}
in oscEvent I get "/192.168.1.133" instead of "192.168.1.133"
also OscMessage.netAddress() returns a variable that is not working as destination endpoint.
Hello there,
On OSX, when using oscP5 in Processing, OSC stops after a while when the application is in the background (i.e. not focused). It does sucessfully resume when you click on the window.
Is it a normal behaviour and is there anyway to prevent this behaviour ?
It seems to happen only on OSX.
If you want to give a try with our app : https://github.com/Theoriz/Augmenta-Simulator
Best,
David C.
Hello, thank you for this great library.
I have the case where 2 processing applications running on the same computer need to receive messages on the same UDP port.
In my test with current version only the first application launched receives the messages.
In other cases using an artnet library in processing I was able to receive UDP messages on the same port. It might relate to an option to "reuse" the socket address. I think that the artnet library does it in this point:
https://github.com/cansik/artnet4j/blob/c923f4bd01e89d8912515d38407f6a875944f04a/src/main/java/ch/bildspur/artnet/ArtNetServer.java#L170
Is there a similar option in ocsP5?
Thank you
Marco
Hi,
First off, thank you for sharing this awesome library!
I was wondering if it's possible to construct an OscMessage
from a byte[]
(essentially decode a byte[]
of valid OSC bytes for a message). I haven't found anything in the library yet.
Would it be possible to have an extra constructor or a static method that takes in a byte[]
and returns the decoded OscMessage
?
At the moment my workaround is to create an OscP5
instance and a NetAddress
instance using the same port to flush
the byte[]
to the same sketch so it gets decoded into an OscMessage. It works, but I'm hoping there's a simpler/more elegant way ?
Thank you very much,
George
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.