{ SoundIn.ar(1,0.1) }.play;// mono on input channel 1; won't work if you don't have at least 2 inputs!

So it's easy to build effects processors for live audio:

(

{ //ring modulator

SinOsc.ar(MouseX.kr(0.001,110,'exponential' ))*SoundIn.ar(0,0.5)

}.play;// stereo through patching from input to output

)

SuperCollider comes with an amplitude tracker and pitch tracker for realtime audio

(

// use input amplitude to control Pulse amplitude - use headphones to prevent feedback.

{

Pulse.ar(90, 0.3, Amplitude.kr(SoundIn.ar(0)))

}.play

)

You can threshold the input to avoid picking up background noise

(

{

var input,inputAmp,threshhold,gate;

var basefreq;

input = SoundIn.ar(0,0.1);

inputAmp = Amplitude.kr(input);

threshhold = 0.02;// noise gating threshold

gate = Lag.kr(inputAmp > threshhold, 0.01);

(input * gate)

}.play;

)

The Pitch follower has many input arguments, though you usually take the defaults

without worrying. It returns two outputs- the tracked frequency and a signal indicating

whether it has locked onto any periodicity or not

Server.internal.boot; //if on a Mac you'll need to swap back to internal server for using .scope- you can have both the internal and localhost server on at once, but you might need to press the -> default button

//showing the outputs - K2A makes sure control rate signals are converted to audio rate, because the final output of a Synth has to be audio rate

(

{

var freq, hasFreq;

# freq, hasFreq = Pitch.kr(SoundIn.ar(1,0.1));

[K2A.ar(freq*0.001), K2A.ar(hasFreq)]

}.scope

)

//detected fundamental frequency used to control some oscillators with allpass reverberation

//Amplitude detector also used to make the control track the input more effectively

(

{

var in, amp, freq, hasFreq, out;

in = Mix.ar(SoundIn.ar([0,1]));

amp = Amplitude.kr(in, mul: 0.4);

# freq, hasFreq = Pitch.kr(in);

out = Mix.ar( LFTri.ar(freq * [0.5, 1, 2]) ) * amp;

6.do({

out = AllpassN.ar(out, 0.040, [0.040.rand,0.040.rand], 2)

});

out

}.play

)

//Also switch waveform based on hasFreq output

(

{

var in, amp, freq, hasFreq, out;

in = SoundIn.ar(1);

amp = Amplitude.kr(in, mul: 0.4);

# freq, hasFreq = Pitch.kr(in);

out=if(hasFreq,Pulse.ar(freq,0.5,0.1),SinOsc.ar(freq,0,0.1));

6.do({

out = AllpassN.ar(out, 0.040, [0.040.rand,0.040.rand], 2)

});

out

}.play

)

There are various other machine listening capabilities in SuperCollider.Machine listening is getting the computer to extract perceptually and musically meaingful attributes by analyzing an input sound.

Here are some onset detectors which might be helpful:

[Onsets]

[PV_HainsworthFoote]

[PV_JensenAndersen]

They rely on using the FFT UGen in the front end to go from time domain to frequency domain. You can trust the code examples for now and we'll investigate FFT properly later on (or explore the help file yourself).