I’m getting widget channel names with cabbageGetWidgetChannels
and I’d like to update a table only when any of the widget values change. This works find if I manually detect value change by spelling out all the widgets like:
kVal, kTrig cabbageGetValue "channelName"
,
but if I try to loop through the channels, cabbageGetValue
triggers also when value is not changed, presumably due to “banging” it with a k-rate index. I get a similar issue if I use changed:k(kVal)
instead of kTrig. I am puzzled why changed detects a change while kVal is constant?
Is there a way to scan through the widgets in a loop like below without getting value change triggers all the time?
Example:
<Cabbage>
form caption("test loop cabbageGetValue") size(330, 290) pluginId("cgv1") colour(0, 0, 0) guiMode("queue")
rslider bounds(8, 8, 40, 70) range(0, 10, 1, 1, 0.0001) channel("par1") text("Par1") popupText("0") _getMe(1)
rslider bounds(46, 8, 40, 70) range(0, 10, 2, 1, 0.0001) channel("par2") text("Par2") popupText("0") _getMe(1)
rslider bounds(86, 8, 40, 70) range(0, 10, 3, 1, 0.0001) channel("par3") text("Par3") popupText("0") _getMe(1)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL
</CsOptions>
<CsInstruments>
ksmps = 32
instr 1
Sliders[] cabbageGetWidgetChannels "_getMe(1)"
printarray Sliders, 1
iN = lenarray(Sliders)
print iN
kind = 0
until kind == iN do
kVal, kTrig cabbageGetValue Sliders[kind]
if kTrig == 1 then
printk 1, kVal
endif
kind += 1
od
endin
</CsInstruments>
<CsScore>
f0 z
i 1 0 -1
</CsScore>
</CsoundSynthesizer>