Cabbage Logo
Back to Cabbage Site

Using cabbageGetStateValue for i-rate variables

hi!

First off, just wanna say I’m very new to csound and cabbage, just starting to wrap my head around it, but really enjoying it so far.

So, I’m making a sampler, and I’m coding an array of tall thin buttons to be draggable with the mouse on the x axis so I can use them as markers on top of my soundfiler to set the start times for different notes (like Slicex).

Now, since their position isn’t part of the button widget’s state, I’m trying to figure out the best way to store and retrieve their position, in such a way that when I export this as a VST, it’ll save and recall properly in a DAW.

My first attempt was to use cabbageSetStateValue to store an array of values. But cabbageGetStateValue doesn’t run at i-rate (which I now understand from browsing this forum is for good reason) so any time I change a marker position, my diskin2’s skip time doesn’t actually update until the second time I play a note.

I thought of generating an array of invisible sliders and just keeping their values synced, but that seems like it might add more overhead than is actually necessary?

Or do I need to take a look at reinit?

I figured I’d ask and see if you guys have any thoughts / suggestions that might point me in the right direction.

Thanks!

Can you prepare a minimal .csd file for me so I can take a look?

This might actually work Ok. If you set automatable(0) they won’t show up in the host, so they really will be hidden. It’s a simple hack, but I’ve seen it work perfectly well in the past.

Thanks for the reply! I tried the hidden sliders approach and it seems to work pretty well. Tested in the DAW and state seems to reload just fine, and the markers follow the cursor without much lag.

Here’s what I’ve got. It’s based on one of the example files and there’s not much else going on yet but the slice markers are working.

sliceman.csd (10.2 KB)

That works well :slight_smile: