question about dely lines
EDITED:
Hey guys, I want to implement an allpass filter but i struggle with the difference equation and its implementation:
heres the structure
and here are the difference equations:
So finally I got the difference equation. I also tried to implemend it into my process function. (d(n) is a delay line in my code before i wanted to implemt the allpass, therefore I commented it out, but can be useful to compare). m(k) and m'(k) are both delays that are calculated. zeta is set to be one and is therefore not in the equation. The plugin sounds wrong and horrible if I try this way. Anyone got an Idea?
function out = process(plugin, in)
out = zeros(size(in));
for i = 1:size(in,1)
% Summieren der L/R – Kanle
inL = in(i,1);
inR = in(i,2);
inSum = (inL + inR)/2;
plugin.buffInput(plugin.pBuffInput + 1) = inSum;
% loop over delay lines
for n=1:plugin.N
% plugin.y_a = 0;
% d_n = gain * delayed v_n
for k=1:plugin.N
% if k == 2 && mod(plugin.pBuffDelayLines,2) == 0
% plugin.gy(k) = 0;
%
% end
plugin.Dg(k) = sqrt(1-plugin.g(k)^2);
%plugin.d(k) = plugin.g(k)*plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k), plugin.maxDelay +1) + 1);
% d(k) = (((sqrt(1-plugin.g(k)^2)^2)+ plugin.g(k)^2 + plugin.g(k)^2) * x1_m0p) + (plugin.g(k) * x1_m0) – (plugin.g(k) * y_m0p);
x1_m0p = plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k)+plugin.m'(k)+1, plugin.maxDelay +1) + 1);
x1_m1p =plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines+ plugin.m(k) +1, plugin.maxDelay +1) + 1);
plugin.d(k)= (plugin.Dg(k)^2+plugin.g(k)^2)*x1_m0p + plugin.g(k)*x1_m1p- plugin.g(k)*plugin.y_a(k);
plugin.y_a(k) = plugin.d(k);
end
%generate time variant matrix
%generateTIFDNmatrix(plugin,buffA);
% f_n = A(n,:) * d’
plugin.f(n) = plugin.A(n,:) * plugin.d(:);
% v_n with pre delay
plugin.v(n) = plugin.b(n) * plugin.buffInput(mod(plugin.pBuffInput + plugin.preDelayS, (plugin.maxPreDelay * plugin.fs + 1)) + 1) …
+ plugin.f(n); %An pe delay noch arbeiten
plugin.buffDelayLines(n, plugin.pBuffDelayLines + 1) = plugin.v(n);
% output lines
plugin.s(n) = plugin.c(n)* plugin.d(n);
out(i,:) = out(i,:) + real(plugin.s(n));
end
% Assign to output
out(i,1) = plugin.mix/100 * out(i,1) + (1.0 – plugin.mix/100) * in(i,1);
out(i,2) = plugin.mix/100 * out(i,2) + (1.0 – plugin.mix/100) * in(i,2);
calculatePointer(plugin);
end
endEDITED:
Hey guys, I want to implement an allpass filter but i struggle with the difference equation and its implementation:
heres the structure
and here are the difference equations:
So finally I got the difference equation. I also tried to implemend it into my process function. (d(n) is a delay line in my code before i wanted to implemt the allpass, therefore I commented it out, but can be useful to compare). m(k) and m'(k) are both delays that are calculated. zeta is set to be one and is therefore not in the equation. The plugin sounds wrong and horrible if I try this way. Anyone got an Idea?
function out = process(plugin, in)
out = zeros(size(in));
for i = 1:size(in,1)
% Summieren der L/R – Kanle
inL = in(i,1);
inR = in(i,2);
inSum = (inL + inR)/2;
plugin.buffInput(plugin.pBuffInput + 1) = inSum;
% loop over delay lines
for n=1:plugin.N
% plugin.y_a = 0;
% d_n = gain * delayed v_n
for k=1:plugin.N
% if k == 2 && mod(plugin.pBuffDelayLines,2) == 0
% plugin.gy(k) = 0;
%
% end
plugin.Dg(k) = sqrt(1-plugin.g(k)^2);
%plugin.d(k) = plugin.g(k)*plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k), plugin.maxDelay +1) + 1);
% d(k) = (((sqrt(1-plugin.g(k)^2)^2)+ plugin.g(k)^2 + plugin.g(k)^2) * x1_m0p) + (plugin.g(k) * x1_m0) – (plugin.g(k) * y_m0p);
x1_m0p = plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k)+plugin.m'(k)+1, plugin.maxDelay +1) + 1);
x1_m1p =plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines+ plugin.m(k) +1, plugin.maxDelay +1) + 1);
plugin.d(k)= (plugin.Dg(k)^2+plugin.g(k)^2)*x1_m0p + plugin.g(k)*x1_m1p- plugin.g(k)*plugin.y_a(k);
plugin.y_a(k) = plugin.d(k);
end
%generate time variant matrix
%generateTIFDNmatrix(plugin,buffA);
% f_n = A(n,:) * d’
plugin.f(n) = plugin.A(n,:) * plugin.d(:);
% v_n with pre delay
plugin.v(n) = plugin.b(n) * plugin.buffInput(mod(plugin.pBuffInput + plugin.preDelayS, (plugin.maxPreDelay * plugin.fs + 1)) + 1) …
+ plugin.f(n); %An pe delay noch arbeiten
plugin.buffDelayLines(n, plugin.pBuffDelayLines + 1) = plugin.v(n);
% output lines
plugin.s(n) = plugin.c(n)* plugin.d(n);
out(i,:) = out(i,:) + real(plugin.s(n));
end
% Assign to output
out(i,1) = plugin.mix/100 * out(i,1) + (1.0 – plugin.mix/100) * in(i,1);
out(i,2) = plugin.mix/100 * out(i,2) + (1.0 – plugin.mix/100) * in(i,2);
calculatePointer(plugin);
end
end EDITED:
Hey guys, I want to implement an allpass filter but i struggle with the difference equation and its implementation:
heres the structure
and here are the difference equations:
So finally I got the difference equation. I also tried to implemend it into my process function. (d(n) is a delay line in my code before i wanted to implemt the allpass, therefore I commented it out, but can be useful to compare). m(k) and m'(k) are both delays that are calculated. zeta is set to be one and is therefore not in the equation. The plugin sounds wrong and horrible if I try this way. Anyone got an Idea?
function out = process(plugin, in)
out = zeros(size(in));
for i = 1:size(in,1)
% Summieren der L/R – Kanle
inL = in(i,1);
inR = in(i,2);
inSum = (inL + inR)/2;
plugin.buffInput(plugin.pBuffInput + 1) = inSum;
% loop over delay lines
for n=1:plugin.N
% plugin.y_a = 0;
% d_n = gain * delayed v_n
for k=1:plugin.N
% if k == 2 && mod(plugin.pBuffDelayLines,2) == 0
% plugin.gy(k) = 0;
%
% end
plugin.Dg(k) = sqrt(1-plugin.g(k)^2);
%plugin.d(k) = plugin.g(k)*plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k), plugin.maxDelay +1) + 1);
% d(k) = (((sqrt(1-plugin.g(k)^2)^2)+ plugin.g(k)^2 + plugin.g(k)^2) * x1_m0p) + (plugin.g(k) * x1_m0) – (plugin.g(k) * y_m0p);
x1_m0p = plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k)+plugin.m'(k)+1, plugin.maxDelay +1) + 1);
x1_m1p =plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines+ plugin.m(k) +1, plugin.maxDelay +1) + 1);
plugin.d(k)= (plugin.Dg(k)^2+plugin.g(k)^2)*x1_m0p + plugin.g(k)*x1_m1p- plugin.g(k)*plugin.y_a(k);
plugin.y_a(k) = plugin.d(k);
end
%generate time variant matrix
%generateTIFDNmatrix(plugin,buffA);
% f_n = A(n,:) * d’
plugin.f(n) = plugin.A(n,:) * plugin.d(:);
% v_n with pre delay
plugin.v(n) = plugin.b(n) * plugin.buffInput(mod(plugin.pBuffInput + plugin.preDelayS, (plugin.maxPreDelay * plugin.fs + 1)) + 1) …
+ plugin.f(n); %An pe delay noch arbeiten
plugin.buffDelayLines(n, plugin.pBuffDelayLines + 1) = plugin.v(n);
% output lines
plugin.s(n) = plugin.c(n)* plugin.d(n);
out(i,:) = out(i,:) + real(plugin.s(n));
end
% Assign to output
out(i,1) = plugin.mix/100 * out(i,1) + (1.0 – plugin.mix/100) * in(i,1);
out(i,2) = plugin.mix/100 * out(i,2) + (1.0 – plugin.mix/100) * in(i,2);
calculatePointer(plugin);
end
end equation, digital signal processing MATLAB Answers — New Questions