separate noisy and pitched sounds

clean-up: #38

here’s a little fun trick how to use the not so well known clarity mode of supercollider’s built in Pitch tracker. set the clar argument to 1 and then grab the second value returned. by default this is a binary hasFreq flag, but with clar=1 it becomes a continuous value 0.0 to 1.0.
the example below includes a one second delay to be able to hear the sounds you make being panned left-right depending on how ’clear’ they are. there’s also a short lag and a curved mapping to make the example work better.

//example: noise in left ear, clear tones in right
//use headphones
{
        var src= DelayN.ar(SoundIn.ar, 1, 1);
        var clarity= Pitch.kr(src, clar:1)[1].lag(0.1);
        Pan2.ar(src, clarity.lincurve(0.1, 0.9, -1, 1, 4).poll);
}.play

and as variations on the above one could easily mute noises…

//example: mute noise, only play pitched sounds
//use headphones
{
        var src= DelayN.ar(SoundIn.ar, 1, 1);
        var clarity= Pitch.kr(src, clar:1)[1].lag(0.1);
        Pan2.ar(src)*clarity.lincurve(0.1, 0.9, 0, 1, 4);
}.play

and of course by just flipping a value around we only play the noises…

//example: mute pitched sounds, only play noises
//use headphones
{
        var src= DelayN.ar(SoundIn.ar, 1, 1);
        var clarity= Pitch.kr(src, clar:1)[1].lag(0.1);
        Pan2.ar(src)*(1-clarity.lincurve(0.1, 0.9, 0, 1, 4));
}.play

last an example to demonstrate how to route signals to effects depending on clarity…

//example: pitched sounds with reverb
//use headphones
{
        var src= DelayN.ar(SoundIn.ar, 1, 1)*0.5;
        var clarity= Pitch.kr(src, clar:1)[1].lag(2);
        XFade2.ar(src, GVerb.ar(src, 50), clarity.lincurve(0.3, 0.9, -1, 1, -2).poll);
}.play