Hi everyone!
I’m trying to make a list processing Allpass Filter for my educational purposes.
As you can see in the code below there is already the code for IIR & FIR Comb that works with a Circular Buffer and a List as Input.
What I’m trying to achieve is a Schroeder Allpass Filter.
I’ve read that the Allpass Filter is a series combination of a feedforward and feedback comb filter (having equal delays) which creates this allpass filter when the feedforward coefficient is the negative of the feedback coefficient.
I find it hard to wrap my head around how to achieve this combination here with a function.
// A list processing IIR & FIR
a = [1, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0]; // Impulse
// Circular Buffer
(
~circGen = {|len = 4| var mem, pointer=0;
mem = Array.fill(len,0);
{|in| var out;
mem[pointer%len] = in;
out=mem[pointer-(len-1)%len];
pointer=pointer+1;
out;
};
};
);
// IIR Comb
(
~iir_comb = {arg cof = 0.9; var circ, prev=0, out;
circ = ~circGen.(2);
{|in|
prev = circ.(prev)+in*cof;
};
};
);
f = ~iir_comb.(0.9);
z = a.collect(f);
z.plot; // Impulse Response of IIR Filter
// FIR COMB
(
~fir_comb ={|cof= 0.9| var circ,prev=0,out;
circ = ~circGen.(3);
{|in|
out=circ.(prev)+in*cof;
prev=in;
out;
};
};
);
f = ~fir_comb.(0.9);
z = a.collect(f);
z.plot;
Furthermore I would like to do it with a real signal combining FIR Comb and IIR Comb by means of DelayN.ar and thru a LocalIn/LocalOut Feedback. How could you combine both in a single function to achieve an Allpass?
//FIR Comb
(
{
a=WhiteNoise.ar;
b=DelayN.ar(a,0.1,0.0002);
a-b;
}.freqscope
);
//IIR Comb
Server.killAll;
s.options.blockSize_(64);
s.boot;
(
{
a=WhiteNoise.ar;
a=a+LocalIn.ar*0.9.neg;
LocalOut.ar(a);
a;
}.freqscope
);
Hope I was clear enough Any help/hints/tips are appreciated! Thank you!