How to get magnitude values for a Parametric EQ?
9 次查看(过去 30 天)
显示 更早的评论
I was doing pretty well with analog filters, but I can't seem to get similar results with digital filters.
%% 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.
0 个评论
采纳的回答
Brian Hemmat
2020-8-22
编辑:Brian Hemmat
2020-8-27
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 个评论
Brian Hemmat
2020-8-27
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:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Measurements and Spatial Audio 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!