Form
form creates the main application window. The default values for size are 600x300. There can only be one form per instrument, and it has the unique channel name of MainForm. The caption property will only be displayed when running an instrument as a standalone application.
Configuration properties like pluginId, channelConfig, enableDevTools, logger, and package have been moved to the top-level of the Cabbage JSON structure. See the Widget Introduction for more details.
Properties (alphabetical)
Below is the full, alphabetical list of top-level widget properties for form.
Caption
"caption": "string"
The string passed to caption will be the string that appears on the main application window.
Id
"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.
Style
"style": {
"fill": "#004c6b",
"opacity": 1
},
- The form background color is controlled by
style.fill. - Opacity applies to the form’s background.
Example
<Cabbage>
{
"pluginId" : "def1",
"enableDevTools": true,
"channelConfig": [
{ "name": "Stereo", "ins": "2", "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
kVal, kTrig = cabbageGetValue("trigger")
if kTrig == 1 then
if kVal == 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>