I am trying to control DMX lights via OSC from Sonic Pi. I have installed the OLA daemon and I manage to get my OSC messages through, like so:
use_osc "localhost", 7770
osc "/dmx/universe/1/25", 250
This sets a single slot to a specific value. There is basically one problem: DMX is very bad at handling messages this way. In order to control one device several slots have to be set, I want to control several devices, and the messages have to be padded, resulting in very many and very inefficient datagrams. It’s best to send messages to DMX devices as blobs. OSC supports blobs, and I gather so did Sonic Pi. In the code I find 2 significant references to OSC. The change log says for the 3.2.0 ‘Tau’ release: »The
osc fn now forces all outgoing args to either be numbers or strings (binary blobs and timestamps are not supported at this point).« So, I understand there had been support for blobs before and dropping it was intended.
Then, osc.erl does seem to carry all that is needed to encode blobs. There is
encode_binary and a switch for the data type with a
when that calls it (
encode_arg(X) when is_binary(X) -> encode_binary(X).). However, I complete fail to see if this is still the code that is actually used. It is part of the Tau stuff in the end. Also, I wouldn’t know how to modify it to get OSC support back.
Any hints on how to go about getting OSC blobs to work are very welcome. I’d also appreciate any suggestion for code modifications. Especially, if there is a specific reason for dropping OSC blobs from SP then I’ll be happy to make some (suggested) modifications and build my own.
Also, have I chosen the wrong approach? Is there a better way to control DMX from SP, maybe just writing to
Finally, I’d welcome suggestions on how to create byte arrays in SP. I wonder if something like this is the right way:
[112, 220, 17].pack('C*').