sojamo / oscp5

An Open Sound Control (OSC) implementation for Java and Processing
GNU Lesser General Public License v2.1
132 stars 51 forks source link

feature request: decoding an OscMessage from a byte[] #11

Closed orgicus closed 6 years ago

orgicus commented 6 years ago

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

sojamo commented 6 years ago

Hi George, there is another osc library that I have been working on which contains a function bytesToMessage that does what you are looking for (a working gist example) it takes a byte array and returns an OscMessage. I can carry it over to oscP5 in a future release, but as you can tell from my last commit I haven't made updates to oscP5 for a while.

orgicus commented 6 years ago

Hi Andreas,

The resources you've shared are extremely useful. Initially I tried to hack my way through it, but realised there is a conflict between sojamo.osc's OscMessage and oscP5's OscMessage. I'll switch the whole osc part to sojamo.osc to keep it consistent.

Thank you very much for the support, George