Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving OSC bundle messages is cumbersome #2085

Open
korfuri opened this issue Jun 10, 2019 · 14 comments
Open

Receiving OSC bundle messages is cumbersome #2085

korfuri opened this issue Jun 10, 2019 · 14 comments

Comments

@korfuri
Copy link
Contributor

korfuri commented Jun 10, 2019

Hi, I'm trying to use OSC to receive messages in Sonic Pi. Specifically I'm sending these messages from VCV Rack using the Trowasoft modules in a way described here. I'm facing a small issue that make the experience slightly annoying. I'm not sure whether the issue lies with Sonic Pi, Trowasoft's implementation of OSC, or a mix of both.

I'm running a 3.2.0-dev build from commit ab31ae0 built with the ubuntu-18.04 script on Linux Mint (based on Ubuntu bionic). Receiving remote OSC messages is enabled.

Trowasoft's implementation sends all OSC messages as bundles. I don't know if that's bad, from my reading of the OSC docs it sounds like recipients should understand it just fine. But Sonic Pi shows the received messages as /osc:127.0.0.1:35042/#bundle [] in the cues list, and indeed trying to unpack the values using sync gives me an empty array ([]). From this it seems that Sonic Pi is just treating the bundle as an opaque blob and doesn't unpack the values inside. This means that all I can get is a cue that a bundle was received, without added info, and without a way to distinguish what path(s) the bundle contains.

Example code I'm using:

live_loop :receive do
  use_real_time
  use_osc_logging true
  voltage = sync "/osc:*/#bundle"
  print voltage   ## always prints `[]`
end

I've tried syncing on /osc:*/*, /osc:*/ch/1 (the path I'm sending to from VCV Rack), and variants of that to no avail.

I think ideally the bundle should be expanded (recursively if needed, as the spec says a bundle can contain other bundles) and each OSC message in the bundle should be processed as an incoming message from the same source as the parent bundle.

@llloret
Copy link
Collaborator

llloret commented Jun 10, 2019 via email

@korfuri
Copy link
Contributor Author

korfuri commented Jun 10, 2019

Thanks! I was under the impression that the OSC decoding was done in app/server/ruby/lib/sonicpi/osc/oscdecode.rb (which definitely has no bundle support). I've opened llloret/osmid#54 to track the issue on the osmid side, with a pcap.

@ethancrawford
Copy link
Collaborator

I'm not fully across all the details, so this may not be thoroughly relevant, but are the following comments about fast_osc's capabilities related? https://github.com/samaaron/sonic-pi/blob/master/app/server/ruby/vendor/fast_osc-0.0.12/README.md#usage

@llloret
Copy link
Collaborator

llloret commented Jun 10, 2019 via email

@llloret
Copy link
Collaborator

llloret commented Jun 10, 2019

@ethancrawford, yes, I think you are right. This is being processed in Sonic Pi, osmid has nothing to do with it.
Apologies for the confusion.

@korfuri
Copy link
Contributor Author

korfuri commented Jun 10, 2019

I'm sending OSC over UDP to Sonic Pi from another application running on the same machine. There's no MIDI involved, so I agree with you that this doesn't look like it's going through osmid. Thanks for looking into it anyway :)

@ethancrawford thanks for the pointer. The doc is about encoding, not decoding, but it looks like a promising place to look. That the bundles I'm interested in have a single message inside of them (at least for now, I don't know if the source I'm using is able to send bundles with more than one message). Here's a pcap of such a bundle: https://packettotal.com/app/analysis?id=82ea8bf5e82110cde3d832f05976f76e

It looks like the file I found is a copy of fast_osc's decoder, which does not support bundles for decoding (and per the doc above, only has partial support for encoding). However I don't know Ruby well at all so I may be missing something.

@samaaron
Copy link
Collaborator

Yes, unfortunately we don't currently support receiving OSC bundles at this stage. Were you using them in an attempt to schedule events for the future or attempting to have multiple messages be executed simultaneously?

@korfuri
Copy link
Contributor Author

korfuri commented Jun 10, 2019

The latter: this is all real-time, and my sender is packaging everything in bundles (even when it's sending a single value). I have no need for future-time bundles.

I've opened j4s0n-c/trowaSoft-VCV#35 to see if they can remove the unnecessary bundling but I think the more proper fix would be to support bundles in Sonic Pi since they're part of the OSC spec.

@samaaron
Copy link
Collaborator

@korfuri

Agreed, it would be lovely to support OSC bundles natively in Sonic Pi. However, it's not a majorly high priority for me right now (as it's not a trivial fix). Instead, I'm working on getting 3.2 out of the door which still has a lot of work left - especially with the Windows building process.

Happy to consider pull requests though!

@korfuri
Copy link
Contributor Author

korfuri commented Jun 11, 2019

Thanks, I did try my ruby-fu against that problem. I managed to get what looks to me like a reasonable patch in #2086 for the Ruby implementation of fastosc. I have not looked into porting the change to the C version yet either, because I'm in very unfamiliar territory here so I figured I'd request some feedback before continuing:

  • Does this approach look good to you? The main issue I see is that I'm changing fastosc's API.
  • Where should I send fastosc contributions? I assume they should go to fastosc's repo directly but I don't know where that is.

If I should proceed I'll take a stab at fixing and adding relevant tests, and at changing the C extension.

Thanks!

@ethancrawford
Copy link
Collaborator

ethancrawford commented Jun 11, 2019

@korfuri - fast_osc comes from https://github.com/xavriley/fast_osc 🙂
(Edit - ahaha. Just saw your comments on your related PR - you were guessing correctly).
/cc @xavriley

@llloret
Copy link
Collaborator

llloret commented Jun 11, 2019 via email

@korfuri
Copy link
Contributor Author

korfuri commented Jun 11, 2019

@llloret - wonderful, thank you! I have no issues waiting, in the meantime I can just run my own fork and force it to use the Ruby version :)

I'm closing the PR now, I assume you'll merge that same code directly into @xavriley 's repo with your C changes.

@xavriley
Copy link
Collaborator

Luis' PR is in xavriley/fast_osc#3

@korfuri For the pure ruby version (#2086) I'm happy to look at patches into fast_osc directly but I'd rather create a new method like FastOsc.decode_bundle and also FastOsc.bundle? than change the existing API if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants