Cabbage Logo
Back to Cabbage Site

Behind the scenes of the "remove preset" filebutton?

I’ve noticed that upon removing a preset (with Cabbage’s built-in preset system), all audio and instances of instruments are automatically turned off. How is this made possible?

I have been trying to figure out a way to recreate this behavior when performing other preset-related actions, such as selecting a preset from a combobox or initializing all the parameters, but haven’t found any success. For example, here is something I tried (for context, this is meant for a initialization button):

   gkinit chnget "Init" 
   if (changed2(gkinit) == 1) then
   
        event "i", 1003, 0, .1     ;instr that initializes all widgets
        turnoff2 10, 8, 0.02       ;attempt to turn off all instances of MIDI-receiving instr
        clear gareverb            ;clear global reverb variable
        
   endif

While this approach does turn off any notes that are being sustained (by my fingers on the keyboard) and clears the reverb variable, it fails to turn off notes that are in their release state (if a note has a long release, it lingers while changing timbre as the widgets are reset). I’ve also run into some weird glitches when using this method, perhaps caused by the combination of all the widgets being set to different values in such a short amount of time and instruments/events still running while those changes take place.

So hmmmm what’s the secret behind the “remove preset” button? :rofl:

I’ll take a look. Thanks for the report. :+1:

Thanks - just for clarification, the effect that the remove button has is desired imo, as it clears out any sound and terminates events (even if they’re in their release state) upon the current preset’s deletion, and I’m trying to recreate that effect when doing other things like selecting presets from a combobox or initializing a patch.

Now I understand. So you want a kill switch of sorts? I’ll take a look at what happens with remove and get back to you. It’s exam time here so I’m buried deep in corrections… :grimacing:

Yeah, that’s a good way to put it!

No worries about the wait. Hoping the schoolwork isn’t stressing you out too much!

So the only magic here is that it sets all widgets to the next preset, which causes the current preset sounds to stop. But in my tests MIDI notes still play. If I set a really long release time for a synth and remove a preset while that note is playing, the next preset takes over and the sound continues there :thinking: I think what you are after is some kind of global kill switch.

One crude way of doing this would be to add a channel to your MIDI instruments, that will immediately turn them off is activated. Something like:

if chnget:k("end") == 1 then
    turnoff
endif

it’s crude, but should end everything immediately.

Just tried doing that (putting a turnoff in the MIDI instr) like so:

   if (changed2(gkinit) == 1) then
   
        event "i", 1003, 0, .1      ;call instr that initializes all widgets
        turnoff                     ;turn off current instrument (MIDI instr)
        
   endif

but it unfortunately still doesn’t cut out any notes that are in their release state. Same result as using turnoff2 in a separate instr, as demonstrated in the original post. I wonder if this has something to do with the way csound interacts with MIDI events?

also tried this out again and yes, that’s what happens for me too. I might’ve just gotten mixed up with what I was remembering at the time that I reported a different result upon removing a preset.

I just tried this and I get the same issue as you. How strange, I was sure turnoff would be an instant hit! I’m curious about this myself. I think I’ll go ask on the Csound mailing list.

ok! I think I just subscribed to the list (this one?) so I’m not sure if you’ve happened to send your question or not. If not, I can ask!

I didn’t get a chance, I was still seeing if I can work it out. But feel free to ask. There is the list and forum.csound.com :+1:

For some reason I don’t have permission to post on the mailing list site, but does emailing to csound@lists.bath.ac.uk do the job? I found that on a manual page but I’m not sure if that method is outdated or not.

[edit] - just posted the question to the forum!

1 Like