First time here? Check out the FAQ!
x

How to parse incoming OSC messages of unknown length?

+1 vote
45 views
My main use case is sending an array of either all integers or all floats from an external OSC client.  Up until now I've been preformatting blank OSC datatypes of a constant length, using formatted argument placeholders with the technique used in NELab's OSCTools, to receive incoming OSC messages with an arbitrary number of arguments (up to the predetermined constant as max length), as an alternative to using a true array type (not sure if that is possible yet here).

Can anyone recommend another way to do this, so that incoming collections of OSC values can be treated like an array, whose length is not known ahead of time? (i.e. not totally free separate messages unless they were all contained in a parent bundle or packet).
asked Nov 30 in Controllers, OSC & MIDI by thom-jordan (Practitioner) (600 points)

1 Answer

+2 votes

The Paca(rana) can receive arrayed OSC messages; that is, you can send an array of floats using a single OSC message. You can map the individual values of that message in the VCS, or you can refer to an individual value in a Capytalk expression.

For example, if the OSC message was /value,fffff 0.0 0.1 0.2 0.3 0.4  then you could refer to the individual parts as:

!osc_value__1 !osc_value__2 !osc_values__3 !osc_value__4 !osc_value__5

One simple way to work with these values would be to use !osc_value in your Sound and use a Replicator with a suffix of "__1" to rename that control so that each replica would be using a different value from the OSC message.

Since the number of copies that the Replicator creates is determined at compile time, you would set the number of copies to the maximum you expected. Then you could use a separate OSC message (for example /count,i) that indicated how many values were in the message and make decisions based on that.

For example, in the Sound being replicated, you could do something like:

(!osc_count ge: ?VoiceNumber) true: !osc_value false: 0

to provide a default value (or to turn off the output of a Sound) when too few values were supplied.

answered Nov 30 by ssc (Savant) (81,800 points)
Interesting approach! Right now I wish to populate a sequencer with note and control data directly from OSC. I have an existing version that works well enough, but retooling it using this kind of approach should offer more flexibility and perhaps some improved performance. I'll let you know how it goes.. Thanks !
How to construct Kyma-fied OSC syntax using 'variable' names?
...