thomasfredericks / MicroOsc

MicroOsc is a minimal Open Sound Control (OSC) library for Arduino
MIT License
16 stars 2 forks source link

Unable to send argument-less message #9

Closed sofian closed 2 months ago

sofian commented 4 months ago

It would be useful to be able to simply send a message with no arguments such as "/bang". Right now I am unsure how this could be done with the current API -- I don't think it can.

I think the most intuitive would just be to overload the send() function: myMicroOsc.send("/bang");

thomasfredericks commented 4 months ago

The OSC 1.0 specification does not give an example for a "/bang" type of message other than the OSC type tag N for "Nil. No bytes are allocated in the argument data."

I do not know if that type is really supported in OSC enabled software.

To follow the naming convention of the other methods, it should probably be :

myMicroOsc.sendNil("/bang");

sofian commented 4 months ago

According to the 1.0 specs "An OSC message consists of an OSC Address Pattern followed by an OSC Type Tag String followed by zero or more OSC Arguments." So it looks like it is possible to have "zero" arguments.

There is indeed a "N" (nil) type which allows no arguments but for "bangs" it looks like the appropriate type would be "I" (Infinitum) (see https://www.nime.org/proceedings/2009/nime2009_116.pdf) It was renamed Impulse: (aka “bang”) in 1.1 "used for event triggers. No bytes are allocated in the argument data. This type was named “Infinitum” in OSC 1.0 optional types."

My feeling is that these types (N and I) are rarely used and they are not required if we are simply able to have "zero" arguments like the 1.0 specs seem to suggest. I feel like a "sendNil" and "sendInfinitum" functions would not be that useful in practice. If we are indeed able to send "zero" arguments according to 1.0, then I just find that a function allowing us to send zero arguments would be appropriate. Perhaps overloading the sendMessage() function would make sense.

sofian commented 4 months ago

Other options:

thomasfredericks commented 4 months ago

If we look into OSC 1.1, microOsc.sendImpulse("/bang") seems to be safest and at least documented. Having no type tag was indeed supported by previous OSC versions but is definitely frowned upon in new OSC versions.

An OSC message consists of an OSC Address Pattern followed by an OSC Type Tag String followed by zero or more OSC Arguments.

Note: some older implementations of OSC may omit the OSC Type Tag string. Until all such implementations are updated, OSC implementations should be robust in the case of a missing OSC Type Tag String.