Parsing OSC message

Hi Everyone,

I have a question regarding a controller that Im making that receives OSC messages.

I have looked around but I don't seem to find any information about how to extract a string argument from an incoming OSC message.

If there is solely an int connected to the message I manage to extract that:

/tracks 1234 (int)

but a message like:

/tracks 1 (int) volume (string) 0.850 (float)

I really don't know how to parse that. I tried with getString but I only got errors.

I use the OSC library from CMAT.

Is there anybody who can help me extract these three arguments or point me in the right direction?

Much appreciated!


Look at the library it has full data extraction commands

You can query for number of data in the OSCMessage (size), the type of fields and extract a given type at a given location.

Hi J-M-L,

thanks for your wisdom!

I managed to get the int and float from my previous message, I’m still struggling with extracting the string.

This is what I have so far:

void routeTone(OSCMessage &msg, int addrOffset ){
char address[255];
int len = msg.getAddress(address, 0);
char str[7];
for(int i=0; i<len; i++)

  • Serial.print(" arg1: ");*
  • int data1 = msg.getInt(0);*
  • Serial.print(data1);*
  • Serial.print(" arg2: ");*
  • char data2 = msg.getString(1, str, 7);*
  • Serial.print(data2);*
  • Serial.print(" arg3: ");*
  • float data3 = msg.getFloat(2);*
  • Serial.print(data3);*
  • //char data2 = msg.getString(1,0,2);*
  • //Serial.print(data2);*
  • Serial.println(" ");*
    Which gives me this output:
    arg1: 3 arg2: a arg3: 0.65
    How can i get “volume” to appear in arg2?

Hi everyone!

This solved it:

Serial.print(" arg2: "); msg.getString(1, str, 7); String data2 = (char*)str; Serial.print(data2);

which library do you use? or