# 5.2 Recording impulse response

Problem

To measure impulse responses for sound source localization and sound source separation.

Solution

Ingredients

A loudspeaker, a microphone array, an audio device that can simultaneously play and record a sound, and a signal including multiple TSPs are needed in the impulse response measurement. A wave file of a single TSP signal is installed in /usr/bin/harktool3_utils upon installation of harktool with a filename 16384.little_endian.wav. Since this file includes only a single TSP signal, it is necessary to cut and paste to make multiple TSPs (e.g., 8 or 16 times) using waveform editing softwares such as matlab or python. Note that spaces should not be inserted between TSPs.

The number of TSP depends on the environment of the measurement. For example, 8-times TSP is enough in an environment with only a little noise. While 16-times TSP is recommended in an environment with a lot of noise, e.g a running air conditioner.

Similarly, a raw file 16384.little_endian.tsp, which is a 32bit float wave data in a little-endian format is also installed in the same path. The wavesurfer software can be used to read the file. Below is the instruction on the installation and reading files using wavesurfer.

Installation of wavesurfer

 	  \verb+sudo apt-get install wavesurfer+


Opening file using wavesurfer

 	  wavesurfer /usr/bin/harktool3_utils/16384.little_endian.tsp


Then, set the configuration as shown in (Fig. 5.1)

Impulse Response Measurement Procedure

Impulse responses are measured in two steps: (1) playing and recording the TSP signal, and (2) calculating impulse responses from TSP signals.

1. Playing and recording the TSP signal
Playing multiple TSP signals and adding each signal reduces the background noise and vibrations. Files that includes 8-times TSP is named tsp8.wav.

Next is to use the HARK support tool wios  for measurement. For example, to perform a synchronous recording-playback in an ALSA supported 8-channel multi-input device, execute the following command: (see Recording multichannel sound how to use wios  )

	  wios -s -x 0 -i tsp.wav -c 8 -o r100_d000.wav


It is necessary to measure the impulse response of sounds coming from each direction. In about 1-2 meters of concentric circle from the center of the microphone array, move the speakers in order and with an equal angle while recording. For example, when the impulse response is measured in a 1 meter distance from the microphone array with 10 degrees interval, the following files will be generated:

    r100_d000.wav
r100_d010.wav
...
r100_d350.wav

2. Calculating impulse responses from TSP signals.
The impulse response is calculated by convolving the reverse TSP signal with the signal recorded in a way described above, and synchronously adding multiple playbacks to find the average value. harktool can be used in calculating impulse response. See the chapter on harktool in the HARK document for more details.

Discussion

Impulse response is an output of the system following the application of an impulse function to the system. Intuitively, the reverberation you hear upon clapping your hands in a room is a type of impulse response. The problem in actually measuring the “impulse response” is the need for a large amount of energy with a sufficient signal-to-noise ratio. To solve this problem, the impulse response is measured using a Time Stretched Pulse (TSP) signal, whose energy is stretched over time. Impulse response can be determined by recording the TSP and calculating the converse and inverse of the TSP [1,2]. The best interval between measurements is usually around 5 or 10 degrees, although it depends on the microphone array and on the shape and configuration of the room.