Skip to content

Instantly share code, notes, and snippets.

@catfact
Last active December 7, 2020 01:42
Show Gist options
  • Select an option

  • Save catfact/2f591c7fa2d4e89a3358875bf8133896 to your computer and use it in GitHub Desktop.

Select an option

Save catfact/2f591c7fa2d4e89a3358875bf8133896 to your computer and use it in GitHub Desktop.
Zonsp (onsets with pitch in supercollider)
z = Zonsp.new(Crone.server, Crone.context.pitch_in_b[0].index)
// onsets with pitch
Zonsp {
var <synth;
var <responder;
var trig_id = 0;
var adc_channel = 0;
*new { arg server, pitch_bus;
^super.new.init(server, pitch_bus)
}
init { arg server, pitch_bus;
synth = {
arg onset_threshold=0.1,
onsets_delay = 0;
var hz = In.kr(pitch_bus);
var input = SoundIn.ar(adc_channel);
var chain = FFT(LocalBuf(512), input);
var onsets = DelayC.kr(Onsets.kr(chain, onset_threshold, \rcomplex), onsets_delay);
//hz.poll;
SendTrig.kr(onsets, trig_id, hz);
}.play(server);
// register to receive this message
responder = OSCFunc({ arg msg, time;
// good old SC magic numbers
var id = msg[2];
var hz = msg[3];
// do something with hz, like calculate distance to scale entries
// would also be a good test run for "nonperiodic polls"
postln('['++time++'] '++ hz);
},'/tr', server.addr);
}
free {
synth.free;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment