Impulse Response Measurement

A MATLAB Experiment for Purdue ECE 301

Developed by Craig Manarik and Chih-Chun Wang

 

Part III:

 

Preparing the File

 

1.      Download the following WAV files and save them in the same directory as your recorded impulse response.

·         ece301conv.m

·         impulse_center.m

·         x1.wav

 

2.      Open MATLAB and change to the appropriate directory.

 

3.      Run the following command:

impulse_center(‘your_recorded_impulse_file_name_here.wav’);

 

Note: The purpose of this function is to convert the signal you recorded to a suitable format. More specifically, it will put your recorded impulse response in the center of an 8 second window. To ensure that this function runs properly, your recorded impulse must have at least 4 seconds before and after the impulse and must have a sampling frequency 44.1kHz. Please consult with TA if there is any problem running the above function.

  

 

The function will create a new file in the current directory called new_file.wav. This file contains your recorded impulse centered in an 8 second window.

 

4.      Enter the following commands

 

duration = 8;
f_sample = 44100;
t = (((0-4)*f_sample+0.5):((duration-4)*f_sample-0.5))/f_sample;

 

5.      Load x1(t) and your impulse by the following commands:

 

[x1,f_sample1] = audioread(‘x1.wav’);
x1 = x1’;
[impulse,f_sample2] = audioread(‘new_file.wav’);
impulse = impulse’;

 

(You can now plot your signals versus time with the command plot(t,x1) or plot(t,impulse). You can listen to your signals with the commands soundsc(x1,f_sample1) or soundsc(impulse,f_sample2) )

 

 

Objective

 

1.      Use the following commands to convolve the signal x1 with the recorded impulse.

 

output = ece301conv(impulse,x1);

 

2.      Listen to your output signal with the command

 

soundsc(output,f_sample);

 

NOTE: Prior to playing the output file, you may want to plot the output in MATLAB to check the amplitude of the output waveform, using the command plot(t,output);. In some scenarios (due to your recording environment), you may end up with a waveform that has a very small amplitude in which case the audio will not be audible when play the output variable. In that case, you can multiply the output by a suitable gain (e.g., output=output*100;) to ensure that the audio will be audible. Another alternative is to use the command output=output/max(output); to adjust the volume automatically.

3.      Repeat the preparation and problem section for the second impulse response you recorded on campus.

 

4.      Describe the differences between the audio before and after convolving with the impulse responses.

 

5.      Save your new audio as a WAV file using

 

audiowrite('file_name.wav', output, f_sample);

 

 

6.      Upload the following items to Brightspace (following TA’s instruction) in a single zipped file:

·         The WAV files for both of your impulse responses after they have been centered in an 8 second window.

·         The WAV files produced from convolving x1 with your impulse responses.

·         Your description of the differences between the audio before and after convolving with the impulse responses.