OSC flattening array?

Hi. From a program I’m sending data in this form to Sonic Pi via OSC:
[300.0, [48, 57, 52, 62, 50, 67, 60, 72, 55, 64, 69]]
It’s a tempo and an array of notes.

Oddly, in Sonic Pi the array seems to be flattened, and I process it like this:

  with_bpm args[0] do
    notes = args[1..-1]
    play_pattern notes
  end

Is this how things are supposed to be?

1 Like

Hi @dcbriccetti,

unfortunately the standard OSC spec doesn’t supported nested data structures (http://opensoundcontrol.org/spec-1_0). There was talk of extensions to support this but I’m not aware of anything that’s gathered any steam.

With regards to your situation, it’s quite possible that the OSC library used by the program you’re sending data from is flattening this data prior to encoding it in the OSC binary format.

The code you’ve written looks lovely to me :slight_smile:

BTW, I’m intrigued. What’s your bigger plan with this project? It looks interesting…

Sam, thanks for the explanation.

Here’s an explanation of the program.

For the junior high students I teach during the school year, I’m trying to blend visual and musical things with computer sciencey stuff, like how data is represented, binary, ASCII, Unicode, RGBA; sorting, etc.

Dave