Post Go back to editing

Bandpass filter coefficient is inconsistent with the calculation result of matlab butter() function.

Dear Team,

I am learning the audio processing algorithm of adsp21489.
Calculate according to the bandpass coefficient in the help document of General 2nd Order.

I tried it in matlab.
The following code

clear;

fs = 48000;        

% f1 Low cutoff   f2 High cutoff
f2 = 11000;
f1 = 9000;

% center frequency
f0 = sqrt(f1*f2) 

% Bandwidth is Bandwidth_in_octaves
Bandwidth_in_octaves  = log(f2/f1)/log(2)

gainLinear = 1 ; % (Vo/Vi)


W0 = 2 * pi * f0 / fs


Alpha = sin(W0) * sinh(log(2)/2 * Bandwidth_in_octaves * W0 / sin(W0))
a0 = 1 + Alpha
a1 = -2 * cos(W0)
a2 = 1 - Alpha
b0 = Alpha * gainLinear
b1 = 0
b2 = -Alpha * gainLinear
 
% Normalized a0
 numerator_B =  [b0,b1,b2]/a0
 denominator_A = [a0,a1,a2]/a0
 

% Matlab butter()
 [b,a] = butter(1,[f1/(fs/2),f2/(fs/2)],'bandpass')

The end of the code uses the Matlab butter() function for comparison.
I found that the calculation results are inconsistent.
Who knows the reason?

I simulated the two results with sigma, and also simulated with bandwidth.Although the difference between the three frequency response curves is very small, I would like to know which of the two calculation methods is correct?

Thank you experts very much!

Parents
  • Hello darkmark,

    I moved this over to the SigmaStudio for SHARC for better support. 

    I do want to add that the graphs in SigmaStudio is designed to give you a general idea of what the filter is doing. There is a small amount of code that is written to produce the graph. In MATLAB there is a lot of code developed to produce precise graphs because that is the purpose of the program. The purpose of SigmaStudio is to compile the code and allow you to edit the DSP code. Graphing is just a convenience not the purpose of the program. If you want to accurately measure the performance of the filter in the DSP then use an Audio Precision to generate and graph the output of the filter. Another way is to take the coefficients into MatLab and graph them there. 

    Dave T

Reply
  • Hello darkmark,

    I moved this over to the SigmaStudio for SHARC for better support. 

    I do want to add that the graphs in SigmaStudio is designed to give you a general idea of what the filter is doing. There is a small amount of code that is written to produce the graph. In MATLAB there is a lot of code developed to produce precise graphs because that is the purpose of the program. The purpose of SigmaStudio is to compile the code and allow you to edit the DSP code. Graphing is just a convenience not the purpose of the program. If you want to accurately measure the performance of the filter in the DSP then use an Audio Precision to generate and graph the output of the filter. Another way is to take the coefficients into MatLab and graph them there. 

    Dave T

Children