Cabbage Logo
Back to Cabbage Site

Get current text from combobox & optionbutton?

Is this possible? I seem to only be able to get the initial text, and not the current selected text when using this:

gkTest cabbageGet "ArpMode", "text"

My plan is to use the string value as if-conditions to avoid reading the index of an array where the index has been jumbled after adding new elements in between. Perhaps this is problematic to achieve?

If you use a combobox with channelType("string") you can use cabbageGetValue, which will return the current string. Not possible with an options button, but what I would do in that case is simply define an array of strings corresponding to the button values.

1 Like

Thanks. I tried this, but it always makes Cabbage crash.

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
combobox bounds(12, 22, 75, 19) channel("ComboboxTest"), colour(64, 73, 88), items("Yes", "No", "Maybe"), channelType("string")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1

SCombobox cabbageGetValue "ComboboxTest"

if (changed2(SCombobox) == 1) then
    printks SCombobox, 1
endif

endin

</CsInstruments>
<CsScore>
i1 0 z
</CsScore>
</CsoundSynthesizer>

Not sure why it crashes but you’re using the i-time version of get value. Use the k-time version with the inbuilt changed trigger. That’s should work :crossed_fingers:

Here’s working code:

instr 1
    SCombobox, kTrig cabbageGetValue "ComboboxTest"
    printf SCombobox, kTrig
endin

Nice, it works in Cabbage.

In FL Studio however, the channel is still a float value.

The only thing a host gets is a value between 0 and 1. I was reluctant to add ‘string’ comboboxes for this reason, but they can still be quite useful. What are you trying to achieve exactly?

Trying to make plugins as future-proof as possible. Say you have a combobox sorted alphabetically. When using the integer value as an if-condition, you would need to insert the new element at the end of the combobox to not scramble the order for existing users. Using strings however, should solve this I imagine.

Well, you can’t change the range of any VST parameter are the plugin has been instantiated. So adding extra items to a combobox will only work if that parameter is marked as non-automatable. Does this botch your plans?

I’m not talking about changing the range during runtime, but hard-coded in the Cabbage-section of the .csd, e.g. as part of an update. Surely this would update the range for the channel when opening the project in a host?

Oh yeah for sure. So long as they are known when the plugin is first opened.

Okay, so to conclude, string-type channels are not currently implemented to be used in hosts, correct?

The reason I was curious about this, was that I found other commercial plugins that seemingly does this.

StringChannelZebra

The VST SDK does provide a way of doing this as far as I can tell, but I’ve never implemented it. I can tke a crack at it over the coming days. The goal here is to have text appear in the native UI instead of numbers?

Yes, and to use the string channel-value in if-conditions. This means elements in comboboxes would not be tied to index integers, and be more future-proof in terms of adding new elements.

I’ll see what can do. :+1:

Looks like a good start, but the problem is the host still only broadcasts numbers, not strings. So if you use a combobox like this for automation, Cabbage will only receive numbers. So you’ll still need to work of indices? Should I continue?

Ah okey, if I still have to work with indices in Cabbage then it’s not necessary to add unless you see another use for it?

I’ll keep at it. I know what you’re looking for, and it would be useful. I’m afraid it might break some things, but we’ll test it out first to make sure. And if it does, we’ll need to make a call on it.

See String combobox - potential breaking change This should give you exactly what you were looking for. Thanks for the push, it’s a big improvement over the older way of doing things.