Skip to content
Cabbage
Install

Widgets

CheckBox

checkBox creates a checkBox on screen that can be used for a whole range of tasks. The “channel” string identifies the channel on which Cabbage will communicate with Csound.

checkbox.csd
Download .csd
"active": true

Will deactivate a control if false is set (use 0/1 to update from Csound). Controls which are deactivated can still be updated from Csound. Any widget that has its active property set to false will allow all mouse-clicks to pass through it.

"automatable": true

Determines if a widget is automatable by a host DAW. Automatable widgets show up as plug-in parameters in the host. Non-automatable widgets can still communicate with Csound but are not accessible by the host. The default varies by widget: most interactive controls default to true, while display-only widgets such as label, image and csoundOutput default to false.

Note that hosts don't allow this parameter to change dynamically. If you change this setting, the plugin will need to be reloaded.

"bounds": {"left":0, "top":0, "width":100, "height":100}

Integer values that set position and size on screen(in pixels).

"channels": [
{
"id": "channelName",
"label": { "name": "Channel Name", "prefix": "", "suffix": "" },
"event": "valueChanged",
"type": "number",
"range": {"min":0, "max":100, "defaultValue":0, "skew":1, "increment":0.1}
}
]

In Cabbage 3, widgets use an array of channels instead of a single channel string. Each channel object includes an id that defines a unique channel name. Widgets in Cabbage 3 can have any number of channels attached to them. An optional label object controls how the parameter appears in DAW parameter editors and automation lanes; if omitted, the id is used. An optional event property specifies the type of interaction. A range object can define the minimum, maximum, and default values, along with the skew and step increment. The type is set to number by default. Each widget sets its own type, number or string. A "string" channel carries text (readable with the string variant of cabbageGetValue), persists through session saves, and is excluded from DAW automation. See Persisting Custom UI State.

Channel label: DAW display name

The label object separates the internal channel identifier from the display name shown in DAWs, and allows a prefix and suffix to be appended to the parameter's value string in the DAW. This is useful when you want short, code-friendly channel IDs (e.g., hrm1, hrm2) while showing descriptive names in the DAW (e.g., Harmonic 1, Harmonic 2). Csound code always uses the id for channel access via cabbageGetValue and cabbageSetValue.

FieldDescription
name Human-readable parameter name shown in the DAW (required if using label)
prefix String prepended to the value in the DAW's value display (optional)
suffix String appended to the value in the DAW's value display (optional)

If range is omitted, it defaults to a range from 0 to 1, with increments of 0.001 for widgets that use drag events (e.g., sliders, XY pads) and 1 for widgets that use click or toggle events (e.g., buttons, checkboxes).

Note on increment parameter behavior:

The increment parameter quantizes all values sent to Csound channels, ensuring they snap to the specified step size. For example, with increment: 0.1, values will be rounded to 0.0, 0.1, 0.2, etc. before reaching Csound.

The DAW host automation has additional constraints:

  • increment >= 1.0: The host will display discrete integer steps (e.g., move from 1 to 2 to 3, etc.) in its native controls, and enforce these steps during automation.
  • increment < 1.0: The host displays a continuous slider.

Cabbage always quantizes values internally before sending to Csound.

Supported event types:

EventDescription
valueChanged (default)Tracks simple value changes
mousePressLeftSends 1 when the left mouse button is pressed, 0 when released.
mousePressRightSends 1 when the right mouse button is pressed, 0 when released.
mousePressMiddleSends 1 when the middle mouse button is pressed, 0 when released.
mouseReleaseLeftSends 0 when the left mouse button is released.
mouseReleaseRightSends 0 when the right mouse button is released.
mouseReleaseMiddleSends 0 when the middle mouse button is released.
mouseMoveXTracks movement along X axis.
mouseMoveYTracks movement along Y axis.
mouseDragXTracks movement along X axis with mouse pressed
mouseDragYTracks movement along Y axis with mouse pressed
mouseInside Sends the channel maximum while the pointer is inside the widget and the minimum when it leaves.
"id": "widgetId"

This optional channel can be used to define a top-level line of communication between the instrument’s UI and Csound. It is reserved for UI updates only. If omitted, it defaults to the first id from the channels array. Its primary purpose is to help produce clearer code, especially for widgets with multiple channels.

"label": {
"text": "",
"offsetY": 0,
"offsetX": 0,
"align": "center"
}

Configures the widget label displayed near the control.

  • text: the label text.
  • offsetY: vertical offset applied when the label is rendered outside the control (pixels).
  • offsetX: horizontal offset applied when the label is rendered outside the control (pixels).
  • align: label alignment for widgets that support it, such as groupBox, rotarySlider and numberSlider. numberSlider also accepts left and right to place the label beside the value.

For the slider widgets with a nested style.label object (horizontalSlider, verticalSlider, rotarySlider and numberSlider), typography is set under style.label.*. Other widgets use style.fontFamily, style.fontSize, style.fontColor and style.textAlign.

"persistence": {
"preset": true,
"session": true
}

