SCMultiSliderView a richly configurable view for graphically displaying and editing an array of values

Inherits from: Object : SCView

SCMultiSliderView on the surface is like a group of sliders. However, various graphical options allow you to use it for displaying and editing graphic representations of array values. It is also the super class of SCEnvelopeView.

See also: SCEnvelopeView

Some Important Issues Regarding SCMultiSliderView

If no instance variables other than parent and bounds are set, then a multislider with bounds.width/12 sliders is created. However, the default thumbSize is 12 and the gap default is 1. The view width has to be 13*n+2 for all the sliders to automatically fit in the view.

So if you want a specific number of sliders, then it is best to specify the size and set elasticMode to 1. Then you will get a multislider which distrubutes size amount of sliders over bounds.width, where the slider widths are at maximum indexThumbSize (default 12) and the gap is adusted accordingly.

Creation / Class Methods

*new (parent, bounds)

parent - The parent view.

bounds - An instance of Rect, or a Point indicating width@height.



w =;

m = MultiSliderView(w,Rect(10,10,n*13+2,100)); //default thumbWidth is 13

m.value=Array.fill(n, {|v| v*0.05}); // size is set automatically when you set the value

m.action = { arg q;




Accessing Instance and Class Variables



Gets/sets the size of the array returned by action, if you explicitly set the size. If you do not set the size nor value, then the size of the array returned by action will be the amount of sliders in the view, which is bounds.width/12. Changing size, after the the multislider has been drawn or after the value array has been set, will lead to unexpected results. Instead, you should change the content of value, if you need to change the multislider contents.

arg1 - An Integer.

indexIsHorizontal_ (val)

Determines the index direction (vertical/horizontal) of the slider.

val - An instance of Boolean. Default is true.


editable_ (val)

Determines if the sliders are editable. If editable is false, the multislider will still execute action on mouse click.

val - An instance of Boolean.

readOnly_ (val)

val - boolean.


step_ (stepSize)

Quantizes the values to the nearest multiple of stepSize.

stepSize - An instance of Float.

Accessing and Setting Values


value_ (val)

Gets/sets the property, \value, by calling get/setProperty(\value, val). The setter also sets size to the size of val. This will not do the action of the slider.

val - An instance of Array.

valueAction_ (val)

Sets the property, \value, by calling setPropertyWithAction(\value, val). Also sets size to the size of val. Does the sliders action.

val - An instance of Array.


index_ (inx)

Gets/sets the first index of the selection range.

inx - an integer.


selectionSize_ (aval)

Gets/sets the size of the selection. Can be 0.

aval - An integer.

startIndex_ (val)

val - An integer.


currentvalue_ (iny)

Gets/sets the value at the current index.

iny - A float between 0 and 1.


reference_ (val)

Sets a reference value, and draws it according to other drawing options: as a line, or a thumb.

val - An Array of Floats between 0 and 1;



Gets/sets a function to be evaluate on Ctrl-click

arg1 - An instance of Function. Default value is nil.

Customizing Appearance

showIndex_ (abool)

Highlights the currently selected index.

abool - An Instance of Boolean. Default is false.


elasticMode_ (mode)

Determines if the sliders are distributed over the width of the view. If resize is 2, 3, or 8, then the width and gap of the individual sliders will adjust automatically using a maximum slider with of thumbSize.

mode - 0 or 1

thumbSize_ (val)

Sets the indexThumbSize_ of the sliders. If elasticMode is 1, then it determines the maximum indexThumbSize of the slider as well as the valueThumbSize.

val - A Float or Integer.

indexThumbSize_ (val)

The size of the slider thumb in the index direction.

val - A Float or Integer.

valueThumbSize_ (val)

The size of the slider thumb in the value direction.

val - A Float or Integer.

drawLines (abool)

drawLines_ (abool)

Draws connecting lines between the values.

abool - An instance of Boolean. default is false.

drawRects_ (abool)

Draws the thumbs of the sliders.

abool - An instance of Boolean. default is true.


gap_ (inx)

Set/get the property, \xOffset, which is gap between the sliders. This value is ignored if elasticMode is set to 1.

inx - An integer.

isFilled_ (abool)

If set to true, this extends the thumb-rectangle to the edge, like in a bar graph. Fills the area between 0 and the value, or between 0 and the reference, depending on other draw options. If drawLines_(true) and drawRects_(false) and isFilled_(true), then it will fill the value between the value and the reference only.

abool - An instance of Boolean.



w =;

m = MultiSliderView(w,Rect(10,10,20*13+2,100)); //default thumbWidth is 13


m.value=Array.fill(n, {|v| 1.0.rand});

m.reference=Array.fill(n, {|v| 0.5});

m.action = { arg q;q.value.postln; };

m.isFilled_ (true);





fillColor_ (acolor)

The fill color of the view.

acolor - An instance of Color.

strokeColor_ (acolor)

The line color of the view.

acolor - An instance of Color.

colors_ (strokec, fillc)

Sets the stroke and fill colors of the graph.

strokec - An instance of Color.

fillc - An instance of Color.

Subclassing and Internal Methods

The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.

defaultKeyDownAction (char, modifiers, unicode)

The default keydown actions are:

key action comment

unicode 16rF703, increment index by 1 right arrow

unicode 16rF702, decrement index by 1 left arrow

unicode 16rF700, decrement gap by 1 up arrow

unicode 16rF701, increment gap by 1 down arrow


A list of properties to which this view responds. See SCView.


[ \bounds, \visible, \enabled, \canFocus, \resize, \background, \minWidth, \maxWidth, \minHeight, \maxHeight, \value, \thumbSize, \fillColor, \strokeColor, \xOffset, \x, \y, \showIndex, \drawLines, \drawRects, \selectionSize, \startIndex, \referenceValues, \thumbWidth, \absoluteX, \isFilled, \step, \elasticResizeMode ]


The method called by default when initiating a drag from an SCNumberBox.

Tho following describes the defaultbehavior:

a) if selectionSize is 0, returns the content of value (an Array):

b) if selectionSize > 1, returns an Array with the values at the indexes in the selection;

if references is not nil, returns an array containing (a) or (b) , and an array of the relevant reference values ; [ [values], [references] ]


The method called by default when attempting to place a drag in this object. Will recieve any drag, but the drag should either be an array of values, ( [ values ] ), or an array containg an array of values and an array of reference values ( [ [values], [references] ] ).


The default method called when a drag has been received. If the currentDrag is a String, then Performs value_() and reference_() using currentDrag as an argument. Does not perform the action.


Not normally called directly (called by the primitive).


// basic



w =;

m = MultiSliderView(w,Rect(10,10,n*13+2,100)); //default thumbWidth is 13

m.value=Array.fill(n, {|v| v*0.05}); // size is set automatically when you set the value

m.action = { arg q;




// looks like a candlestick graph


var size;

size = 350 / 6;

w =;

w.view.decorator = FlowLayout(w.view.bounds);

m = MultiSliderView(w, Rect(0, 0, 350, 100));

m.value_(Array.fill(size, {0.01}));

m.isFilled_(true); // width in pixels of each stick

m.indexThumbSize_(2.0); // spacing on the value axis




// rotate the above graph


m.bounds_(Rect(0, 0, 100, 350));



Interactive Example (explains all the graphic options)



w = Window("MultiSlider Options", Rect(200, Window.screenBounds.height-550, 600, 450));


w.view.decorator = FlowLayout( w.view.bounds, 10@10, 10@2 );

m = MultiSliderView(w,Rect(0,0,580,200)); // default thumbWidth is 13

m.value=Array.fill(n, {|v| 0.5+((0.3*v).sin*0.25)});

m.action = { arg q;q.value.postln; };

StaticText(w,380@18).string_("indexThumbSize or thumbSize");

Slider(w,580@10).action_({arg sl; m.indexThumbSize=sl.value*24}).value_(0.5);


Slider(w,580@10).action_({arg sl; m.valueThumbSize=sl.value*24}).value_(0.5);

StaticText(w,580@18).string_("xOffset or gap");

Slider(w,580@10).action_({arg sl;0.5- m.xOffset=sl.value*50});


Slider(w,580@10).action_({arg sl; m.setProperty(\startIndex, sl.value *m.size )};);



.action_({ w.view.removeAll; f.value; });


Button(w,100@20).states_([["elasticMode = 0"],["elasticMode = 1",Color.white]])

.action_({|b| m.elasticMode = b.value});

Button(w,160@20).states_([["indexIsHorizontal = false"],["indexIsHorizontal = true",Color.white]])

.action_({|b| m.indexIsHorizontal = b.value.booleanValue}).value_(1);

Button(w,120@20).states_([["isFilled = false"],["isFilled = true",Color.white]])

.action_({|b| m.isFilled = b.value.booleanValue});

Button(w,120@20).states_([["drawRects = false"],["drawRects = true",Color.white]])

.action_({|b| m.drawRects = b.value.booleanValue}).valueAction_(1);

Button(w,100@20).states_([["drawLines = false"],["drawLines = true",Color.white]])

.action_({|b| m.drawLines = b.value.booleanValue});

Button(w,160@20).states_([["readOnly = false"],["readOnly = true",Color.white]])

.action_({|b| m.readOnly = b.value.booleanValue});

Button(w,120@20).states_([["showIndex = false"],["showIndex = true",Color.white]])

.action_({|b| m.showIndex = b.value.booleanValue});

Button(w,120@20).states_([["reference = nil"],["reference filled",Color.white],["reference random",Color.yellow]])

.action_({|b| b.value.booleanValue.if({


{m.reference=Array.fill(n, {1.0.rand})},

{m.reference=Array.fill(m.size, {0.5})});

},{ q=m.value;m.reference=[]; h.string="reference can't be returned to nil presently. please hit RESET."}



Button(w,180@20).states_([["fillColor = Color.rand"]]).action_({m.fillColor=Color.rand});

Button(w,180@20).states_([["strokeColor = Color.rand"]]).action_({m.strokeColor=Color.rand});

Button(w,180@20).states_([["background = Color.rand"]]).action_({m.background=Color.rand});





Load a Sound file


// press shift to extend the selection

// use as waveView: scrubbing over the view returns index

// if showIndex(false) the view is not refreshed (faster);

// otherwise you can make a selection with shift - drag.

var size, file, maxval, minval;

size = 640;

a = Window("test", Rect(200 , 140, 650, 150));

a.view.decorator = FlowLayout(a.view.bounds);

b = MultiSliderView(a, Rect(0, 0, size, 50));



d =;

c = FloatArray.newClear(65493);

r = Slider( a, Rect(0, 0, size, 12));

r.action = {arg ex; b.setProperty(\xOffset, (ex.value * 4) + 1 )};

file =;




// file.inspect;


minval = 0;

maxval = 0;

f =;

d =;{arg fi, i;

if(fi < minval, {minval = fi});

if(fi > maxval, {maxval = fi});


if(i % 256 == 0,{

d = d.add((1 + maxval ) * 0.5 );

f = f.add((1 + minval ) * 0.5 );

minval = 0;

maxval = 0;



b.reference_(d); // this is used to draw the upper part of the table


r = Slider( a, Rect(0, 0, size, 12));

r.action = {arg ex; b.setProperty(\startIndex, ex.value *f.size )};

// b.enabled_(false);

b.action = {arg xb; ("index: " ++ xb.index).postln};












Use as Sequencer

// example with sound


var size;

size = 12;


n={arg freq=330;,0,0.2)}.play;

w = Window("test", Rect(200 , 450, 10 + (size * 17), 10 + (size * 17)));

w.view.decorator = FlowLayout(w.view.bounds);

b = MultiSliderView(w, Rect(0, 0, size * 17, size * 17));

b.value_( Array.fill(size,{|i| i/size}) );


b.action = {arg xb;

n.set(\freq, 330+(1100*;

("index: " ++ xb.index ++" value: " ++};

b.elasticMode_(1); // makes the squares fit evenly

b.setProperty(\showIndex, true); // cursor mode



r = Routine({

0.1.wait;{ arg i;




});{ arg i;










Note: this forces the entire view to redraw at each step and will spend a lot of CPU.