extMultiSliderView

clean-up: #36

in november 2011 there was some discussion on the sc-users mailinglist about a multislider point scroll similar to the one in maxmsp. there were many nice suggestions in the thread, but as so often nothing got decided/implemented. below is my suggestion - a simple fifo.

extMultiSliderView from redFrik on Vimeo.

here is the class extension...

//for sc3.6 or earlier
//copy and save as extSCMultiSliderView.sc in extensions folder
+SCMultiSliderView {
        add {|val|
                this.value= this.value.copyRange(1, this.value.size-1)++val;
        }
        addFirst {|val|
                this.value= val.asArray++this.value.copyRange(0, this.value.size-2);
        }
}
+QMultiSliderView {
        add {|val|
                this.value= this.value.copyRange(1, this.value.size-1)++val;
        }
        addFirst {|val|
                this.value= val.asArray++this.value.copyRange(0, this.value.size-2);
        }
}

note that if you're using the latest sc3.7, then the GUI redirect classes are gone and you need to write the class extensions like the following...

//for sc3.7 or newer
//copy and save as extMultiSliderView.sc in extensions folder
+MultiSliderView {
        add {|val|
                this.value= this.value.copyRange(1, this.value.size-1)++val;
        }
        addFirst {|val|
                this.value= val.asArray++this.value.copyRange(0, this.value.size-2);
        }
}

and here are the examples from the video...

//--basic example
(
var n= 100; //number of sliders
var w= Window("scroll test").front;
var a= MultiSliderView(w, Rect(10, 10, w.bounds.width-20, w.bounds.height-20));
a.elasticMode= 1;
a.value= Array.fill(n, {0});
Routine({
        inf.do{|i|
                0.05.wait; //scroll speed
                a.addFirst(sin(i/10)*0.5+0.5); //try .add instead of .addFirst
        };
}).play(AppClock);
CmdPeriod.doOnce({w.close});
)

//--example with sound input
(
s.waitForBoot{
        var n= 100; //number of sliders
        var w= Window("scroll test audio").front;
        var a= MultiSliderView(w, Rect(0, 0, w.bounds.width, w.bounds.height));
        var b= {
                var src= SoundIn.ar; //mic input
                SendReply.kr(Impulse.kr(60), '/trk', Amplitude.kr(src, 0.1, 0.1));
                DC.ar(0); //silence
        }.play;
        a.elasticMode= 1;
        a.valueThumbSize= 8;
        a.indexThumbSize= 1;
        a.drawLines= true;
        a.value= Array.fill(n, {0});
        OSCFunc({|msg| {a.addFirst(msg[3])}.defer}, '/trk');
        CmdPeriod.doOnce({w.close});
};
)

also see Marije's SWPloterMonitor from her same day clean-up.