Skip to content

Instantly share code, notes, and snippets.

@iani
Created December 21, 2013 16:49
Show Gist options
  • Select an option

  • Save iani/8071893 to your computer and use it in GitHub Desktop.

Select an option

Save iani/8071893 to your computer and use it in GitHub Desktop.
GUI for Live Hardware Coding with SuperCollider - basic idea.
/*
//
(
// initialise ~step var (for count the current step)
~step=0;
a = LHCV((
symbol: { | self, symbol |
self.soundOn.postln;
if (self.soundOn) {
(instrument: \test, degree: (A: 11, B: 12, C: 13, D: 14)[symbol]).play;
}
},
counter: { | self, counter |
if (counter > 0) {
(instrument: \test, degree: counter).play;
~step = ~step + 1;
"~step = ".post; ~step.postln;
(type: \w, x: ~step, y: 50-(15*counter)).play;
self.soundOn = true;
}{
self.soundOn = false;
~step = ~step + 1;
(type: \w, x: ~step, y: 50).play;
}
}
)).start;
)
// change clk
a.setClk_(newValue);
// return current clk value
a.clk
*/
LHCVmonitor : LHCV {
var <x, <y;
var <>window;
var <>points;
*new { | x, y |
^super.newCopyArgs(x, y).init
}
init { | x, y |
this.prMakeMonitor;
this.addType(x, y);
}
prMakeMonitor {
points = List.new;
if(window.isNil) {
window = Window.new("monitor", Rect(100, 50, 800, 200)).front;
window.view.background_(Color.white);
window.drawFunc = {
Pen.translate(0, 100);
points.do { |point, i|
if(i == 0) { Pen.moveTo(point) } { Pen.lineTo(point) };
}; // end do
Pen.stroke;
}; // end .drawFunc
}; // endif
}
addType { | x, y |
// assign input
~x = x; ~y = y;
Event.addEventType(\w, {
points.add(Point(~x, ~y)); //
defer { monitor.value; window.refresh; };
});
CmdPeriod.doOnce({ window.close; Event.addEventType(\w, nil) });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment