Program Changes to OSC Messages

lydian91's icon

Numerous errors in here no doubt, but I hope my intent is clear enough. I'm trying to merge program changes and coll data into OSC messages.

So for example, if the patcher were to receive PC 128 on channel 6, the resulting OSC message would be "/instance/0/strip/11/enable 1"—that's the goal at least.

An additional problem is that if the patcher receives multiple program changes simultaneously, it processes them fine, but the application downstream of Max that's receiving the OSC messages can't handle them simultaneously. So I also need a way to space them out in 10-20ms intervals without dropping any messages. I imagine this would be easier to set up after pgmin rather than after sprintf.

Max Patch
Copy patch and select New From Clipboard in Max.

TFL's icon

Your order of operations is wrong, because of cold/hot inlets: your OSC message will be formed with an enable state from the current program change message and the coll content from the previous message. I used [join @triggers 1] to fix that.

Also, no need unpack what you just packed in your case.

I also added a small FIFO mechanism: incoming messages get stored in a [coll], and as long as there is stored messages, they get output and removed at a given rate until there is no more left. But obviously this will create some kind of latency if you are receiving a lot of program change messages, so this is is probably not a good idea.

I purposefully set the output interval to 100ms so you can visualize what is happening.

Max Patch
Copy patch and select New From Clipboard in Max.

Here is the fixed version of your patch without the FIFO:

Max Patch
Copy patch and select New From Clipboard in Max.