Building dynamically OSC Addresses
Opened this issue · 1 comments
Hi there,
nice Library ;)
I found it is not possible to build an OSC Address in a For-Loop with string operations.
Example: "/Test_" + String(i) -> not working
Also:
NewOSC = "/Test_" + String(i)
NewOSC will also throw an error
Would be nice to have the possibility to build the OSC Addresses more dynamically.
I have to build 32 OSC Addresses in a sketch and I have to use a case-switch.
Cheers
HI,
In issue #6 I helped a user with something very similar.
MicroOsc does not support String
objects, you must convert them to C strings. That is the error you are getting.
But, to generate a String
objects on the fly is very common for computer code, but not recommended on a micro-controller for memory fragmentation and speed issues.
Here are some of my recommendations to improve the speed and reliability of OSC parsing code:
-
Move as much as possible of the address pattern to the arguments. For example, instead of using the address
/channel1/pot3
with ani
argument for its value, you should use/pot
withiii
arguments (one for the channel number, one for the pot number and a final one for the value). This is much faster! -
For more advanced users, I created new advanced methods to copy the address and type tags. You can split (i.e. tokenize) the address to then build a conditional strcmp() decision tree from there. Here is an example on the new methods and how to tokenize : microosc_slip_copy-address-and-typetags.ino