Norns: sending an array of numbers from lua to sclang

Hi

I figured out it’s possible to register your own OSCFunc in sc (within subclassing of CroneEngine) then in Lua script use:

osc.send_crone(path, args)

however, the args above needs to be of string type…

Can one send array of floats from lua to sc?

Thanks!

y

trying to get the values from these sent to sc:

There may be a smarter way to do this, as I have very little experience with both languages, but my first instinct is to make your Lua script send a string containing space-separated floats and have your SC script parse that back into floats (assuming SC can do something like string.split()).

thanks Ben.

yeah, that’d be possible but osc, by specification is able to communicate floats… so i’d like to avoid the parsing ping-pong if possible.

ok, so osc_send_crone it looks like it’s a C function call defined in:
~/norns/matron/src/osc.c

It’s a bit silly but… I did;

this.addCommand(\ping, “ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff”, { |m| });

to send 64 values of float.
it works.

m.class.postln // -> Array
m[1].class.postln // -> Float

1 Like

you can do that, but float arrays aren’t really supported r/n

you can also use “blob” type and do your own packing/unpacking

thanks.

i did the following:
engine.ping(table.unpack(x))

how do you specify ‘blob’ type in lua exactly?
btw, i couldn’t just do unpack(x) which i guess has to do with lua’s version being not the newest?

btw, it is working. thanks to everybody;

3 Likes

oh shoot, i apologize, we didnt actually implement a blob case in osc_send.

would probably add a case here to handle tables:
[ https://github.com/monome/norns/blob/master/matron/src/weaver.c#L948 ]

but then we have to ask whether to send tables as raw byte arrays, or do some kind of packing of numbers automatically. (kind of ugly either way, hence not done i suppose.)

right. and there is a limit to the size of what you can send via single udp packet. so i guess what we have already pretty much serves the purpose (sending relatively small data from lua to supercollider)! thanks for the clarification;)