Cabbage Logo
Back to Cabbage Site

cabbageSet "range"

Is it possible to change the range of a slider with cabbageSet? I tried the following:

rslider bounds(20, 20, 70, 70), channel("beats"), range(1, 64, 16, 1, 1), text("Beats")
rslider bounds(90, 20, 70, 70), channel("notes"), range(1, 64, 1, 1, 1), text("Notes")
rslider bounds(160, 20, 70, 70), channel("shift"), range(0, 63, 0, 1, 1), text("Shift")
kOne init 1
kBeats chnget "beats"
if changed:k(kBeats)==1 then
  cabbageSet kOne, "notes", "range", 1, kBeats, 1, 1, 1
  cabbageSet kOne, "shift", "range", 0, kBeats-1, 1, 1, 1

The purpose is that the slider “notes” should be restricted to 1…kBeats and “shift” to 0…kBeats-1 so that the user cannot choose values out of range. (and still use the full angular range of the slider)

Is there anything wrong in my code or is it simply not possible because the range of a slider is immutable? Thanks in advance for the answer.

It I remember correctly, the ranges can’t be changed.

One method I’ve used in the past is to set the range of the sliders to 0 and 1, then multiply that in Csound by the desired ranges.

@mjmogo is correct. Ranges can’t be updated because it would destroy host automation. It gets asked about quite a lot, but unless the plugin SDKs change it’s just not workable.

Thanks for clarifying this. Thinking a bit more about it I also see that it would be difficult to implement a dynamic change of ranges. Things like a value suddenly falling out of the range after it is changed must be handled.
@mjmogo: I also had the idea, but I want to avoid ending up with non-integers.