Sliders

Slider can be used to create an on-screen slider. Data can be sent to Csound on the channel specified through the channel string. Sliders can be rotary, vertical, horizontal, range-based, or number boxes, and can react in both a linear and non-linear fashion.

slider gapMarkers(val), markerColour("colour"), markerThickness(value), markerStart(value), markerEnd(value), outlineColour("colour"), popupText("text"), popupPrefix("text"), popupPostfix("text"), range(min, max, value, skew, incr), defaultValue(val), filmstrip("filename", numFrames, removeA,), imgFile("type", "file"), sliderBounds(x, y, width, height), textColour("colour"), text("string"), trackerThickness(val), trackerInsideRadius(val), trackerOutsideRadius(val), textBoxOutlineColour("colour"), textBoxColour("colour"), trackerColour("colour"), trackerBackgroundColour("colour"), trackerStart(val), trackerEnd(val), trackerCentre(val), valueTextBox(val), valueTextBoxBounds(x, y, width, height), velocity(val), active(val), alpha(val), automatable(val), bounds(x, y, width, height), channel("chan"), colour("colour"), fontColour("colour"), identChannel("channel"), popup(val), parent(val), presetIgnore(val), valuePrefix("valuePrefix"), valuePostfix("valuePostfix"), rotate(radians, pivotx, pivoty), visible(val), toFront(), moveBehind("widgetName"), widgetArray("chan", number),

Specific Identifiers


gapMarkers(val) Sets whether gap markers will be visible in slider. These are the lines that denote the position of the thumb in relation to the slider.


markerColour("colour") This sets the colour of the marker in a rotary slider. 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.


markerThickness(value) Sets the thickness of the a rotary slider's marker. Set to 0 to disable.


markerStart(value) Sets where to start drawing a rotary slider's marker segment. Value should be between 0 and 1. 0 is the center of the knob.


markerEnd(value) Sets where to draw the end point of a rotary slider's marker segment. Value should be between 0 and 1. 0 is the center of the knob.


outlineColour("colour") Sets the colour of a button outline, or a rotary slider`s tracker outline. In the case of rslider's this is the line that is drawn around the rslider's tracker. If you don't wish to display the tracker outline set the colour to something with an alpha value of 0. See above for details on valid colours.


popupText("text") Sets the text that will appear in the popup text bubble when a user hovers over the widget. This can be used to override the default text which displays the channel name and the current value. Passing a 0 will disable all popupText notices completely. Not available to nslider


popupPrefix("text") Sets the text that will prefix what appear in the popup text bubble when a user hovers over the widget. Not available to nslider


popupPostfix("text") Sets the postfix text that will appear in the popup text bubble. This string will appear just after the current value of the slider. Although nslider's don't use popup bubbles, this identifier will set a value postfix.


range(min, max, value, skew, incr) the first 2 parameters are required. The rest are optional. The first two parameters let you set the minimum value and the maximum value. The next parameter determines the initial value of the slider. The 4th parameter allows you to adjust the skew factor. Tweaking the skew factor will cause the slider to output values in a non linear fashion. A skew of 0.5 will cause the slider to output values in an exponential fashion. A skew of 1 is the default value, which causes the slider to behave is a typical linear form. The final parameter sets the incremental step size for the slider. If you need to have very fine control of steps you may wish to look at using an Endless Encoder instead.

range() can not be updated or modified once a widget has been declared.


defaultValue(val) Sets the default value for a sliders. This is the value the slider will jump to on a double click.


filmstrip("filename", numFrames, removeA,) The filmstrip identifier allow users to use a filmstrip style .png to skin sliders. filename is the name of the .png file to be used. numFrames is the number of frames in the film strip image. removeA and removeB will reScale the underlying slider object, which is invisible due to the skin laid on top of it. For example, in the case of a hslider, removeA(.1) will remove .1 of the overall length of the slider from the left side, removeB(.1) will remove .1 of the overall length from the right. This allows one to reScale sliders according to where their skin images start and end.

For a vslider removeA and removeB refer to the top and bottom of the slider. See the KnobManSlider.csd file in the Misc. examples for more details. This idetnfier only works with vertical framed images.

Try to avoid full path names at all costs. They will work fine on a local machine, but will not be valid on another machine.


imgFile("type", "file") Use this identifier to set a unique .svg or .png file to be used instead of the default look and feel. "type" should be one of the following:

Buttons:
- "on" : sets the button image when it is on - "off" : sets the button image when it is off
Sliders:
- "background" : sets the slider background image - "slider" : sets the slider thumb, or in the case of a rotary slider, the inner circle. This image moves in sympathy with that the mouse as users move the slider.

For more information see Using SVGs and PNGs


sliderBounds(x, y, width, height) Sets the x, y, width and height of a slider within a Cabbage slider component. The default size is automatically calculated by Cabbage depending on the size of the slider. Modify this only if you need to tweak the slider's position within its parent.


textColour("colour") This set the colour of the text passed to text(). If you wish to change the colour of the numbers being displayed use fontColour(). See below. See above for details on valid colours.


text("string") "string" will be the text that appears on the widget. button widgets take two strings, one for on and one for off.


trackerThickness(val) Sets the thickness of the slider's tracker, 1 being full thickness. This is the line that follows the slider when you move it. To disable the tracker you can set its thickness to 0 or it's alpha colour channel to 0.

Not available for rsliders


trackerInsideRadius(val) Sets the inner radius of a rotary tracker, proportional to the overall rotary slider size. val should be in the range 0 to 1

Only available to rsliders


trackerOutsideRadius(val) Sets the outer radius of a rotary tracker, proportional to the overall rotary slider size. val should be in the range 0 to 1 Only available to rsliders


textBoxOutlineColour("colour") Sets the colour of the outline of the value text box used to display the slider's value when textBox is enable. See above for details on valid colours.


textBoxColour("colour") Sets the colour of the background of the value text box used to display the slider's value when textBox is enable. See above for details on valid colours.


trackerColour("colour") Sets the colour of the slider's tracker. This is the line that follows the slider when you move it.


trackerBackgroundColour("colour") Sets the colour of the slider's tracker background. This is the colour that sits behind trackers line that follows the slider when you move it.


trackerStart(val) Sets where Cabbage will start drawing the rotary slider tracker. This is a value between 0 and 1, where 0 and 1 represent 6 o'clock. The default value is .1.


trackerEnd(val) Sets where Cabbage will stop drawing the rotary slider tracker. This is a value between 0 and 1, where 0 and 1 represent 6 o'clock. The default value is .9.


trackerCentre(val) Sets where Cabbage will start drawing the tracker progress from. This is a value between 0 and 1, where 0 and 1 represent 6 o'clock. The default value is .9.

This value should always be within the trackerStart() and trackerEnd() points. If not, your slider will look quite strange!


valueTextBox(val) textBox takes a 0 or a 1. 1 will cause a text box to appear with the sliders values. Leaving this out will result in the numbers appearing automatically when you hover over the sliders with your mouse.


valueTextBoxBounds(x, y, width, height) Sets the x, y, width and height of a slider's value text box. The default size is automatically calculated by Cabbage depending on the size of the slider.


velocity(val) Sets the sensitivity of the slider to mouse movement. The value passed should be in the range of 1 upwards. Note that velocity mode will only work if the range of the slider is greater than the distance in pixels between min and max.

Common Identifiers


active(val) Will deactivate a control if 0 is passed. Controls which are deactivate can still be updated from Csound.


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.


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.


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("colour") This sets the main colour. 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.


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.


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.
Not available to nslider


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.


presetIgnore(val) Defaults to 0. Set this to 1 to ignore this widget's value when a preset is taken.


valuePrefix("valuePrefix") Sets the prefix that is prepended to parameter values when displayed in the host and the plugin GUI. Defaults to "". xypad widgets take two strings, one of the x values, and one for the y values.


valuePostfix("valuePostfix") Sets the postfix that is appended to parameter values when displayed in the host and the plugin GUI. This can be helpful to make the units of parameters clear to the user (e.g. "Hz", "dB", etc.). Defaults to "". xypad widgets take two strings, one of the x values, and one for the y values.


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.


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

Slider types:

  • rslider, a standard rotary or knob slider

  • hslider, a standard horizontal slider

  • vslider, a standard vertical slider

  • hslider2, two value horizontal range slider (deprecated, use hrange)

  • vslider2, two value vertical range slider (deprecated, use vrange)

  • nslider, a number box slider in the style of Pure Data /MaxMSP

Make sure to use two unique channel names when using hslider2 and vslider2, otherwise min and max will be set to the same value.

Example

<Cabbage>
form caption("Slider Example") size(360, 460), guiMode("queue"), colour(2, 145, 209) pluginId("def1")

texteditor bounds(16, 254, 332, 191) channel("infoText"), readOnly(1), wrap(1), scrollbars(1)

vslider bounds(20, 20, 40, 180) channel("harmonic1") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(60, 20, 40, 180) channel("harmonic2") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(100, 20, 40, 180) channel("harmonic3") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(140, 20, 40, 180) channel("harmonic4") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(180, 20, 40, 180) channel("harmonic5") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(220, 20, 40, 180) channel("harmonic6") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(260, 20, 40, 180) channel("harmonic7") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
vslider bounds(300, 20, 40, 180) channel("harmonic8") range(0, 1, 0, 1, 0.001), imgFile("slider", "Fader.png")
checkbox bounds(24, 208, 100, 30) channel("randomise"), colour:1(147, 210, 0), text("Randomise"), fontColour:1("white")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</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. 

giWave ftgen 1, 0, 4096, 10, 1, .2, .1, .2, .1

instr 1

    SText  = "Slider widgets in Cabbage come in a variety of styles. Almost all the widget examples use sliders in some way or another. This simple instrument uses vslider widgets. The fader thumb uses an image loaded from disk. When the 'Randomise' button is pushed, each slider has its position updated according to a simple spline curve.\n\nCabbage sliders can load images for their various parts, background, thumb, etc., or they can use film strips / sprite-sheet type PNGs that contain frames of each state."
    cabbageSet "infoText", "text", SText

    a1 oscili tonek(cabbageGetValue:k("harmonic1"), 10), 50, giWave
    a2 oscili tonek(cabbageGetValue:k("harmonic2"), 10), 100, giWave
    a3 oscili tonek(cabbageGetValue:k("harmonic3"), 10), 150, giWave
    a4 oscili tonek(cabbageGetValue:k("harmonic4"), 10), 200, giWave
    a5 oscili tonek(cabbageGetValue:k("harmonic5"), 10), 250, giWave
    a6 oscili tonek(cabbageGetValue:k("harmonic6"), 10), 300, giWave
    a7 oscili tonek(cabbageGetValue:k("harmonic7"), 10), 350, giWave
    a8 oscili tonek(cabbageGetValue:k("harmonic8"), 10), 400, giWave

    kRandom cabbageGet "randomise"

    if kRandom == 1 then
        cabbageSetValue "harmonic1", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic2", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic3", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic4", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic5", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic6", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic7", abs(jspline:k(.9, .1, .3))
        cabbageSetValue "harmonic8", abs(jspline:k(.9, .1, .3))
    endif

    aMix = a1+a2+a3+a4+a5+a6+a7+a8
    out aMix, aMix
endin       

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 z
</CsScore>
</CsoundSynthesizer>