ReSpeaker DSP V02
Dependencies: mbed MbedJSONValue
Matlab_Script/ArbMagFilterDesign.txt@14:8a4699aa69b5, 2019-06-20 (annotated)
- Committer:
- Arkadi
- Date:
- Thu Jun 20 09:06:46 2019 +0000
- Revision:
- 14:8a4699aa69b5
- Parent:
- 1:574b54755983
experiments version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Arkadi | 1:574b54755983 | 1 | function [MyFilter, sos, g] = ArbMagFilterDesign(Nb, Na) |
Arkadi | 1:574b54755983 | 2 | % For iirlpnorm filter description see http://www.mathworks.com/help/dsp/ref/iirlpnorm.html |
Arkadi | 1:574b54755983 | 3 | |
Arkadi | 1:574b54755983 | 4 | % Nb Numerator Order |
Arkadi | 1:574b54755983 | 5 | % Na Denominator Order |
Arkadi | 1:574b54755983 | 6 | P = [2 128]; % P'th norm |
Arkadi | 1:574b54755983 | 7 | dens = 20; % Density Factor |
Arkadi | 1:574b54755983 | 8 | |
Arkadi | 1:574b54755983 | 9 | % Frequency Vector - normalized |
Arkadi | 1:574b54755983 | 10 | % Real frequences = F * (Fs/2) wher Fs is sampling frequency |
Arkadi | 1:574b54755983 | 11 | F = [0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0]; |
Arkadi | 1:574b54755983 | 12 | % Amplitudas |
Arkadi | 1:574b54755983 | 13 | A = [0 0 0 0 1 1 1.1 1.1 1.1 1.1 1.2 1.2 1.2 1.2 1.2 1.3 1.3 1.3 1.4 1.4 1.4]; % Amplitude Vector |
Arkadi | 1:574b54755983 | 14 | % Weights has one entry per frequency point (the same length as f and a) which tells iirlpnorm how |
Arkadi | 1:574b54755983 | 15 | % much emphasis to put on minimizing the error in the vicinity of each frequency point relative to the other points. |
Arkadi | 1:574b54755983 | 16 | W = [0.1 0.1 0.1 0.1 ones(1,17)]; |
Arkadi | 1:574b54755983 | 17 | % Frequency Edges, normalized (single band) |
Arkadi | 1:574b54755983 | 18 | E = [0 1]; |
Arkadi | 1:574b54755983 | 19 | |
Arkadi | 1:574b54755983 | 20 | % Hints |
Arkadi | 1:574b54755983 | 21 | % |
Arkadi | 1:574b54755983 | 22 | % This is a weighted least-pth optimization. |
Arkadi | 1:574b54755983 | 23 | % Check the radii and locations of the poles and zeros for your filter (with zplane function). If the zeros are on the unit circle |
Arkadi | 1:574b54755983 | 24 | % and the poles are well inside the unit circle, try increasing the order of the numerator or reducing the error weighting in the stopband. |
Arkadi | 1:574b54755983 | 25 | % Similarly, if several poles have a large radii and the zeros are well inside of the unit circle, try increasing the order |
Arkadi | 1:574b54755983 | 26 | % of the denominator or reducing the error weighting in the passband. |
Arkadi | 1:574b54755983 | 27 | |
Arkadi | 1:574b54755983 | 28 | [num,den,err,sos,g] = iirlpnorm(Nb, Na, F, E, A, W, P, {dens}); |
Arkadi | 1:574b54755983 | 29 | |
Arkadi | 1:574b54755983 | 30 | MyFilter = dfilt.df1sos(sos, g); |
Arkadi | 1:574b54755983 | 31 | end |