%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ECE205 Convolution Application
% Written by Y.J.D. Kim on April 4, 2014
%
% Modified by ____PUT YOUR NAME & DATE______
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Read .wav files into MATLAB 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% x: input speech waveform
% h: impulse response of a concert hall
% fs: sample rate of the recordings (Hz)
% N: number of bits per sample used to encode the recordings
[x,fs,N_x] = wavread('SamMagee.wav');
[h,fs_h,N_h] = wavread('concert_hall.wav');
x = sum(x,2); % L+R channels for MONO sound
h = sum(h,2); % L+R channels 
h = downsample(h, fs_h/fs); % downsample h to match the sample rate of x
t_x = (0:length(x)-1)/fs; % time vector for x(t)
t_h = (0:length(h)-1)/fs; % time vector for h(t)
t_y = (0:length(h)+length(x)-2)/fs; % time vector for y(t)

%%%%%%%%%%%%%%
% Convolution 
%%%%%%%%%%%%%%
    
% CONVOLVE x AND h TO PRODUCE y


%%%%%%%%%%%%%%%%%%%%%%%%
% Plotting and Playback 
%%%%%%%%%%%%%%%%%%%%%%%%

% PLAY THE CONVOLUTION OUTPUT y (HINT: SAMPLING FREQUENCY IS fs)


% PLOT x, h, AND y. PROPERLY LABEL YOUR PLOTS USING xlabel, ylabel, title

