SuperCollider CLASSES (extension)


Records FFT data to a memory buffer


PV_RecordBuf stores FFT data to a buffer for use by a number of PV UGens.

Class Methods

*new (buffer, recbuf, offset: 0, run: 0, loop: 0, hop: 0.5, wintype: 0)



The FFT buffer.


The buffer to save frames of FFT data to.


An integer number of frames to offset into the recbuf file. Defaults to 0.


If > 0.0, store data to the recbuf.


If > 0.0, when the end of the databuf is reached, new data will begint o overwrite old data.


The hop size used in the FFT analysis UGen (this allows the PV_Player UGens to check for consistency).


The windowing type used in the FFT analysis UGen (this allows the PV_Player UGens to check for consistency).

Inherited class methods

Instance Methods

Inherited instance methods


// anazlyze a soundfile and store its data to a buffer


var sf;
// path to a sound file here
p = Platform.resourceDir +/+ "sounds/a11wlk01.wav";
// the frame size for the analysis - experiment with other sizes (powers of 2)
f = 2048;
// the hop size
h = 0.5;
// get some info about the file
sf = p );
// allocate memory to store FFT data to... SimpleNumber.calcPVRecSize(frameSize, hop) will return
// the appropriate number of samples needed for the buffer
y = Buffer.alloc(s, sf.duration.calcPVRecSize(f, h));
// allocate the soundfile you want to analyze
z =, p);

// this does the analysis and saves it to 'y'... frees itself when done
SynthDef("pvrec", { arg recBuf=1, soundBufnum=2;
    var in, chain, bufnum;
    bufnum =, 1);, 1,, doneAction: 2);
    in =, soundBufnum,, loop: 0);
    // note the window type and overlaps... this is important for resynth parameters
    chain = FFT(bufnum, in, 0.25, 1);
    chain = PV_RecordBuf(chain, recBuf, 0, 1, 0, 0.5, 1);
    // no ouput ... simply save the analysis to recBuf

a = Synth("pvrec", [\recBuf, y, \soundBufnum, z]);

// you can save your 'analysis' file to disk! I suggest using float32 for the format
// These can be read back in using

y.write(p++".scpv", "wav", "float32");

// play your analysis back ... see the playback UGens listed above for more examples.
SynthDef("pvplay", { arg out=0, recBuf=1;
    var in, chain, bufnum;
    bufnum =;
    chain = PV_PlayBuf(bufnum, recBuf, 1, 0, 1, 1, 0.25, 1);, IFFT(chain, 1).dup);
b = Synth("pvplay", [\out, 0, \recBuf, y]);

// stop the synth;

// free the buffers
[y, z].do({arg me;});