Why is my 1kHz allpass filter returning 1.125kHz?

2 views (last 30 days)
I was happy to discover allpass.m from Dean Andersen, but I'm struggling to get the expected result.
My expectation is based off of the Galaxy output processor from Meyer Sound with an APF set at 1kHz with a Q of 1. This is the filter I'm trying to recreate (viewed as wrapped phase). Here's a link to the full sized image.
This is the result I'm getting in MATLAB viewed as unwrapped phase in orange. Instead of the filter crossing 180º at 1kHz, it's at 1.125kHz. The blue line is another input for my own reference.
What am I missing here? Thanks for any guidance!
Here's the code I'm using and here's a link to the file I'm using for my x-values.
%% load stuff
M = readtable('dB Technologies T4 PS1.xlsx','Sheet','TF');
%% Create APF
Q = 1;
Fc = 1000;
Fs = 96000;
% Magnitude
w0B22 =2*pi*Fc/Fs;
alphaB23 = sin(w0B22)/(2*Q);
a0B24 = 1+alphaB23;
a1B12 = -(-2*cos(w0B22))/a0B24;
a2B13 = -(1-alphaB23)/a0B24;
a1Z2 = round(-a1B12,14);
a2Z3 = round(-a2B13,14);
realpart = -a1Z2/(2*1);
D = a1Z2^2-4*1*a2Z3;
ipart = sqrt(-D)/(2*1);
magnitude = sqrt(realpart^2+ipart^2);
n=1; % poles
Fst = Fc % Not sure if this correct.
Fed = M.Frequency_Hz(515); % This variable didn't seem to change anything.
mag = magnitude;
[b,a] = allpass(n,Fst,Fed,mag,Fs);
% Phase of APF
w = M.Frequency_Hz;
M.Frequency_Norm = (2 * w / Fs) * pi; % Frequency in Hz to rad/samp
phase_unwrap = rad2deg(phasez(b,a,M.Frequency_Norm));
% phase of APF
M.Phase_unwrap = rad2deg(unwrap(deg2rad(M.Phase_deg)));
semilogx(w,M.Phase_unwrap)
hold on
semilogx(w,phase_unwrap) % the filter
grid on
ylim([-360 180]);
xlim([20 20000]);
xlabel('Frequency')
ylabel('Phase Unwrapped (degrees)')
legend('Phase example','Phase filter','Location','best');
hold off
  2 Comments
Sebastian Schlecht
Sebastian Schlecht on 19 Aug 2020
Hi,
can you please post xlsx file such that there is a full reproducible example.
Best,
Sebastian
Nathan Lively
Nathan Lively on 20 Aug 2020
Thanks Sebastian. I linked to the file above. Did it not work for you?
Here it is again - https://u.pcloud.link/publink/show?code=XZ8KoikZ82hiNrq3WspJGy0bynYjeuJnA8T7

Sign in to comment.

Accepted Answer

Nathan Lively
Nathan Lively on 3 Sep 2020
I did not figure out how to use Dean Anderson's function for my purposes, but I did find another one, which is even better because the inputs and outputs are already in the format I'm familiar with.
https://www.dsprelated.com/showcode/182.php

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!