Controls whether a widget's state is saved in DAW presets and Csound session files. Both properties default to true.

  • preset: When true, the widget's current value/state is included when using Csound's cabbageSaveState opcode to save preset data. Set to false for widgets that should not persist in Csound preset files (e.g., widgets that load presets).
  • session: When true, the widget's state is included when the DAW saves a preset. Set to false for widgets that should not have their values loaded/saved when a DAW session loads (e.g., widgets that load presets).

Auto-cascade behavior: If you set preset to false without explicitly setting session, the system automatically sets session to false as well. This prevents state from being saved anywhere unless explicitly requested.

"radioGroup": -1

Radio group allows buttons and checkboxes to be grouped together so that only one widget in the group can be active at a time. Set to -1 for no grouping, or to a positive integer to group widgets together.

"value":0

Value sets the initial state of the widget. In the case of a keyboard widget, it sets the leftmost key to appear.

"visible": true

A value of true shows the widget; set it to false to hide it (use 0/1 to update from Csound). Widgets are visible by default.

"zIndex": 0

Sets the stacking order of the widget. Widgets with higher zIndex values will appear in front of widgets with lower values. Default is 0.

{
"style": {
"opacity": 1,
"borderRadius": 2,
"fontFamily": "Verdana",
"fontSize": "auto",
"fontColor": "#dddddd",
"textAlign": "left",
"on": {
"backgroundColor": "#93d200",
"borderColor": "#dddddd",
"borderWidth": 2,
"textColor": "#dddddd"
},
"off": {
"backgroundColor": "#00000000",
"borderColor": "#dddddd",
"borderWidth": 2,
"textColor": "#000000"
}
},
"label": {
"text": "On/Off"
}
}

Notes

  • fontSize: "auto" scales with the widget height; set a number (px) to fix it.
  • textAlign: "left" shows the box first and text to the right; use "right" to flip.
  • Colors accept CSS strings (e.g., "#93d200", "rgba(0,0,0,0)") or RGB arrays [r,g,b].
  • The text color shown is controlled by the current state's textColor (on/off).

The checkBox returns its on/off state along with a k-rate trigger value. The trigger value will be 1 for one k-cycle when the box is toggled, then return to 0. Read it with the CabbageNumTrig struct form of cabbageGetValue:

trigger:CabbageNumTrig = cabbageGetValue("trigger")
if trigger.trig == 1 then
if trigger.val == 1 then
event("i", "Synth", 0, 3600)
else
turnoff2(nstrnum("Synth"), 0, 0)
endif
endif

For a simple on/off state without edge detection, read the channel at k-rate:

kMute = cabbageGetValue("mute")
checkbox.csd
<Cabbage>
{
"pluginId" : "def1",
"enableDevTools": true,
"channelConfig" : [ {"name": "0 in 2 out", "ins": "0", "outs": "2"} ],
"widgets" : [
{ "type": "form", "caption": "Button Example", "size": {"width": 380, "height": 300}, "guiMode": "queue" },
{
"type" : "checkBox",
"bounds" : {"left": 10, "top": 16, "width": 126, "height": 18},
"channels": [
{ "id": "trigger", "event": "valueChanged", "range": {"min": 0, "max": 1, "defaultValue": 0, "skew": 1, "increment": 1} }
],
"label" : {"text": "Synth Enabled"}
},
{
"type" : "button",
"bounds" : {"left": 146, "top": 12, "width": 80, "height": 30},
"channels": [
{ "id": "mute", "event": "valueChanged", "range": {"min": 0, "max": 1, "defaultValue": 0, "skew": 1, "increment": 1} }
],
"label" : { "text": {"off": "Unmute", "on": "Mute"} }
},
{
"type" : "button",
"bounds" : {"left": 240, "top": 12, "width": 121, "height": 30},
"channels": [ {"id": "toggleFreq", "event": "valueChanged"} ],
"label" : { "text": {"off": "Toggle Freq", "on": "Toggle Freq"} },
"style" : {
"off": {"backgroundColor": "#ff0000", "textColor": "#ffffff"},
"on" : {"backgroundColor": "#0295cf", "textColor": "#ffffff"}
}
}
]
}
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
; Rory Walsh 2021
;
; License: CC0 1.0 Universal
; You can copy, modify, and distribute this file,
; even for commercial purposes, all without asking permission.
instr 1
trigger:CabbageNumTrig = cabbageGetValue("trigger")
if trigger.trig == 1 then
if trigger.val == 1 then
event("i", "Synth", 0, 3600)
else
iInstrNum = nstrnum("Synth")
turnoff2(iInstrNum, 0, 0)
endif
endif
endin
instr Synth
prints("Starting Synth")
kMute = cabbageGetValue("mute")
a1 = oscili(.5*kMute, 300*(cabbageGetValue("toggleFreq")+1))
outs(a1, a1)
endin
</CsInstruments>
<CsScore>
;starts instrument 1 and runs it for a week
i1 0 z
</CsScore>
</CsoundSynthesizer>