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 max(val), markerColour("colour"), markerThickness(value), markerStart(value), markerEnd(value), min(val), outlineColour("colour"), popupText("text"), popupText("text"), popupPostfix("text"), range(min, max, value, skew, incr), filmstrip("filename", numFrames, removeA,), imgFile("type", "file"), sliderbounds(x, y, width, height), textColour("colour"), text("name"), trackerThickness(val), trackerInsideRadius(val), trackerOutsideRadius(val), textBoxOutlineColour("colour"), textBoxColour("colour"), trackerColour("colour"), 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), presetIgnore(val), valuePrefix("valuePrefix"), valuePostfix("valuePostfix"), rotate(radians, pivotx, pivoty), visible(val), toFront(), widgetArray("chan", number),

Specific Identifiers

max(val) If using a double or triple pointer slider (hslider2, hslider3, vslider2, vslider3), max() will set the default maximum position of the maximum thumb controller. The absolute maximum is set using the range identifier. See above.

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.

min(val) If using a double or triple pointer slider (hslider2, hslider3, vslider2, vslider3), min() will set the default minimum position of the minimum thumb controller. The absolute minimum is set using the range identifier. See above.

outlineColour("colour") Sets the colour of a rotary slider`s tracker outline. 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 defaul text which displays the channel name and the current value. Passing a 0 will disable all popupText notices completely.

<!--UPDATE WIDGETINCSOUND SIdent sprintf "popupText(\"Popup Text %d\") ", rnd(1000) SIdentifier strcat SIdentifier, SIdent --> Not available to nslider

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 defaul text which displays the channel name and the current value. Passing a 0 will disable all popupText notices completely. 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.

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 pass a unique svg file to use instead of the default look and feel. "type" should be one of the following:

  • "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("name") The string passed in for "name" will appear on a label beside the slider. This is useful for naming sliders.

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.

<!--UPDATE WIDGETINCSOUND SIdent sprintf "trackerThickness(%f) ", rnd(10) SIdentifier strcat SIdentifier, SIdent --> 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

<!--UPDATE WIDGETINCSOUND SIdent sprintf "trackerInsideRadius(%f) ", rnd(10)/10 SIdentifier strcat SIdentifier, SIdent --> 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

<!--UPDATE WIDGETINCSOUND SIdent sprintf "trackerOutsideRadius(%f) ", rnd(10)/10 SIdentifier strcat SIdentifier, SIdent --> 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.

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") "chan" is the name of the channel that Cabbage will communicate with Csound on. The current value of this widget can be retrieved in Csound using a chnget opcode, or can be set using a chnset opcode.

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 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

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 "".

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 "".

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 takses no arguments and is only intended for use with identifier channels.

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>