Function for Pattern Parsing from OSC

Hello, I have this OSC message which is send to SC and I can map these data with an OSC Function that I have made and I want to do the same in Tidal. While I am not very familiar with the implementation of OSC functions in Tidal, I was wondering if anyone can help with parsing this OSC message as a pattern, the incoming OSC messages come as this below:

{
  address: '/lick',
  args: [
    '943txiiKsnC0gLmoAAAD',
    '{\n' +
      '    "0": "166.00",\n' +
      '    "1": "183.00",\n' +
      '    "2": "149.00",\n' +
      '    "3": "149.00",\n' +
      '    "4": "166.00",\n' +
      '    "5": "183.00",\n' +
      '    "6": "166.00",\n' +
      '    "7": "183.00"\n' +
      '}'
  ]
}

Basically, what I need is to ignore the other parts of the message including the strings and spoof the values for using as patterns ignoring the keys ("0", "1" etc.).

'    "0": "166.00",\n' +
  '    "1": "183.00",\n' +
      '    "2": "149.00",\n' +
      '    "3": "149.00",\n' +
      '    "4": "166.00",\n' +
      '    "5": "183.00",\n' +
      '    "6": "166.00",\n' +
      '    "7": "183.00"\n' +

I couldn't find more info on how to make function for receiving OSC rather than the sending functions in the link of OSC support here (OSC | Tidal Cycles). Obviously and as expected this will through this error in Tidal post window ->

Unhandled OSC: Message {messageAddress = "/lick", messageDatum = [AsciiString {d_ascii_string = "943txiiKsnC0gLmoAAAD"},AsciiString {d_ascii_string = "{\n "0": "166.00",\n "1": "183.00",\n "2": "149.00",\n "3": "149.00",\n "4": "166.00",\n "5": "183.00",\n "6": "166.00",\n "7": "183.00"\n}"}]}

hi!
i don't think receiving OSC messages like this is supported yet in tidal unfortunately, there is some effort going on in restructuring this logic and making it possible in the future, but it will probably take a while.

the only way to get patterns out of OSC messages is to send them to the /ctrl address with a string that functions as a name and the desired value.

maybe an option would be to restructure the messages before sending to tidal - if you are sending from supercollider, this should be easy - if not maybe you can send them to supercollider first, parse them there and send new messages out to tidal.

Hey, I spend a lot of time to learn this, in the difficult way :slight_smile:

It seems that messages cannot be parsed easily, I was aiming for something like this:

n = NetAddr("localhost", 6010);
n.sendMsg('/ctrl', 'speed', Array.fill(4, {rrand(0.1, 1.0).round(0.01)})); //this not okay
n.sendMsg('/unmute', 1); //this okay

-- tidal code
(cP "1 2 3 4" "speed" |/ 0.5)

So what is the right format to send the pattern both in SC and tidal some code appreciated.

K.

could you maybe explain what you're trying to achieve by sending an array to a control parameter? :slight_smile:

tidal doesn't support receiving arrays, so you would have to send each value individually

n.sendMsg('/ctrl', 'speed1',  rrand(0.1, 1.0).round(0.01));
n.sendMsg('/ctrl', 'speed2',  rrand(0.1, 1.0).round(0.01));
etc.

and then use them in tidal like: cF defaultValue "speed1", where defaultValue is some number that will be used if speed1 is undefined

Okay, assuming I have a pattern I want to send to TidalCycles, what is the right format, is it possible to show me the tidalcode? I am not sure the documentation has enough examples and the ones I am trying not working with pattern associations between SC and TC.

well, there is no association between SC patterns and Tidal patterns unfortunately, you can only receive single values on the tidal side, so i don't think what you're trying to achieve is possible like this

Isn't this applicable?

From TidalCyles help: "If you want to receive entire patterns (written as a string of mini notation), use cP".

I wasn't meaning SC patterns but something like converted to be used into TidalCycles using the cP type of OSC. There is no example on using something like this "1 2 3" :: Pattern String.

ahh i didn't know about cP, sorry! it looks like you send a mininotation string to tidal so something like

(
~string = "[";

4.collect { ~string = ~string ++ rrand(0.1, 1.0).round(0.01).asString  ++ " ";};

~string = ~string ++ "]";
)

n.sendMsg('/ctrl', 'speed', ~string);

i'm no supercollider expert so not sure if this is the best way to do it..
but then you should be able to do

let speedPat = cP "speed" :: Pattern Double

and use speedPat anywhere in your code like a normal pattern

Oh nice, thanks.

Is there a way debug or print the incming messages in Tidal?

I use wireshark for this. Note that you have to enable osc_udp in the wireshark settings.