


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Assigned: September 1, 2006 Due: September 8, 2006 Review the following concepts discussed in lecture:
MATLAB Problem: Decimation and Interpolation of Sound
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ME 360 HW #3: Decimating/Interpolating Sound % Bryan Rasmussen % 17 Sep. 2004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Load and Play the Sound File load handel sound(y,Fs); pause(10); % Plot a section of the sound file total_time = max(size(y))/Fs; time_increment = 1/Fs; time_vector = [time_increment:time_increment:total_time]; figure stem(time_vector,y') % Plot a zoomed in section of the sound file figure stem(time_vector(1:250),y(1:250)') % Downsample the signal by 4 y_ds_4 = downsample(y,4); Fs_ds_4 = Fs/4; % Play the downsampled sound files sound(y_ds_4,Fs_ds_4); pause(10); % Upsample the signal y_us_4 = upsample(y_ds_4,4); % Play the upsampled sound files sound(y_us_4,Fs); pause(10); % Plot the downsampled and upsampled sound signal (we pad with zeros to make the vectors the same length) time_increment = 1/Fs; time_vector_ds_4 = [0:1/Fs_ds_4:total_time]; time_vector_us_4 = [0 0 0 time_vector]; figure subplot(311) stem(time_vector,y') subplot(312) stem(time_vector_ds_4,y_ds_4') subplot(313) stem(time_vector_us_4,y_us_4') % Plot a zoomed in section of the sound file figure subplot(311) stem(time_vector(1:240),y(1:240)') subplot(312) stem(time_vector_ds_4(1:60),y_ds_4(1:60)') subplot(313) stem(time_vector(1:240),y_us_4(1:240)') % Decimate the signal by 2, 4, and 8 using the "decimate" command. y_dc_4 = decimate(y,4); % Play the decimated sound files sound(y_dc_4,Fs_ds_4); pause(10); % Type "help decimate" and "help downsample" and describe the difference in MATLAB's commands. help downsample; help decimate;