Cabbage Logo
Back to Cabbage Site

Dynamically updating slider range possible?

I’m having some trouble figuring out what’s happening here. Maybe Rory or someone can chime in.

I have a slider that needs its max range updated based on the size of the sample in the buffer. As far as I can tell it is being updated at i-rate but it behaves as if it’s at k-rate?

I’m declaring it like this:

rslider bounds(150, 250, 60, 60), channel("Placement"), text("PLACEMENT"), identchannel("placementIdent"), range(0.001, 3, 2, 1, 0.001), $KNOB1, trackercolour(25, 181, 254)

And updating it like this

itablelength = ftlen(giRecBuf1L)

imaxlength = sr/itablelength
SPlacementRange sprintf "range(0.001, %f, %f, 1, 0.001)", imaxlength, imaxlength/2 ;update "Placement" max range with buffer max length
chnset SPlacementRange, "placementIdent"

But it’s behaving like this - snapping back to default value.

http://recordit.co/L9L5A6VSZi

It’s not possible. The slider ranges are fixed by the host when a plugin is launched. Updating them in realtime would cause all sorts of issues in the host. The best thing to do here is to set the slider range to move from 0 to 1. Then scale the value of the slider by the sample buffer size. If you wish to provide some details to the end user you can set what appears when the user moves the slider through the popuptext/postfix/prefix identifiers. These can be updated in real-time.

Got it. That makes sense - thanks.

Related to above - is it possible to update a slider position dynamically? For instance if I have an LFO controlling “feedback” - can the feedback control be animated to reflect the modulation?

Sure. Widgets that have values associated with them such as sliders, buttons, comboboxes, etc., can all have their values updated at any time using a chnset. Check the following example.

test.csd (432 Bytes)

Note that updating the slider values at k-rate is rarely a god idea. Best to update only when needed.

i think that something like:

klfofeed_ oscil 1, 1; bipolar modulation between -1 and 1
klfofeed = abs(klfofeed_); make it unipolar between 0 and 1 - if the slider has range 0 to 1
kmet metro 4;limit the update of the gui to 4 times per second
if kmet == 1 then
    chnset klfofeed, "ChannelOfTheSlider"
endif

As far as I’ve understood the channel of the widget is bidirectional (send and receive).
Hope it works.

Thanks