Last active
December 7, 2020 01:42
-
-
Save catfact/2f591c7fa2d4e89a3358875bf8133896 to your computer and use it in GitHub Desktop.
Zonsp (onsets with pitch in supercollider)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| z = Zonsp.new(Crone.server, Crone.context.pitch_in_b[0].index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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