How do I get frequency response as values from multibandParametricEQ System object?

2 ビュー (過去 30 日間)
Hiroshi Iwamura
Hiroshi Iwamura 2018 年 8 月 22 日
編集済み: michio 2019 年 10 月 28 日
I cant visualize the response using visualize(mPEQ). But I want "values" as [h,w]. How do I get?

採用された回答

Kei Otsuka
Kei Otsuka 2018 年 8 月 24 日
To extract frequency response, modifying or adding your own function to multibandParametricEQ.m might be helpful.
For example, you can use computefreqz, one of the dsp.util.FilterVisualizer object function to calculate frequency response within a multibandParametricEQ.
?
#1. Add following to visualize function defined in multibandParametricEQ.m
fVector = logspace(log10(20),log10(Fs/2),NFFT);
H = obj.visualObj.computefreqz(coeffs, fVector', Fs);
data = 20*log10(abs(H));
#2. Add output arguments to visualize function
function [data, fVector] = visualize(obj,NFFT)
#3. Confirm if modified method works
mPEQ = multibandParametricEQ(...
'NumEQBands',1,...
'Frequencies',9.5e3,...
'PeakGains',10);
[h, w] = visualize(mPEQ)
figure, semilogx(w,h)
ax = gca;
ax.YLim = [-25 25];
ax.XLim = [20 44100/2];
xlabel('Frequency (Hz)')
ylabel('Magnitude (dB)')
grid on
grid minor
  2 件のコメント
Hiroshi Iwamura
Hiroshi Iwamura 2018 年 8 月 24 日
Thank you for your reply.
I tried to add these lines at the end of "function [data, fVector] = visualize(obj,NFFT)".
fVector = logspace(log10(20),log10(Fs/2),NFFT ); H = obj.visualObj.computefreqz(coeffs, fVector', Fs ); data = 20*log10(abs(H));
And then I got error like "not found computefreqz".
Something wrong? (I'm using R2016a. But other error occurred in R2018a. )
But I found I can get filter coefficients as below.
[B,A] = coeffs(mPEQ);
So now I can draw arbitrary graph such as ...
Fs = 48000; f = logspace(1,5,4096); f(f>Fs/2) = [];
h_all = 0; for i=1:size(B,2) sosPEQ = [B(:,i),[1;A(:,i)]]; h = freqz(B(:,i),[1;A(:,i)],f,Fs); h_all = h_all + 20*log10(abs(h)); end figure semilogx(f,h_all)
That's fine to me!
Thanks a lot.
Kei Otsuka
Kei Otsuka 2018 年 8 月 25 日
That's great, thanks for sharing your experience with us.
&#01
The error you run into was because dsp.util.FilterVisualizer is not available on R2016a. This is just FYI, but you can use freqz instead like this;
fVector = logspace(log10(20),log10(Fs/2),NFFT);
H = freqz(coeffs{1}, [1;coeffs{2}], fVector', Fs);
data = 20*log10(abs(H));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!