%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% This m-file shows how to use D-T convolution to explore the effect of %% and RC circuit on an audio signal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% C=5e-9; R=100e3; %%% sets RC = 0.5 ms (cut-off frequency = 300 Hz) RC=R*C; %% compute RC time constant for use later [x,Fs]=wavread('guitar1.wav'); % read in wave file of guitar recording del_t=1/Fs; % Fs is sampling rate read in by wavread.m so invert it to get time spacing t=(0:500)*del_t; %% create 501 point time sample vector h=(1/RC)*exp(-t/RC); %% compute impulse response of this RC circuit at the 501 time points plot(t,h) %% note that h(t) decays to negligible values by the end of the 501 time points xlabel('time (s)') ylabel('RC Impulse Response (volts)') %% use del_t*h(nTs) to make D-T conv approximate C-T conv %% See Eq. (3.64) in Sect 3-5 of book y=conv(x,del_t*h); %% this D-T convolution approximates the C-T convolution that %% the RC circuit does disp('Hit any key to start first playback') pause sound(x,Fs); %%% Listen to the original signal (the input to the RC circuit) disp('When playback stops... Hit any key to start playback of output') pause %%% wait until first playback is over.. then user must hit a key sound(y,Fs); %%% Listen to the signal at the output of the RC circuit... %% notice that it has less treble content (i.e. less high frequency)