Cabbage Logo
Back to Cabbage Site

Assiging a value to buttons

I’m only 2 days in working with Cabbage and Csound and im excited to use Cabbage as my replacement to synthmaker.

Currently working on a EQ and im stuck trying to figure out button values.

Here’s my question:
I would like a button to toggle between 2 values to set a frequency on the RBJ opcode (just like the range on a slider). How do i set up a button to act in this way that if the button is on then send the value of 8k and if the button is off then send the value to 12K.

Thanks for the help
Matt

You could do something like this:

if chnget:k("button") == 1 then
  kFreq = 8000
else
  kFreq = 12000
endif

ar rbjeq asig, kFreq, klvl, kQ, kS

Or lightly more cryptic, but shorter code:

ar rbjeq asig, chnget:k("button") == 1 ? 8000 : 12000, klvl, kQ, kS

Btw, untested code, so watch out for typos, but hopefully the logic is clear.

Awesome, worked like a charm! Definitely like the lighter version :wink:

BTW, thank you for putting together Cabbage!

:+1: