‹ Quartz Composer in SC Linear Feedback Shift Register ›

extMultiSliderView

2014-09-29 00:34 supercollider

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 MaxMSPJitter. There were many nice suggestions in the thread, but as so often nothing got decided/implemented. Below is my suggestion - a simple FIFO.

extMultiSliderView

Here is the class extension...

//for SC 3.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);
  }
}

Note that if you're using an old version of SuperCollider (<= 3.6) the class extension(s) need to look like this...

//for SC 3.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);
  }
}

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.


‹ Quartz Composer in SC Linear Feedback Shift Register ›