Skip to content

Instantly share code, notes, and snippets.

@yratof
Created October 16, 2018 14:06
Show Gist options
  • Save yratof/0d23796397d19ce040ed5e68c91779fc to your computer and use it in GitHub Desktop.
Save yratof/0d23796397d19ce040ed5e68c91779fc to your computer and use it in GitHub Desktop.
DigitalIn for Supercollider
(
~ctrl = {
var d0 = DigitalIn.ar(0); // Button on pin D0, set to 0 state then 1 when pressed
SendReply.kr(Impulse.kr(10), '/ctrl', [d0]); // Pulse, symbol, [data]
}.play;
x = {
arg t_trig=0, t_freq=440;
var sig;
sig = SinOsc.ar (t_freq, 0, 0.2!2);
sig = sig * Env.perc(0.02,4).kr(0,t_trig);
}.play;
OSCdef('listen', {
arg msg;
x.set(\t_trig, msg[3].asInteger); // This can trigger a sound, but surely OSCdef is a bad place for triggers
}, '/ctrl');
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment