home/ atoms/ sc-pitch-amplitude-analysis

SuperCollider's Pitch and Amplitude UGens extract frequency and loudness from audio input in real time

The Pitch UGen uses an autocorrelation-based algorithm to estimate the fundamental frequency of an audio signal, returning a [freq, hasPitch] pair. Amplitude returns a smoothed amplitude envelope. Together they form a simple machine-listening front end: detect pitch and volume, then drive synthesis with those values. The Onsets UGen adds onset detection using FFT-based analysis. For fuller spectral description, Loudness and MFCC UGens (Ch 15) operate on FFT frames. This pipeline — microphone → analysis UGen → synthesis response — is the backbone of live audio-reactive performance and notation systems.

Examples

x = { var in = SoundIn.ar(0); var amp = Amplitude.ar(in);

freq, hasFreq = Pitch.kr(in);

LFTri.ar(freq * [1, 2]) * amp; }.play

Assessment

Build a patch that listens to a microphone, tracks pitch and amplitude, and plays back the detected pitch one octave up in the opposite stereo channel. Extend it to trigger a different timbre on each onset detected by Onsets.

“in = SoundIn.ar(0); amp = Amplitude.ar(in); # freq, hasFreq = Pitch.kr(in); LFTri.ar(freq*[1,2]) * amp;”
corpus · the-supercollider-book-official-code-examples-scbookcode-gpl · chunk 48