How to get magnitude values for a Parametric EQ?

5 vues (au cours des 30 derniers jours)
Nathan Lively
Nathan Lively le 14 Août 2020
Commenté : Nathan Lively le 28 Août 2020
I was doing pretty well with analog filters, but I can't seem to get similar results with digital filters.
Here's what I tried first. Link to my xlsx data.
%% load stuff
M = readtable('dB Technologies T4 PS1.xlsx','Sheet','TF');
%% create filter
Fs = 96e3;
N1 = 2;
G = -5; % 5 dB
Wo = 100/(Fs/2);
BW = 4000/(Fs/2); % Need to figure out how to insert BW in octaves.
[b,a] = designParamEQ(N1,G,Wo,BW);
%% calculate magnitude response
w = M.Frequency_Hz;
h = freqz(b,a,w);
magdB = mag2db(abs(h));
That didn't work, so I tried create a biquad filter from the parametric filter.
BQ = dsp.BiquadFilter('SOSMatrix',[b.',[1,a.']]);
h = freqz(BQ);
That didn't work either. I thought maybe it had something to do with my frequency needing to be converted to radians per sample...
wRad = w*((2*pi)/(Fs/2));
But that didn't work either. What am I missing here?
By the way, I was able to visualize the BQ filter with fvtool, so I could see it was working. I just have been able to get a magnitude response form it.

Réponse acceptée

Brian Hemmat
Brian Hemmat le 22 Août 2020
Modifié(e) : Brian Hemmat le 27 Août 2020
Hi Nathan,
The syntax of freqz that you were using in your code above expects w to be normalized fequency. I ran your code and its not normalized. You can specify frequency in Hz by also specifying the sample rate.
Another issue (updated answer): is that the default orientation of the coefficients output from designParamEQ was not the orientation expected by fvtool and freqz.
M = readtable('spec.xlsx','Sheet','TF');
Fs = 96e3;
N = 2;
G = -5; % 5 dB
Wo = 1000/(Fs/2); % center frequency
BW = 1; %bandwidth in octaves
Q = sqrt(2^BW)/((2^BW)-1); % convert bandwidth to Q
BWnorm = Wo/Q; % then to normalized bandwidth
[b,a] = designParamEQ(N1,G,Wo,BWnorm,'Orientation','row');
fvtool([b,a])
%%
% Magnitude and phase of parametric EQ
f = M.Frequency_Hz;
h = freqz([b,a],f,Fs);
magdB = mag2db(abs(h));
% plot
semilogx(f,magdB) % the filter
grid on
% ylim([-24 24]);
% xlim([20 20000]);
xlabel('Frequency')
ylabel('Magnitude')
legend('Mag Parametric EQ','Location','best');
  4 commentaires
Brian Hemmat
Brian Hemmat le 27 Août 2020
Hi Nathan,
Sorry, I led you astray on my first answer. There was a second issue that the orientation of the coefficients output from the design function was not compatible with fvtool and freqz. Consult the documentation for more details:
Nathan Lively
Nathan Lively le 28 Août 2020
We did it! Well, you did it. :)
Brian, thank you so much. It's been a struggle for me to get started because I know a little about being a sound engineer, but almost nothing about math or programming.
Here's the result.
Would you be willing to take a stab at helping figure out the same problem, but with an allpass filter? https://www.mathworks.com/matlabcentral/answers/581223-why-is-my-1khz-allpass-filter-returning-1-125khz

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by