Thanks @chronopolis, I have fixed this problem, but I’m facing another one now. These darn comboboxes. I think I should start a Cabbage fork called NoComboCabbage! Life would be so much easier :rofl. I hope to have something for you to test in a few hours…
Updates to cabbageSet/Get opcodes
Ok, fix pushed, but needs testing. Your example now works fine, but keep in mind that every time you recall a preset the combobox on the right will jump to ‘itemB’ because the combobox on the left will change its value.
I was thinking an all-combobox version of Cabbage!! Just go all in!
OK, my simplified example works now but I’m still having some issues with my version which uses cabbageChannelStateSave
instead of the .snaps system. I will try to make an example when I get back later but basically, on cabbageChannelStateSave
my comboboxes again become empty. Note that they are triggered by a changed listener so that could have something to do with it. Also the combobox with the preset name always turns blank after saving. I have a lot going on here and I might have also botched the combobox recall on cabbageChannelStateRecall
- so I will test and get back…
Thanks Rory. This example is clear
cabbageSetValue "recallCombo", sprintfk("%s/%s", SPath, SFilename), 1
So the combobox won’t automatically set to the most recently saved preset? In my case I am using a filebutton to save named preset. Is there way to retrieve that string to set the combobox?
Later - Oh I see, it’s all stored in the filebutton…
Can’t seem to get this line to work with a named preset filebutton? recallCombo just turns empty. prob just me being tired…
cabbageSet 1, "recallCombo", "refreshFiles(1)"
cabbageSetValue "recallCombo", cabbageGetValue:S("recallCombo"), 1
ChannelStateSaveCombo.csd (2.9 KB)
You’re not using the preset system in this instance, but a set of opcodes for saving Csound channels. Therefore the save button and the combo box showing your custom presets are agnostic of each other. So when we save a preset we need to manually set the new preset name in the combobox.
You should pass the name of the file you just saved:
SSaveFile, kTrigSave cabbageGetValue "triggerSave"
if kTrigSave == 1 then
kOk = cabbageChannelStateSave:k(SSaveFile)
cabbageSet 1, "recallCombo", "refreshFiles(1)"
cabbageSetValue "recallCombo", SSaveFile, 1
endif
OK, sorry to but in here, but I’ve been working on getting this method for presets working, and it seems I can save stuff, but when I read it in, I don’t get anything, or at least that is the way it seems. Guess I’m a bit confused by the following:
cabbageSetValue "att", cabbageGetValue:k("att")
Just how does this work? It appears you are getting the value for this parameter only to just reassigning… What is this supposed to do?
Also, if this is just making the final settings for the parameters in the file, do we need to have a line for each parameter? Or loop over a list of them?
When you restore channel data with cabbageChannelStateRecall
it will update each underlying Csound channel, but not the actual widget. This opcode knows nothing of Cabbage or its crazy ways
So yes, you will need to update the widgets accordingly.
Thanks - that did it…
I have a problem with cabbageSet opcode on listbox (but most likely I’m the problem); I’m reworking my old MIDI (Program changes in this case) preset system to work with cabbageChannelStateRecall.
Attached the file (and a subfolder containing the test presets) presetsListboxMidi.zip (7.7 KB)
With gui and mouse everything works as expected; when receiving midi messages if I set the listbox value with cabbage set (line 75 currently commented) cabbage crash, if i use chnset (line 74 - to update channel but not listbox selected value) it seems to work but listbox is not updated.
Any idea on how tho have listbox value updated without crash?
Using cabbage 2.7.14 built from sources on debian
This is a tricky one to debug because I don’t have a MIDI controller, and I’ve not been able to cause any crash by doing this with the UI. In my tests here gSfilenamesMidi[0]
seems to be empty all the time? Is there any way you can modify the following instrument so that it crashes when a user presses a button?
instr $CONTINSTR ;Always on control
;MIDI
kstatus, kchan, kdata1, kdata2 midiin
if kstatus == 192 then
Sfnam = gSfilenamesMidi[kdata1]
kcopare strcmpk Sfnam, ""
if kcopare != 0 then
chnset Sfnam, "recallCombo"
;cabbageSetValue "recallCombo", sprintfk("%s", Sfnam), k(1)
endif
endif
if you replace the MIDI stuff with a cabbageGetValue for a new button, does it also crash?
I’ve added a button (Preset3/Preset1) that switch preset like the midi code. listboxtest_MIDI_button.csd (5.3 KB)
As per the midi version:
- with chnset (line 76) works without updating the list
- cabbageSetValue (line 77) crash cabbage
gSfilenamesMidi[0]
is always empty because there is no preset starting with 000_; the numbers before underscore in the names are converted to number that indicate the midi program and the index in gSfilenamesMidi array (to retreive the file preset name when receiving a program change)
I just tested on ma Mac and it presented no problems. I’m going to boot up my Linux box now and see what happens there…
[some time later] this is a tricky one. The crash is bringing to some Linux X11 Windowing code which doesn’t seem to make any sense. I’m still digging, but so far I’ve not made any headway…
@vallste But I think I have the issue resolved now. That was quite a trip! I think I also caught a bug in the string version of cabbageGetValue
. Can you try the latest dev tip and let me know? Thanks.
@rorywalsh just build from develop and tested, no more crashes, works as expected.
Thank you!