Warp0 Warp a buffer with a warp factor


Inspired by Chad Kirby's SuperCollider2 Warp1 class, which was inspired by Richard Karpen's sndwarp for CSound. A granular time strecher and pitchshifter.


Warp0.ar(numChannels, buffer, warpFactor, freqScale, windowSize, envbufnum, 

overlaps, windowRandRatio, interp, mul, add)

numChannels - the number of channels in the buffer.

buffer - the buffer number of a mono soundfile.

warpFactor - amount to stretch or compress the buffer. 0.5 is half speed, 2 is twice the speed.

freqScale- the amount of frequency shift. 1.0 is normal, 0.5 is one octave down, 2.0 is one octave up.

Negative values play the soundfile backwards.

windowSIze - the size of each grain window.

envbufnum - the buffer number containing a singal to use for the grain envelope. -1 uses a built-in 

Hanning envelope.

overlaps - the number of overlaping windows.

windowRandRatio - the amount of randomness to the windowing function.  Must be between 0 (no

randomness) to 1.0 (probably to random actually) 

interp - the interpolation method used for pitchshifting grains. 1 = no interpolation. 2 = linear. 

4 = cubic interpolation (more computationally intensive).



Examples:


s.boot;


(

SynthDef(\warp, {arg buffer = 0;

var out, filelength, env;

env = EnvGen.kr(Env([0.01, 1, 1, 0.01], [0.1, 14, 0.9], 'exp'), doneAction: 2);

//warp factor of 0.25- stretch sound by 4 times

out = Warp0.ar(1, buffer, 0.25, MouseX.kr(0.25, 4), 0.1, -1, 8, 0.05, 1);

Out.ar(0, out * env);

}).send(s);


)


b = Buffer.read(s, "sounds/a11wlk01.wav");


a = Synth(\warp, [\buffer, b]);

a.free;


(

SynthDef(\warp, {arg buffer = 0;

var out, warp, filelength, env, freq;

warp = MouseX.kr(0, 1);

freq = MouseY.kr(0.5, 4);

env = EnvGen.kr(Env([0.01, 1, 1, 0.01], [0.1, 14, 0.9], 'exp'), doneAction: 2);

out = Warp0.ar(1, buffer, warp, freq, 0.1, -1, 8, 0.05, 1);

Out.ar(0, out * env);

}).send(s);


)


a = Synth(\warp, [\buffer, b]);

a.free;

b.free;