wekaco / rust-sketches

Ideas and sketches for a mutli voice instrument.
1 stars 0 forks source link

feat/conv Implement convolution feedback #1

Open dmtrs opened 5 years ago

dmtrs commented 5 years ago

Supercollider example in Convolution documentation

(
{
    var input, kernel;

    input = SoundIn.ar(0);
    kernel = Mix.ar(LFSaw.ar([300,500,800,1000] * MouseX.kr(1.0, 2.0), 0, 1.0));

    // must have power of two framesize
    Convolution.ar(input,kernel, 1024, 0.5)
}.play;
)

(
// must have power of two framesize- FFT size will be sorted by Convolution to be double this
// maximum is currently a=8192 for FFT of size 16384
a = 2048;
s = Server.local;

// kernel buffer
g = Buffer.alloc(s, a, 1);
)

(
// random impulse response
g.set(0, 1.0);
100.do({ arg i; g.set(a.rand, 1.0.rand) });
{
    var input, kernel;
    input = SoundIn.ar(0);
    kernel = PlayBuf.ar(1, g.bufnum,BufRateScale.kr(g.bufnum), 1, 0, 1);

    Convolution.ar(input, kernel, 2 * a, 0.5)
}.play;
)

Resources:

dmtrs commented 5 years ago

Fast Convolution Algorithms: Overlap-add, Overlap-save http://eeweb.poly.edu/iselesni/EL713/zoom/overlap.pdf

FFT Convolution http://www.dspguide.com/CH18.PDF