Cabbage Logo
Back to Cabbage Site

K-rate cabbageGetValue at i-time

i-time state of k-rate channels received from valuator widgets seems to change between the first and second time the instrument containing the cabbageGetValue is called - either MIDI notes or score events - and always zero the first time. So in the following:

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
rslider bounds(5,5,150,150), channel("test"), range(0,1,0.5)
keyboard bounds(5,160,390,85)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -dm0 -+rtmidi=NULL -M0
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
ktest cabbageGetValue "test"
print i(ktest)
endin

</CsInstruments>
<CsScore>
i 1 1 1
i 1 2 1
</CsScore>
</CsoundSynthesizer>

the print from the two notes will be:

instr 1:  #i0 = 0.000
instr 1:  #i0 = 0.500

It seems to be the same behaviour with both queue and polling methods.

The workaround/solution seems to be to read the widgets in an always-on instrument, output as global variables, and cast to i-rate in the other instrument:

instr 1
gktest cabbageGetValue "test"
endin

instr 2
print i(gktest)
endin

</CsInstruments>
<CsScore>
i 1 0 z
i 2 1 1
i 2 2 1

</CsScore>

but this feels like a bit of a kludge.

cabbageGetValue has no init function. There is a reason for this, but I’ll have to look over my notes in order to find that reason. I think it had something to do with loading sessions in a DAW. The fix couldn’t be simpler, all I have to do is add a single i to my source code and then it runs perfectly :rofl:

Let me look at why I removed the init method. You might have some useful input on an alternative solution.

Still digging through notes here, but it seems to have come about due to an issue with VST3 plugins in FL Studio. A very strange edge case. I’ll go back and see if I can recreate the issue, and then somehow find a better solution. I agree that it’s not very intuitive the way it is now.

It’s mainly the inconsistency between the first two notes that is unintuitive. I thought these used to always output zero at i-time which was at least consistent and could be handled with an init in the following line if a zero would cause a crash.

The following delightful workaround produces what would be desirable:

instr 1
ktest cabbageGetValue "test"
itest cabbageGetValue "test"
ktest init            itest

i 1 1 1
i 1 2 1

instr 1:  #i0 = 0.500
instr 1:  #i0 = 0.500

Can something like this not be built into cabbageGetValue?

My feeling is that they should output what they have as their default value. I’m still looking into the reasons I made this change. I know it’s buried somewhere in a thread of over a 1000 messages :face_with_monocle:

p.s. one thing that could be a potential issue here is that cabbageGetValue with a trigger will now no longer trigger a change when an instrument loads. I’d be fine with this too, but some people may have been using this mechanism to init things…

I managed to hunt down the example .csd who behaves correctly with this non init time version. Now I just need to ensure it still works if I add an init run. Of course, it doesn’t but I will see if I can fix that without having to rewrite the .csd…

Good things it has started raining here in Germany. After 4 weeks of glorious sunshine, I might actually get some time to work :slight_smile:

I’ve pushed some changes through and triggered a new build. I’ve tested the problematic .csd and it seems to work fine both in Cabbage and in various hosts. I’ll keep my fingers crossed that I don’t get a slew of angry messages about this very subtle change in behaviour :grimacing:

Great, this works handily. It’s now in line with the behaviour of CsoundQt valuators too, so should make porting form one to the other smoother.

Fingers crossed too.

If bug reports come in regarding plugins I’ll do what I can to make sure this is the default behaviour from hereon in. :muscle: