Cabbage Logo
Back to Cabbage Site

High CPU usage for the queue guiMode

Just right click my name and select send message. The examples that ship with cabbage all work fine for me. No drop outs…

I’m back to the cabbageSetValue issue. Could you please consider this comparison:

<Cabbage> bounds(0, 0, 0, 0)

form caption("test CabbageGetValue") size(300, 200), colour(0, 0, 0), pluginId("tepc") ;guiMode("queue") 

button bounds(28, 50, 71, 24) latched(0) channel("FlipOFF") identChannel("ID_FlipOFF") text("OFF") colour:0(100, 100, 100, 255) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(28, 24, 71, 24) latched(0) channel("FlipON") identChannel("ID_FlipON") text("ON") colour:0(100, 100, 100, 255) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)

button bounds(108, 36, 66, 27) channel("State") text("State") colour:0(255, 255, 0, 100) colour:1(255, 255, 0, 255) visible(1)


</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-d -n -+rtmidi=null -M0 -m0d

</CsOptions>
<CsInstruments>
ksmps   = 16

instr 1

iQueueMode = 0

if iQueueMode == 0 then

if trigger(chnget:k("FlipOFF"),0.5,0) == 1 then
chnset  k(1), "State"
printks "OFF\n", 0
endif

else

if trigger(cabbageGetValue:k("FlipOFF"),0.5,0) == 1 then
cabbageSetValue "State", k(1) ;trigger(cabbageGetValue:k("FlipOFF"),0.5,0)
printks "OFF\n", 0
endif

endif
   
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z ;starts instrument 1 and runs it for a week
i 1 0 -1;[60*60*24*7]

</CsScore>
</CsoundSynthesizer>

It seems that cabbageSetValue runs at init time? I can avoid it by using the commented trigger there but I am wandering if this could be avoided so that it would be more consistent with the default mode?

I doesn’t seem to me that this was implemented? Or am I misunderstanding something… or many things? :thinking:

My bad. It’s still picking up an init pass for cabbageSetValue. Although cabbageGetValue is not non-init! In the mean time, you can still achieve what you want with just two lines of code and no if tests:

kValue, kTrig cabbageGetValue "FlipOFF"
cabbageSetValue "State", k(1), kTrig

I will remove the init pass from cabbageSetValue tomorrow, I just want to run a few more tests first. :+1:

Cool! Thanks!
I’m using if to minimize number of variables and because I am doing other things within the if block. I’m wandering how would the if test and the Cabbage trigger compare in terms of the CPU costs? I guess Cabbage is already doing the if test, so avoiding another test seems good, but then we need to handle one more k-rate variable?

That’s true but, but you remove an opcode from the equation. And I find it makes the code easier to read, but I don’t think one way or the other are going to be all that different in terms of CPU.