Commit 26f91431 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Adding matlab scripts for third octave filter design

parent 26611b3e
Fs = 44100;
Hd = ita_dsp_third_octave_filterbank_iir_lowpass_coefficients( Fs, 14.1 )
ita_dsp_third_octave_filterbank_iir_band_coefficients( Fs, 14.1, 17.8 ) % 16 Hz band
% ...
ita_dsp_third_octave_filterbank_iir_highpass_coefficients( Fs, 17780 )
%% Export to C/C++ header using std::vector
copyfile( 'ITADSPThirdOctaveFilterbankCoefficients.proto.h', 'ITADSPThirdOctaveFilterbankCoefficients.h' );
fd = fopen( 'ITADSPThirdOctaveFilterbankCoefficients.h', 'wt' );
fseek( fd, '### stub code ###' );
fprintf( fd, 'std::vector< float > vfITADSPThirdOctaveFilterbankCoefficients = {' );
fprintf( fs, '%.9g', length( Hd.sosMatrix ), h( 1 ) );
fprintf( fd, ',\n %.9g', h( 2:end ) );
fprintf( fd, '};\n');
fclose( fd );
function Hd = ita_dsp_third_octave_filterbank_iir_band_coefficients( Fs, Fc1, Fc2 )
%ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS Returns a discrete-time filter object.
% Fs Sampling Frequency
% Fc1 First Cutoff Frequency
% Fc2 Second Cutoff Frequency
N = 10; % Order
h = fdesign.bandpass('N,F3dB1,F3dB2', N, Fc1, Fc2, Fs);
Hd = design(h, 'butter');
function Hd = ita_dsp_third_octave_filterbank_iir_highpass_coefficients( Fs, Fc )
%ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS Returns a discrete-time filter object.
% Fs Sampling Frequency
% Fc Cutoff Frequency
N = 10; % Order
h = fdesign.highpass( 'N,F3dB', N, Fc, Fs );
Hd = design( h, 'butter' );
function Hd = ita_dsp_third_octave_filterbank_iir_lowpass_coefficients( Fs, Fc )
%ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS Returns a discrete-time filter object.
% Fs Sampling Frequency
% Fc Cutoff Frequency
N = 10; % Order
h = fdesign.lowpass( 'N,F3dB', N, Fc, Fs );
Hd = design( h, 'butter' );
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment