Cabbage Logo
Back to Cabbage Site

Two UDOs setting different parameters on same identchannel creates issues (resolved)

This might be a cabbage limitation, or it might be a bug… but either way I came across this odd behavior.

I have two UDOs, one sets visible(%d) on widgets, and the other sets text(%s). Using either opcode on it’s own works like expected… but using both opcodes creates an issue, and the visible() change no longer seems to take effect.

Here’s an example. “Mode 1” should have three visible sliders labeled 1 2 and 3, “mode 2” should have two visible sliders labeled A and B. If you comment out the second opcode calls to setslidertext (lines 45 and 49), the visibility will work again.

vis_text_test.csd (1.6 KB)

What’s happening here is that your instrument sends a to a visible() string to the channel, and then in the same k-cycle it sends a text() string to the same channel, thus overwriting the previous string. If you were sending the next string in the next k-cycle things would work fine but because it’s going in the same k-cycle it will be overwritten. I’ve done this a few times myself and wondered why it’s not working, but if you think about in pure Csound code you see the obvious problem. It’s akin to doing something like this:

instr 1
kVal = 1
chnset kVal, "channel"
kVal = 2
chnset kVal, "channel"
endin

It’s clear that “channel” will only ever be 2. Perhaps your UDOs could return strings that you could then concat into a full line of Cabbage text that can be sent in one go. Or I’m sure you can probably think of other ways around this too.

I had a feeling it might be an oddity like that rather than a true bug, but I couldn’t quite put my finger on it. Thanks for helping nail that down.

I was trying to avoid having one monolithic opcode with a billion inputs, but that might just be the easiest way. I’ll try a few options and see what I like best for my use case.

If yo come up with something useful maybe you can post to the Cabbage recipes sections. I think that’s a good place for sharing useful snippets of code and UDOs.