keijiro / OscJack

Lightweight C# implementation of OSC server/client
The Unlicense
475 stars 66 forks source link

Feature request: support for OSC blobs #10

Open ManjitBedi opened 5 years ago

ManjitBedi commented 5 years ago

First, thank you; we have been using your OscJack & it has been really good.

Are there any plans to support OSC blobs?

We are possibly going to send data as a single JSON string per message which could be fine in the short term.

keijiro commented 5 years ago

Okay. I'll consider it.

By the way, do you know any application that uses OSC blobs? I can test the functionality with a primitive test program, but it's better to test with a practical application.

ManjitBedi commented 5 years ago

I know you must be a busy man; we are also using your Spout plugin for Unity.

What is happening is, we are using a 3rd party SDK called NUITrack with web cameras & depth sensors to detect people & then send the detected body poses as OSC messages to other applications like Touch Designer & the Unreal engine. Sending the data as OSC messages can result in 60+ messages per person per frame. It is not an efficient transport architecture but it works.

The people who commissioned the project are more animators & visual artists & not software developers; they are able to use OSC message in their projects.

Using a blob could reduce sending 60 messages to sending maybe 2 or 3 messages per frame.

But it could be combining the data into a JSON string will also work but then there is the limitation of the string size to being 1500 bytes. I am currently developing code to use JSON strings with your OSC plugin.

I may be able to help with the development of the blob feature depending on your schedule & mine.

Thanks for replying so promptly.

keijiro commented 5 years ago

But it could be combining the data into a JSON string will also work but then there is the limitation of the string size to being 1500 bytes.

As far as I know, there is no well-defined limitation on OSC string length. "1500 bytes" limitation might come from the UDP layer.

http://opensoundcontrol.org/topic/247

It means that those meesages will be limited to 1500 bytes even if you use a blob message.

Blob support would be a nice-to-have, but for your specific case, I'd recommend splitting JSON into multiple strings and send them with string messages.

spee commented 3 years ago

As a follow-up to this; I'm also trying to receive more than 4 values in a single package because, in a similar setup as OP, we also track users. We don't transmit an entire pose, but just a packet with ID, x, y, z, width, height. Do I understand correctly from the docs that I'd need to send multiple message in order to receive all 6 values?

spee commented 3 years ago

I've tried and it turns out that, in the dispatcher callback, I'm able to read more than 4 values from the OscDataHandle:

server.MessageDispatcher.AddCallback(
    address,
    (string address, OscDataHandle data) => {
        Debug.Log(string.Format("(ID: {0} / POS: {1}, {2}, {3} / SIZE: {4}, {5})",
            data.GetElementAsInt(0),
            data.GetElementAsFloat(1),
            data.GetElementAsFloat(2),
            data.GetElementAsFloat(3),
            data.GetElementAsFloat(4),
            data.GetElementAsFloat(5)));
    }
);

So I'm just not sure why the OSC Server Class docs say "Just like the client class, it supports int, float and string types, and capable of receiving up to four elements within a single message."