Widgets
Keyboard
keyboard will display a keyboard that will send MIDI information to your Csound instrument. This component can be used together with a hardware controller.
Properties
Section titled “Properties”Active
Section titled “Active”"active": trueWill 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
Section titled “Automatable”"automatable": trueDetermines 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.
Base Octave
Section titled “Base Octave”"baseOctave": 3Sets the base octave used when the computer keyboard is mapped to MIDI notes.
Bounds
Section titled “Bounds”"bounds": {"left":0, "top":0, "width":100, "height":100}Integer values that set position and size on screen(in pixels).
Channel
Section titled “Channel”"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.
| Field | Description |
|---|---|
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:
| Event | Description |
|---|---|
valueChanged (default) | Tracks simple value changes |
mousePressLeft | Sends 1 when the left mouse button is pressed, 0 when released. |
mousePressRight | Sends 1 when the right mouse button is pressed, 0 when released. |
mousePressMiddle | Sends 1 when the middle mouse button is pressed, 0 when released. |
mouseReleaseLeft | Sends 0 when the left mouse button is released. |
mouseReleaseRight | Sends 0 when the right mouse button is released. |
mouseReleaseMiddle | Sends 0 when the middle mouse button is released. |
mouseMoveX | Tracks movement along X axis. |
mouseMoveY | Tracks movement along Y axis. |
mouseDragX | Tracks movement along X axis with mouse pressed |
mouseDragY | Tracks 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. |
"color": { "whiteNote": "#ffffff", "arrowBackground": "#0295cf", "keydown": "#93d200", "blackNote": "#000000"}Configures the colours used by the keyboard widget. Colours accept any valid CSS colour string, or a hexadecimal value.
whiteNote: colour of the white keys.blackNote: colour of the black keys.keydown: colour of a key while it is held down.arrowBackground: background colour of the octave arrow buttons.
"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.
Octaves
Section titled “Octaves”"octaves": -1Sets the number of octaves displayed by the keyboard. Set to -1 to fit as many octaves as the widget width allows.
"value":0Value sets the initial state of the widget. In the case of a keyboard widget, it sets the leftmost key to appear.
Visible
Section titled “Visible”"visible": trueA 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
Section titled “ZIndex”"zIndex": 0Sets 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, "fontFamily": "Verdana", "fontSize": "auto", "fontColor": "#000000", "textAlign": "center"},- Keyboard visuals (white/black keys, keydown color) are configured under the
color.*object on the widget, not instyle. - The keyboard's note labels use
fontFamily,fontSize,fontColorandtextAlign.
Csound Usage
Section titled “Csound Usage”The keyboard widget sends MIDI data to Csound through Csound’s MIDI callback functions. This data can be accessed through the interop MIDI command-line flags and parameter fields, as shown in many of the Cabbage synth examples:
<CsOptions>-m0d --midi-key=4 --midi-velocity-amp=5</CsOptions>With these flags, the note number arrives in p4 and the velocity in p5. The information can also be accessed through Csound’s MIDI opcodes. Note velocity is mapped to the vertical axis of the key press: the lower the key is pressed, the louder the note.
Example
Section titled “Example”<Cabbage>{ "pluginId" : "def1", "enableDevTools": true, "channelConfig" : [ {"name": "0 in 2 out", "ins": "0", "outs": "2"} ], "widgets" : [ { "type": "form", "caption": "Combobox Example", "size": {"width": 580, "height": 500} }, { "type" : "rotarySlider", "bounds" : {"left": 12, "top": 9, "width": 86, "height": 90}, "channels": [ { "id": "att", "range": {"min": 0, "max": 1, "defaultValue": 0.01, "skew": 1, "increment": 0.001} } ], "text" : "Att." }, { "type" : "rotarySlider", "bounds" : {"left": 99, "top": 9, "width": 86, "height": 90}, "channels": [ { "id": "dec", "range": {"min": 0, "max": 1, "defaultValue": 0.4, "skew": 1, "increment": 0.001} } ], "text" : "Dec." }, { "type" : "rotarySlider", "bounds" : {"left": 187, "top": 9, "width": 86, "height": 90}, "channels": [ { "id": "sus", "range": {"min": 0, "max": 1, "defaultValue": 0.7, "skew": 1, "increment": 0.001} } ], "text" : "Sus." }, { "type" : "rotarySlider", "bounds" : {"left": 274, "top": 9, "width": 86, "height": 90}, "channels": [ { "id": "rel", "range": {"min": 0, "max": 1, "defaultValue": 0.8, "skew": 1, "increment": 0.001} } ], "text" : "Rel." }, { "type" : "keyboard", "bounds" : {"left": 12, "top": 104, "width": 348, "height": 80}, "channels": [ {"id": "keyboard"} ] }, { "type" : "comboBox", "bounds" : {"left": 260, "top": 188, "width": 100, "height": 30}, "channels": [ {"id": "waveform"} ], "corners" : 5, "items" : ["Saw", "Square", "Triangle"] } ]}
</Cabbage><CsoundSynthesizer><CsOptions>-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5</CsOptions><CsInstruments>; Initialize the global variables.ksmps = 32nchnls = 20dbfs = 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
vcoModes:i[] fillarray 0, 10, 12 att:i = cabbageGetValue("att") dec:i = cabbageGetValue("dec") sus:i = cabbageGetValue("sus") rel:i = cabbageGetValue("rel") env:k = madsr(att, dec, sus, rel) vcoOut:a = vco2(env*p5*.5, cpsmidinn:k(p4), vcoModes[cabbageGetValue:i("waveform")]) outs(vcoOut, vcoOut)
endin
</CsInstruments><CsScore>;causes Csound to run for about 7000 years...f0 z</CsScore></CsoundSynthesizer>