Cabbage Logo
Back to Cabbage Site

New trigger issue

After tweaking the radioGroup issue (Radiogroup - chnset one button ON doesn't turn other buttons OFF), a new Cabbage plague seems to poke out. The example below is again out of context, but this worked before and I made good use of it :wink:

See what happens in 2.7.13 if you press the ā€œloadā€ button more than ones. Even after stopping Cabbage, the GUI part remains stack in some kind of a neurotic state.

form caption("test ButtonsLoop") size(330, 290) pluginId("tbl1") colour(0, 0, 0) guiMode("queue")

button bounds(10, 74, 34, 14)   channel("IO_SavePar1") text("S 1", "S 1") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(48, 74, 34, 14)   channel("IO_SavePar2") text("S 2", "S 2") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(86, 74, 34, 14)   channel("IO_SavePar3") text("S 3", "S 3") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(124, 74, 34, 14)  channel("IO_SavePar4") text("S 4", "S 4") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(162, 74, 34, 14)  channel("IO_SavePar5") text("S 5", "S 5") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(200, 74, 34, 14)  channel("IO_SavePar6") text("S 6", "S 6") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(238, 74, 34, 14)  channel("IO_SavePar7") text("S 7", "S 7") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(276, 74, 34, 14)  channel("IO_SavePar8") text("S 8", "S 8") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)

button bounds(10, 92, 34, 14)   channel("IO_SavePar9") text("S 9", "S 9") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(48, 92, 34, 14)   channel("IO_SavePar10") text("S 10", "S 10") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(86, 92, 34, 14)   channel("IO_SavePar11") text("S 11", "S 11") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(124, 92, 34, 14)  channel("IO_SavePar12") text("S 12", "S 12") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(162, 92, 34, 14)  channel("IO_SavePar13") text("S 13", "S 13") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(200, 92, 34, 14)  channel("IO_SavePar14") text("S 14", "S 14") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(238, 92, 34, 14)  channel("IO_SavePar15") text("S 15", "S 15") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
button bounds(276, 92, 34, 14)  channel("IO_SavePar16") text("S 16", "S 16") corners(3) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)

button bounds(10, 128, 70, 14)  channel("IO_Load") text("LOAD", "LOAD") automatable(0) corners(3) latched(0) colour:0(255, 255, 0, 80) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)


</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL 
</CsOptions>
<CsInstruments>

ksmps = 16
nchnls = 2
0dbfs = 1

instr 1

if trigger(cabbageGetValue:k("IO_Load"), .5, 0) == 1 then
    
    kind = 0
    until kind == 16 do
    cabbageSetValue sprintfk("IO_SavePar%d", kind+1), k(0)
    kind += 1
    od

    kind = 0
    until kind == 16 do
    if kind>7 then 
        cabbageSetValue sprintfk("IO_SavePar%d", kind+1), k(1)
    endif
    kind +=1
    od
    
endif

endin

</CsInstruments>
<CsScore>
f0 z
i 1 0 [3600*24*7]
</CsScore>
</CsoundSynthesizer>

Yes, i see this here. It seems like itā€™s a direct consequence of the radioGroup ā€˜fixā€™. Darn it. Oh wait, Iā€™ve an ideaā€¦

[edit] another roll of sticky tape applied :grimacing: What Iā€™ve done is force the button to behave as it did in the past if it is NOT part of a radioGroup. Your instrument runs here now fine. It was entering into a recursive loop. Not fun for a button. Not fun at all! :rofl:

Thanks! I really hope we can get out of this stickiness already.
Do you fear any other thing to give after the radioGroup fix?

I was wondering what is going on with the radioGroup - how it is treated. I imagine it should be treated as a single object (a vector) not as a scalar. The change in the state of a vector could then perhaps be given by some kind of rotation, which require a single parameter to change (like an angle) within a k-cycle. Sorry if this is a complete naive shot in the dark, but maybe it could provide some useful point of view on redesigning the radioGroup?

Itā€™s actually a group of individual objects. Which is more or less the problem. It does need a redesign. Right now Iā€™m using the JUCE radio group mechanism, which is fine when interacting with the button via the GUI, but is a little cumbersome when we wish to dynamically update them from the code.

Like you I would like to get out of the stickiness, but it looks like we are stuck in the stickiness for a little time longerā€¦

OK. Letā€™s try to stick with it then :slight_smile:
Iā€™ll let you know if something else falls into the spider nets.

1 Like

It seems the stickiness is not overā€¦?
There is something very strange with the widget triggering and the reinit block. This causes crash when I have it in a more busy context, but here you can see that by removing either of the two reinit blocks it works as expected, else it gets caught in a loop which can eventually exit.

<Cabbage>

