Widgets
GenTable
genTable creates a table widget on screen that can be used to display the contents of a function table or the contents of a file. When selectableRegions is enabled, users can interactively select portions of the waveform by clicking and dragging.
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.
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": "gentableStart", "event": "valueChanged", "range": { "min": 0, "max": -1 } }, { "id": "gentableLength", "event": "valueChanged", "range": { "min": 0, "max": -1 } } ]The genTable has two default channels that provide information about the current selection. Note these channels are only valid if selectableRegions is set to true.
"file": "filename"This identifier is used across a number of widgets.
combobox and listbox - will load lines from a file as selectable items.
gentable and soundfiler - will load a sound file to display
image - will load an image to display (PNG/JPG/SVG)
infobutton - sets the file to display when the button is clicked This can be a local html file, or a URL.
If a full file path is not given, file() will search in the current directory, i.e., the directory that contains the csd file that is open. It is best to keep all files in the same directory as your csd file. If you wish to keep them in a separate folder use relative paths, i.e, ../../folder.
Avoid absolute path at all costs. Failure to do so will most likely problems with your instruments as soon as you share them.
"fill": 1Fill determines if the genTable waveform should be filled or drawn as an outline. Set to 1 for filled, 0 for outline.
"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 asgroupBox,rotarySliderandnumberSlider.numberSlideralso acceptsleftandrightto 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
Section titled “Persistence”"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: Whentrue, the widget's current value/state is included when using Csound'scabbageSaveStateopcode to save preset data. Set tofalsefor widgets that should not persist in Csound preset files (e.g., widgets that load presets).session: Whentrue, the widget's state is included when the DAW saves a preset. Set tofalsefor 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.
"range": {"y": {"min": -1, "max": 1}}Sets the vertical display range of the genTable waveform. min and max define the values shown at the bottom and top of the widget.
Sample Range
Section titled “Sample Range”"range": {"x": {"start": 0, "end": -1}}Sets the visible sample range on the genTable's X axis. start and end are sample indices; an end of -1 uses the last sample. These values can be changed in real-time to enable zooming.
Samples
Section titled “Samples”"samples": []Samples contains the audio sample data for genTable widgets. This is typically managed internally by Cabbage.
Selectable Regions
Section titled “Selectable Regions”"selectableRegions": trueWhen enabled, users can click and drag on the waveform to select a region of samples. The selected region is highlighted with a semi-transparent overlay.
Behavior:
- Click and drag: Select a region by clicking on the waveform and dragging to define the selection boundaries
- Click without drag: Clicking without dragging (less than 3 pixels of movement) clears the current selection
- Visual feedback: Selected regions are shown with a semi-transparent overlay
- Channel output: When a region is selected, the start and end sample indices are automatically sent to Csound via the configured channels (see
channelGentable)
This feature is useful for selecting portions of audio for processing, looping, or analysis.
Table Number
Section titled “Table Number”"tableNumber": 1Sets the function table to be displayed by the genTable widget.
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, "borderRadius": 4, "borderWidth": 1, "borderColor": "#dddddd11", "strokeColor": "#dddddd", "strokeWidth": 1, "fillColor": "#ffffff11", "backgroundColor": "#00000000", "fontFamily": "Verdana", "fontSize": "auto", "fontColor": "#dddddd", "textAlign": "left", "logarithmic": false},backgroundColorfills the area behind the waveform, whilefillColoris the waveform colour whenfillis1.strokeColorandstrokeWidthcontrol the waveform outline whenfillis0.logarithmicdisplays the waveform using logarithmic scaling.- Label typography is configured with
fontFamily,fontSize,fontColorandtextAlign. - Colors accept named CSS colors, hex (e.g., #RRGGBB or #RRGGBBAA), or rgb/rgba strings.
Csound Usage
Section titled “Csound Usage”The genTable display is kept in sync from Csound with cabbageSet. Use the trigger value from a widget channel to gate the update so the table only redraws when something changes:
fillRes:CabbageNumTrig = cabbageGetValue("fill")cabbageSet(fillRes.trig, "gentable1", "fill", fillRes.val)cabbageSet("gentable1", "tableNumber", 1)To fill the table with your own samples, regenerate its function table in Csound and then point the widget at it with tableNumber. The example below rebuilds table 1 from five harmonic amplitudes passed as p4–p8, optionally inverting it, and refreshes the display:
instr UpdateTable normal:i = (cabbageGetValue:i("normal") == 0 ? -1 : 1) sumTable = ftgen(1, 0, 1024, 10*normal, p4, p5, p6, p7, p8) cabbageSet("gentable1", "tableNumber", 1) ; update table displayendinRelated slider values are read at k-rate in the usual way, and a changed trigger fires the update instrument only when one moves:
harm1:k = cabbageGetValue("harm1")trigger:k = changed(harm1, harm2, harm3, harm4, harm5)if trigger == 1 then event("i", "UpdateTable", 0, .01, harm1, harm2, harm3, harm4, harm5)endifExample
Section titled “Example”<Cabbage>{ "pluginId" : "def1", "enableDevTools": true, "channelConfig" : [ {"name": "0 in 2 out", "ins": "0", "outs": "2"} ], "widgets" : [ { "type": "form", "caption": "Gentable Example", "size": {"width": 400, "height": 650}, "guiMode": "queue" }, { "type": "genTable", "bounds": {"left": 10, "top": 7, "width": 380, "height": 200}, "id": "gentable1", "tableNumber": 1 }, { "type" : "horizontalSlider", "bounds" : {"left": 14, "top": 212, "width": 368, "height": 14}, "channels": [ { "id": "harm1", "range": {"min": 0, "max": 1, "value": 1, "skew": 1, "increment": 0.01} } ], "label" : {"text": "Harm1"} }, { "type" : "horizontalSlider", "bounds" : {"left": 14, "top": 244, "width": 368, "height": 14}, "channels": [ { "id": "harm2", "range": {"min": 0, "max": 1, "value": 0, "skew": 1, "increment": 0.01} } ], "label" : {"text": "Harm2"} }, { "type" : "horizontalSlider", "bounds" : {"left": 14, "top": 276, "width": 368, "height": 14}, "channels": [ { "id": "harm3", "range": {"min": 0, "max": 1, "value": 0, "skew": 1, "increment": 0.01} } ], "label" : {"text": "Harm3"} }, { "type" : "horizontalSlider", "bounds" : {"left": 14, "top": 308, "width": 368, "height": 14}, "channels": [ { "id": "harm4", "range": {"min": 0, "max": 1, "value": 0, "skew": 1, "increment": 0.01} } ], "label" : {"text": "Harm4"} }, { "type" : "horizontalSlider", "bounds" : {"left": 14, "top": 340, "width": 368, "height": 14}, "channels": [ { "id": "harm5", "range": {"min": 0, "max": 1, "value": 0, "skew": 1, "increment": 0.01} } ], "label" : {"text": "Harm5"} }, { "type" : "checkBox", "bounds" : {"left": 16, "top": 380, "width": 120, "height": 20}, "channels": [ {"id": "normal"} ], "label" : {"text": "Normalise"}, "value" : 1 }, { "type" : "checkBox", "bounds" : {"left": 140, "top": 380, "width": 120, "height": 20}, "channels": [ {"id": "fill"} ], "label" : {"text": "Fill Table"}, "value" : 1 } ]}
</Cabbage><CsoundSynthesizer><CsOptions>-d -n -m0d</CsOptions><CsInstruments>;sr is set by the hostksmps = 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.sumTable@global:i = ftgen(1, 0, 1024, 10, 1)
//fill table with default valuesschedule("UpdateTable", 0, 0, 1, 0, 0, 0, 0, 0)
instr 1
;toggle fill fillRes:CabbageNumTrig = cabbageGetValue("fill") cabbageSet(fillRes.trig, "gentable1", "fill", fillRes.val)
harm1:k = cabbageGetValue("harm1") harm2:k = cabbageGetValue("harm2") harm3:k = cabbageGetValue("harm3") harm4:k = cabbageGetValue("harm4") harm5:k = cabbageGetValue("harm5")
outSig:a = oscili(.2, 200, 1) outs(outSig, outSig)
trigger:k = changed(harm1, harm2, harm3, harm4, harm5) if trigger==1 then ;if a slider changes trigger instrument 2 to update table event("i", "UpdateTable", 0, .01, harm1, harm2, harm3, harm4, harm5) endif
endin
instr UpdateTable normal:i = (cabbageGetValue:i("normal")==0 ? -1 : 1) sumTable = ftgen(1, 0, 1024, 10*normal, p4, p5, p6, p7, p8) cabbageSet("gentable1", "tableNumber", 1) ; update table displayendin
</CsInstruments><CsScore>f1 0 1024 10 1i1 0 [3600*24*7]</CsScore></CsoundSynthesizer>Loading audio files
Section titled “Loading audio files”Files can be loaded straight into a genTable widget. The example below uses a fileButton to pick a file and cabbageSet to load it:
<Cabbage>{ "pluginId" : "def1", "enableDevTools": true, "channelConfig" : [ {"name": "0 in 2 out", "ins": "0", "outs": "2"} ], "widgets" : [ { "type": "form", "caption": "Gentable Example", "size": {"width": 400, "height": 650}, "guiMode": "queue" }, { "type" : "genTable", "bounds" : {"left": 10, "top": 7, "width": 380, "height": 200}, "id" : "gentable1", "tableNumber" : 1, "selectableRegions": true }, { "type" : "fileButton", "bounds" : {"left": 14, "top": 212, "width": 80, "height": 24}, "channels": [ {"id": "fileToOpen"} ], "text" : {"off": "Open File", "on": "Open File"} } ]}
</Cabbage><CsoundSynthesizer><CsOptions>-d -n -m0d</CsOptions><CsInstruments>;sr is set by the hostksmps = 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 fileRes:CabbageStrTrig = cabbageGetValue("fileToOpen") printf("File selected:%s", fileRes.trig, fileRes.val) cabbageSet(fileRes.trig, "gentable1", "file", fileRes.val)endin
</CsInstruments><CsScore>f1 0 1024 10 1i1 0 [3600*24*7]</CsScore></CsoundSynthesizer>