Check Box
Checkbox creates a checkbox which functions like a button, but the associated caption will not change when the user checks it. As with all widgets capable of sending data to Csound, the channel string is the channel on which the widget will communicate with Csound.
checkbox corners(val), radioGroup(val), active(val), automatable(val), alpha(val), bounds(x, y, width, height), channel("chan"), colour:0("colour"), colour:1("colour"), fontColour("colour"), identChannel("channel"), parent(val), popup(val), presetIgnore(val), rotate(radians, pivotx, pivoty), shape("shape"), text("string"), visible(val), toFront(), moveBehind("widgetName"), widgetArray("chan", number),
Specific Identifiers
corners(val)
Sets the radius size of the widget's corners.
radioGroup(val)
Set the radioGroup which this button will belong to. Can be a number or a string.
Common Identifiers
active(val)
Will deactivate a control if 0 is passed. Controls which are deactivate can still be updated from Csound.
automatable(val)
Default 1. Determines if a widget is automatable by a DAW host. Automatable widgets show up as plug-in parameters in the host. Non-automatable widgets still communicate with Csound but are not accessible
by the host. Note that hosts don't allow this parameter to change dynamically -- the plugin will have to be reloaded for any changes to take effect.
alpha(val)
A value between 0 and 1 will set the alpha blend value for the entire component. Can be useful if you need to fade widgets in and out.
bounds(x, y, width, height)
integer values that set position and size on screen(in pixels).
channel("chan")
or channel("chan1", "chan2")
in the case of widgets that accept two channels such as xypad, soundfiler and range widgets. channel()
accepts a
string/s that names the channel/s that Cabbage will communicate with Csound on. The current value of this widget can be retrieved in Csound using a chnget
, or a cabbageGetValue
opcode. Its value can
be set using the cabbageSet
, or cabbageSetValue
opcodes. hrange
, vrange
, xypad
, and soundfiler
all take two channels:
hrange, vrange : channel("min", "max")
- min and max values
xypad : channel("x", "y")
- x and y values
soundfiler : channel("start", "length")
- start time and length of user selection, in samples
Channels named should start with a letter and cannot have any white spaces. Note that all widgets should have a unique channel name.
colour:0("colour")
This sets the colour of the button when it's value is 0. Any CSS or HTML colour string can be passed to this identifier. The colour identifier can also be passed an RBG, or RGBA value.
All channel values must be between 0 and 255. For instance colour(0, 0, 255) will create a blue, while colour(0, 255, 0, 255) will create a green with an alpha channel set to full.
colour:1("colour")
This sets the colour of the button when it's value is 1. See above for details on valid colours.
You can create an invisible button by setting the colour to something with an alpha value of 0. Images can then be placed under the button to create an image button.
You can create an invisible checkbox by setting the colour to something with an alpha value of 0. Images can then be placed under the checkbox to create an image button. See the PVSampler instrument as an example of this.
fontColour("colour")
Sets the colour of the font. In the case of slider this sets teh colour of the font in the value textBox if it is shown.
identChannel("channel") [!!! DEPRECATED !!!]
Although identifier channels still work, they are no longer supported. Please use the new guiMode("queue") system and the cabbageGet
and cabbageSet
opcodes instead. They are far more efficient then identifiers channel.
parent(val)
This identifier is can be to set a widget's parent. It should only be used when creating widgets dynamically using the cabbageCreate
opcode. See
plants for more details.
popup(val)
This identifier, used with an image or groupbox will convert the plant into a popup plant. The plant will not be shown on the instrument's main interface, but will instead appear when the user sets visible
to 1. < DAWs treat popup dialogue windows in different ways. As a result, you may notice inconsistent behaviour when running your instruments as plugins across a variety of different hosts.
presetIgnore(val)
Defaults to 0. Set this to 1 to ignore this widget's value when a preset is taken.
rotate(radians, pivotx, pivoty)
Rotates the widget by a number of radians(2xPI=full rotation). pivotx and pivoty will determine the rotation pivot points, where 0, 0 represents the component's top-left position.
shape("shape")
Sets the shape of the LED. Default is "square" but users can use "circle" also.
text("string")
"string" will be the text that appears on the widget. button
widgets take two strings, one for on and one for off.
value(val)
value sets the initial state of the widget. In the case of a keyboard
widget, it sets the leftmost ky to appear.
visible(val)
A value of 0 will cause the widget to become invisible. Widgets have their visibility set to 1 by default.
toFront()
Brings a widget to the front of the z order. This identifier takes no arguments and is only intended for use within the Csound orchestra. it makes no sense to call it when declaring the widget.
moveBehind("widgetName")
Moves a widget directly behind another. This identifier should only ever be called from your Csound orchestra using a cabbageSet
opcode.
This only works with widgets or plants that have the same parent.
widgetArray("chan", number) [!!! DEPRECATED !!!]
Deprecated. Please see the section on Managing large numbers of widgets
colour:1() can be set using colour(). However, it's recommended that you use the numerated colour identifiers in order to make your code more readable.
Example
<Cabbage>
form caption("Checkbox Example") size(380, 500), guiMode("queue"), colour(2, 145, 209) pluginId("def1")
texteditor bounds(18, 256, 341, 231) channel("infoText"), readOnly(1), wrap(1), scrollbars(1)
soundfiler bounds(18, 16, 339, 182), channel("soundfiler1"), file("808loop.wav") colour(147, 210, 0), tableBackgroundColour(0, 0, 0, 0)
button bounds(18, 202, 84, 32) corners(5), channel("play"), text("Play", "Stop")
checkbox bounds(104, 202, 125, 32) channel("delay"), fontColour:1(255, 255, 255) text("Delay Enabled")
checkbox bounds(232, 202, 129, 32) channel("reverb"), fontColour:1(255, 255, 255) text("Reverb Enabled")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>e
<CsInstruments>
; Initialize the global variables.
ksmps = 16
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
SText = "A checkbox can be used a toggle/switch between 0 and 1. They are typically used to enable or disable certain parameters. In the example, a sample is loaded to a soundfiler. Csound reads the file directly from disk. As the file is playing, the output of the sampler is sent to a master FX instrument. The two checkbox widgets will enable or disable two different effects. \n\nThe soundfiler scrubber position is being updated in real time. To calculate its position, we use a phasor set to a frequency of 1/(file length / sampling rate). This produces a signal that moves from 0 to 1 in the same length of time it takes the file to play. We then multiply this value by the length of the soundfile in samples and use this value to set the position of the tracker."
cabbageSet "infoText", "text", SText
;trigger playback of sample
kPlayState, kPlayTrig cabbageGetValue "play"
if kPlayTrig == 1 then
if kPlayState == 1 then
event "i", "SamplePlayback", 0, -1
else
turnoff2 nstrnum("SamplePlayback"), 0, 0
endif
endif
endin
instr SamplePlayback
iLen = filelen("808loop.wav")*sr
print iLen
kScrubber phasor 1/(iLen/sr)
cabbageSet metro(20), "soundfiler1", "scrubberPosition", kScrubber*iLen
a1, a2 diskin2 "808loop.wav", 1, 0, 1
outs a1, a2
;send output from sampler to effects
chnset a1, "samplerLeftOut"
chnset a2, "samplerRightOut"
endin
instr Effects
aInL chnget "samplerLeftOut"
aInR chnget "samplerRightOut"
aRevL, aRevR, aDelR, aDelL init 0
kDelay cabbageGetValue "delay"
kReverb cabbageGetValue "reverb"
if kDelay == 1 then
aDelL comb aInL, 2, (1/100)*20
aDelR comb aInR, 2, (1/50)*20
else
aDelR = 0
aDelL = 0
endif
if kReverb == 1 then
aRevL, aRevR reverbsc aInL, aInR, .99, 15000
else
aRevR = 0
aRevL = 0
endif
outs (aDelL+aRevL)*.5, (aDelR+aRevR)*.5
chnclear "samplerLeftOut"
chnclear "samplerRightOut"
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
i1 0 z
i"Effects" 0 z ;always on
</CsScore>
</CsoundSynthesizer>