form caption("test ButtonsLoop") size(330, 290) pluginId("tbl1") colour(0, 0, 0) guiMode("queue")

button bounds(86, 128, 70, 14) channel("IO_Save") text("SAVE", "SAVE") automatable(0) corners(3)  latched(0) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255)  fontColour:1(160, 0, 0, 255)

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL 
</CsOptions>
<CsInstruments>

ksmps = 16
nchnls = 2
0dbfs = 1

instr 1

S_SaveAsFileName strcpy "noChange.txt"

SDefaultPresetName strcpy "preset.txt"
iDefaultPresetExists filevalid SDefaultPresetName

if changed2:k(S_SaveAsFileName) == 1 && strindexk(S_SaveAsFileName, ".txt") > 0 then   
    
    CheckFile: ; comment this block
    iDefaultPresetExists filevalid SDefaultPresetName
    reinit CheckFile 
    
    ;printks "x",0 
endif

if trigger(cabbageGetValue:k("IO_Save"), .5, 0) == 1 then
    
    CheckFile: ; or comment this block
    iDefaultPresetExists filevalid SDefaultPresetName
    reinit CheckFile   
    
    printks "y",0
endif

endin

</CsInstruments>
<CsScore>
f0 z
i 1 0 [3600*24*7]
</CsScore>
</CsoundSynthesizer>

Is having two identical labels legal in Csound? Iā€™ve never seen it before. Surely that is asking for trouble?

Right! This was not what caused my new crashes then. Iā€™ll try to debug further. Something changed. Iā€™ll be back :slight_smile:

I think I found it now. This crashes if I use the longer name with underscore.

<Cabbage>
form caption("test ButtonsLoop") size(330, 290) pluginId("tbl1") colour(0, 0, 0) guiMode("queue")

button bounds(86, 128, 70, 14) channel("IO_Save") text("SAVE", "SAVE") automatable(0) corners(3)  latched(0) colour:0(200, 80, 0, 180) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255)  fontColour:1(160, 0, 0, 255)

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL 
</CsOptions>
<CsInstruments>

ksmps = 16
nchnls = 2
0dbfs = 1

instr 1
SDefaultPresetName strcpy "something_preset.txt"
;SDefaultPresetName strcpy "preset.txt"
S_SaveFileName strcpy SDefaultPresetName
S_SaveFileName cabbageGetValue "IO_SaveAs"

if trigger(cabbageGetValue:k("IO_Save"), .5, 0) == 1 then
    S_SaveFileName strcpyk SDefaultPresetName
    printks "x",0
endif

endin

</CsInstruments>
<CsScore>
f0 z
i 1 0 [3600*24*7]
</CsScore>
</CsoundSynthesizer>

You are trying to retrieve a string value from a channel that doesnā€™t exist, i.e., "IO_SaveAs".
If I remove the call to that channel is works fine. If I leave it in I get a Csound error which pulls down Cabbage. Itā€™s strange though, because that still shouldnā€™t crash Cabbage. Iā€™ll see if I can find the cause of it. Leave it with me. Btw, I think the underscore is a red herring :thinking:

I just pushed a fix for this. It no longer crashes. Can you give it a go when you get a chance?

Thanks! I accidentally deleted the line when copying to the forum:
filebutton bounds(20, 44, 70, 14) channel("IO_SaveAs") mode("save") text("SAVE AS", "SAVE AS")
Have you tried it with this widget in?
Iā€™ll get the new beta this evening.

Works now with widget in or outā€¦

Seems to be all good now :slight_smile:

Seems to be fine with it now. Did you fry the herring now or should we avoid it? :slight_smile:

Testing out my instrument that I posted you, there seems to be some other changes, which are no problem, and I canā€™t pin them down, but seems something with the init pass. I had to add the gate thing at the end of the line:
if changed2(S_LoadFileName) == 1 && strindexk(S_LoadFileName, ".txt") > 0 && kLoadAllGate < 0 then
to prevent the change of S_LoadFileName happening in the init pass. Maybe you have a clue what could be the difference?
Also, I can now use the reinit which caused me trouble before, and this is not due to double labels, but something else went crazyā€¦ and had to remove the reinit block. Basically I am just wondering if you did any changes that could be related to these. Sorry for not being more elaborate. In summary, things seem to work for me today :smile: Thanks to You of course!

I didnā€™t change anything, apart from one little memory allocation in the cababgeGetValue string variant. Try setting the default file for your file button using file("name of file.txt"). I always use the cabbageGetValue triggers instead of changed now as I find them more consistant behaviour and less likely to give false triggers.

I donā€™t use changed but trigger - more useful for non latched buttons.
Using ā€œname of file.txtā€ with or without spaces seems to disable my thing. :thinking:

I didnā€™t mean for you write name of file, but the name of YOUR default file.