Skip to content

Instantly share code, notes, and snippets.

@catfact
Last active June 25, 2016 19:54
Show Gist options
  • Save catfact/783d6fa2a886b41af7e704e8a876778b to your computer and use it in GitHub Desktop.
Save catfact/783d6fa2a886b41af7e704e8a876778b to your computer and use it in GitHub Desktop.
supercollider wave view
s = Server.local;
s.waitForBoot {
~bufsize = s.sampleRate;
~graphsize = ~bufsize / 100;
~buf = Buffer.alloc(s, ~bufsize, 1);
~in = { RecordBuf.ar(SoundIn.ar(0), ~buf.bufnum); }.play;
~delta = 0.5;
~win = Window.new("wave", Rect(0, 0, ~graphsize, 100)).front;
~graph = MultiSliderView(~win, ~win.view.bounds)
.gap_(0)
.valueThumbSize_(1)
.isFilled_(false)
.drawLines_(true)
.drawRects_(false)
.size_(~graphsize)
.readOnly_(true);
~refresh = Routine {
2.0.wait;
inf.do {
~buf.loadToFloatArray(action:{
arg a; { ~graph.value_(a.resamp0(~graphsize) * 0.5 + 0.5); }.defer;
});
~delta.wait;
}
}.play;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment