Previous topicNext topic

Strings via OSC

Questions, comments, feedback, etc.
Post Reply
mhite
Posts: 3
Joined: Sun Aug 28, 2022 6:52 pm

Strings via OSC

Post by mhite »

Hello. I'm learning my way around Magic currently. I'm impressed!

One question I have: Can I receive a string value via OSC? I would love to have an OSC-received strings appear in a text module. Currently, it does not appear the text module supports selecting an OSC source.

Similarly, in modules that do support OSC sources, it appears that only float values are supported.

Am I correct?

I'd also love to be able to receive binary blobs via OSC, ie. image files. Alternatively, being able to receive the image via an OSC string and then performing a base64 decode into an image would be very handy.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Strings via OSC

Post by Magic »

Yes, unfortunately only floats are supported.
mhite
Posts: 3
Joined: Sun Aug 28, 2022 6:52 pm

Re: Strings via OSC

Post by mhite »

Magic wrote:Yes, unfortunately only floats are supported.
Gotcha.

To appropriately trigger, say, a File Reload for an image, through some trial and error I discovered I need to orchestrate the following:

Send a float 0.0
Wait
Send a float 1.0
Wait
Send a float 0.0

I do experience occasional dropped OSC messages though, even when wait was 70ms. My understanding from a prior thread in the forum is that currently you need to make sure to pace your OSC messages at least 1 frame time interval apart.

I was hoping to just send them serialized as an OSC bundle to avoid this. I played with this for a bit but honestly I'm not sure Magic supports bundles. Still trying to ascertain that. Anyone know?

Is there a way for me to send an OSC float to the file reload action that can be used as part of the filename to reload? There's a bit of a data race otherwise in that Magic might try to reload a file that is being regenerated for the next message it is about to get a notification for.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Strings via OSC

Post by Magic »

You can think of a trigger as a button press, where pressing the button down sends a 1, and releasing the button sends a 0. If I remember correctly, it is actually the release of the button which causes the trigger to activate.

If you are running at 60fps, then there would have to be a minimum delay of 16ms (1000/60) between those two messages. But it's probably safer to do a higher delay, especially on wi-fi (vs wired). It really depends on your network reliability. We never recommend using wi-fi for anything critical.

Bundles are not supported.

The problem with the filename thing is that reloading a file takes an indeterminate amount of time. Is there some other solution you can come up with, such as switching between modules?
mhite
Posts: 3
Joined: Sun Aug 28, 2022 6:52 pm

Re: Strings via OSC

Post by mhite »

Magic wrote:You can think of a trigger as a button press, where pressing the button down sends a 1, and releasing the button sends a 0. If I remember correctly, it is actually the release of the button which causes the trigger to activate.
Excellent, thanks for the clarification.
Magic wrote:If you are running at 60fps, then there would have to be a minimum delay of 16ms (1000/60) between those two messages. But it's probably safer to do a higher delay, especially on wi-fi (vs wired). It really depends on your network reliability. We never recommend using wi-fi for anything critical.
Yup! Definitely aware that running UDP on top of Wi-Fi (due to the nature of CSMA/CA networks) is fraught with peril. For my tests, everything is running through a wired, switched network.
Magic wrote:Bundles are not supported.
Thanks for the clarification. If there is no bundle support, it sure would be nice to have an atomic way of triggering these consecutive button press/depress reload events through one OSC packet.
Magic wrote:The problem with the filename thing is that reloading a file takes an indeterminate amount of time. Is there some other solution you can come up with, such as switching between modules?
I'm not 100% sure -- I'm still learning my way around. In my use case, I have software running which monitors what track a DJ is currently playing. As they transition to a new track, the track artwork and artist/song title information are written to the filesystem. When this transition happens, I also fire the reload events to Magic so the image and file modules can re-read their data. Because the file name of the track art and artist/track information re-use the same filenames, there are all sort of silly race conditions that can happen potentially.

I've been playing with the vinyl record spinning example visualizer -- I have the center of the record dynamically showing the song album art and then some text on the screen also showing the track title/artist. As the DJ transitions between songs, these automatically change.

You can kind of see in this screenshot:
vinyl
vinyl
Screen Shot 2022-09-03 at 10.21.34 AM.png (822.07 KiB) Viewed 3069 times
PS. You can get a feel for the software here, btw.

https://www.djctl.com/blog/djctl-in-action/
Post Reply