%% load wave file 
% wave files have inside information about
% sampling rate, usually left and right channel amplitudes, how many bits per sample etc. 
[data, SampleRate, NbitsPerSample]=wavread('voice_record_l27.wav');

y=data(:,1); % we will work only with one channel in this demo 
N=length(y); %number of sample points
% if you need other one use data(:,2)
t=( (1:N)*1/SampleRate ).'; % time spacing is 1/SampleRate and we want column vector

%% calculate corresponding frequency for the DFT
spectrum_freq=fourier_frequencies(SampleRate, N);

%%  no filters just look at spectrum
fprefix='voice_record_unfiltered_l27';
g_vs_freq=ones(N,1);
filter_application(fprefix, t, y,  g_vs_freq);

%% notice huge peak aroun 300 Hz
% we are going to filter it
g_vs_freq=ones(N,1);
Fc=300;
g_vs_freq(abs(spectrum_freq)>Fc*.9 & abs(spectrum_freq)<Fc*1.1 ,1)=0;
fprefix='voice_record_filtered_l27';

y_filtered= filter_application(fprefix, t, y,  g_vs_freq);

%% let's normalize signal
y_filtered=y_filtered/max( abs(y_filtered) ) * 0.98; 

wavwrite(y_filtered, SampleRate, NbitsPerSample, 'voice_record_l27_filtered.wav');




