Cabbage Logo
Back to Cabbage Site

Slider with specific values

Is it possible to give a slider specific values? I want an r-slider that can select between:

1, 2, 4, 8, 16…etc.

I know I could obviously do that with a combo box, but it’s not as easy to control in real time.

I know if I need to I can just have increments of one and just do 2^x in my code… but it would be nice if it told me what it’s really at aswell :wink:

You could ignore the rslider’s own textbox, convert the integers to your desired values in csound and then send them back out to a numberbox widget, strategically placed near the rslider. There’s no documentation for numberbox, maybe it’s in deprecation limbo?

That’s a very good point! It doesn’t have to be directly associated with that widget in particular. Nice one :wink:

No, I just seem to have forgotten about it completely! I’m in the process of updating my PC. Once my new SSD drive is up and running(later today I hope!) I’ll get on to sorting the documentation.

You could also use the popuptext identifier. Here’s your powers of 2 sequence.

<Cabbage>
form size(200, 200)
rslider bounds(50, 50, 100, 100), channel("integers"), range(0, 10, 0, 1, 1), identchannel("Slider")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -m0d 
</CsOptions>
<CsInstruments>

instr 1
kints	chnget	"integers"
if changed(kints)==1 then
		chnset sprintfk("popuptext(\"%d\")",2^kints), "Slider"
endif
endin

</CsInstruments>
<CsScore>
i1 0 [60*60*24*7] 
</CsScore>
</CsoundSynthesizer>