Cabbage Logo
Back to Cabbage Site

Dynamically changing skew value of widget

Since it’s not possible to dynamically create new controls in a newly loaded .orc file, what is the best way to scale a linear widget, since I cannot dynamically update the skew value? “exp” opcode? For some reason it evades me… how would I get a skew value equal to 0.2 in the widget?

I’ll check the math for this tomorrow and let you know.

I believe this is what Cabbage does. ( I say ‘believe’ because it’s actually all wrapped up in the JUCE Slider class. But it seems to match it. Just hit play.

Sorry my math skills are not up to the task here :cold_sweat: - so to translate from js, since it’s taking a base and an exp… seems like csound exp only takes the exponent? I assume the base is always 1?

;kfilter control goes from 0-1
 ifskew = 0.2
 kfilter = exp(1/ifskew)
 kfilter scale kfilter, 5000, 80

I know this isn’t right but am I close?

I’d have gone with:

;skewedValue = Math.pow((slider.value()/100), 1 / skew);

iSkew = 0.2
kValue = pow(kfilter, 1/iSkew)

:thinking:

I just recently made myself this simple opcode for the same purpose, hope it helps.

opcode mapSlider, k, kiii
; scale as Cabbage sliders
kin, imin, imax, iscale xin
xout imin+(imax-imin)*kin^(1/iscale)
endop

Yes - I got it working… thanks!