Cabbage Logo
Back to Cabbage Site

Crash issue with CustomPresets example

CustomPresets seems to consistently crash if the user saves a preset then tries to open that preset anytime during the same instantiation of the instrument. I’m having trouble trying to figure out how to fix this or even find a cause for it…

Could this be solved? And why is this problem occurring (I’m just curious and currently stumped)?

Attached is a version of CustomPresets that works “properly” (outside of the issue above) - the version that is included in the Cabbage examples attempts to assign all the widget values to only one widget instead of assigning the values to their respective destinations. Just a matter of changing this:

chnset i1, "att"
chnset i1, "dec"
chnset i1, "sus"
chnset i1, "rel"

to this:

chnset i1, "att"
chnset i2, "dec"
chnset i3, "sus"
chnset i4, "rel"

CustomPresets.csd (1.9 KB)

Check out Presets and PresetsNamed in the Examples folder. Might be what you want for your project.

I’ve checked out those examples but I’m honestly not the biggest fan of the .snaps system due to its limitations in sharing/organizing individual preset files as well as the overall look of the default Cabbage dialogue boxes :confused:

I get what you mean. I’d recommend you look through this Solution for user-made presets?

Might find something useful there

Ah, found the solution I think -

This seems to resolve the issue of Cabbage freezing up if the user opens a preset that has been saved during the same run of the plugin.

Here is a modified .csd for reference: CustomPresets.csd (2.0 KB)

Thanks for the link to that thread!

i open the project an go to edit mode and erase what i know its the problem in the script, then hit play and see

Here’s another version that uses the channelState opcodes.

ChannelPresets.csd (1.8 KB)
The advantage of this one is you don’t need to keep track of all channels manually. Calling the following anywhere in your code will write all channel values as JSON data to disk.

kOk = channelStateSave:k("myPresets.txt")

The following will read and set all channels to the saved values:

kOk = channelStateRecall:k(“myPresets.txt”)

If you use this approach you will need to:

  • to manage the filenames yourself - in my example they are always called the same thing…
  • You will need use the ignore channels optional parameter so that you don’t send Cabbage into an infinite loop by triggering the channels to update again once they are updated. It’s easily done - hence the additional parameters!

More info:
https://rorywalsh.github.io/csoundPluginOpcodes/#/channelStateSave
https://rorywalsh.github.io/csoundPluginOpcodes/#/channelStateRecall

This is interesting - thanks for sharing this additional method! Those new opcodes look cool as well. trigExpseg and trigLinseg have me wondering what kinda unique things one could do with tools like that :o