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!
%% 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 onsemilogx(w,phase_unwrap) % the filter
grid onylim([-360 180]);xlim([20 20000]);xlabel('Frequency')ylabel('Phase Unwrapped (degrees)')legend('Phase example','Phase filter','Location','best');hold off
Best Answer