Minimal Digital Filter Example
% this is a minimal example of
% of digital filtering using MATLAB
% ---
%
% we are going to create a mixture of
% two sounds and filter one of them out
% ---
%
% first lets state the basics for this
% example
fs = 16000; % sample rate for sounds
fHz1 = 220; % 220Hz is a low sound
fHz2 = fHz1*2^3; % three octaves higher
% first make a 1 second sound that
% consists of a mixture of a high note
% and a low note
low_note = cos([1:fs]*2*pi*fHz1/fs);
high_note = cos([1:fs]*2*pi*fHz2/fs);
two_notes = (low_note + high_note);
% design and apply a filter to
% remove the high note
[b a] = butter(1, [0.01 0.1]);
two_notes_filtered = filter(b,a,two_notes);
% join the filtered and unfiltered versions
% together and listen to the result one second
% of un-filtered followed by one second of
% filtered
soundsc([two_notes two_notes_filtered],fs);
Use these links to navigate back to the Cochlear Model page or onward to the explanation of this code.