Main Content

impzest

Estimate impulse response of audio system

Description

ir = impzest(excitation,response) returns an estimate of the impulse response (IR) based on the excitation and response.

example

ir = impzest(excitation,response,Name,Value) specifies options using one or more Name,Value pair arguments.

example

Examples

collapse all

Create a sweep tone excitation signal by using the sweeptone function.

excitation = sweeptone(2,1,44100);

plot(excitation)
title('Excitation')

Figure contains an axes object. The axes object with title Excitation contains an object of type line.

Pass the excitation signal through an infinite impulse response (IIR) filter and add noise to model a real-world recording (system response).

[B,A] = butter(10,[.1 .7]);
rec = filter(B,A,excitation);
nrec = rec + 0.12*randn(size(rec));

plot(nrec)
title('System Response')

Figure contains an axes object. The axes object with title System Response contains an object of type line.

Pass the excitation signal and the system response to the impzest function to estimate the impulse response. Truncate the estimate to 100 points. Use impz to determine the true impulse response of the system. Plot the true impulse response and the estimated impulse response for comparison.

irEstimate = impzest(excitation,nrec);
irEstimate = irEstimate(1:101);

irTrue = impz(B,A,101);
plot(0:100,irEstimate, ...
     0:100,irTrue,'ro')

legend('True impulse response','Estimated impulse response')

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent True impulse response, Estimated impulse response.

Use audioread to read in an impulse response recording. Create a dsp.FrequencyDomainFIRFilter object to perform frequency domain filtering using the known impulse response.

[irKnown,fs] = audioread('ChurchImpulseResponse-16-44p1-mono-5secs.wav');
systemModel = dsp.FrequencyDomainFIRFilter(irKnown');

Create an MLS excitation signal by using the mls function. The MLS excitation signal must be longer than the impulse response. Note that the length of the MLS excitation is extended to the next power of two minus one.

excitation = mls(numel(irKnown)+1);

plot(excitation)
title('Excitation')

Figure contains an axes object. The axes object with title Excitation contains an object of type line.

Replicate the excitation signal four times to measure the average of three measurements. The recording of the first MLS sequence does include all the impulse response information, so impzest discards it as a warmup run. Pad the excitation signal with zeros to account for the filter latency.

numRuns = 4;
excrep = repmat(excitation,numRuns,1);
excrep = [excrep;zeros(numel(irKnown)+1,1)];

Pass the excitation signal through the known filter and then add noise to model a real-word recording (system response). Cut the delay introduced at the beginning by the filter.

rec = systemModel(excrep);
rec = rec + 0.1*randn(size(rec));

rec = rec(numel(irKnown)+2:end,:);

plot(rec)
title('System Response')

Figure contains an axes object. The axes object with title System Response contains an object of type line.

In a real-world scenario, the MLS sequence is played back in the system under test while recording. The recording would be cut so that it begins at the moment the MLS sequence is picked-up and truncated to last the duration of the repeated sequence.

Pass the excitation signal and the system response to the impzest function to estimate the impulse response. Plot the known impulse response and the simulation of the estimated impulse response for comparison.

irEstimate = impzest(excitation,rec);

samples = 1:numel(irKnown);
plot(samples,irEstimate(samples),'bo', ...
     samples,irKnown(samples),'m.')

legend('Known impulse response','Simulation of estimated impulse response')

Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Known impulse response, Simulation of estimated impulse response.

Input Arguments

collapse all

Single period of excitation signal input to audio system, specified as a column vector.

You can generate excitation signals by using mls (maximum length sequence) or sweeptone (exponential sine sweep).

Data Types: single | double

Recorded signal output from audio system, specified as a column vector or matrix. If specified as a matrix, each column of the matrix is treated as an independent channel.

Data Types: single | double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'WarmupRuns',2

Number of warmup runs in the response, specified as a nonnegative integer. The impzest function estimates the impulse response after discarding the specified number of warmup runs from the response.

The default number of warmup runs depends on whether the excitation signal was generated using the mls or sweeptone function:

  • mls –– 1

  • sweeptone –– 0

Data Types: single | double

Output Arguments

collapse all

Estimate of the impulse response of an audio system, returned as a column vector or matrix. The size of ir is L-by-C, where:

  • L –– MLS length or duration of sweep tone silence

  • C –– Number of columns (channels) in the response signal

Data Types: single | double

References

[1] Farina, Angelo. "Advancements in Impulse Response Measurements by Sine Sweeps." Presented at the Audio Engineering Society 122nd Convention, Vienna, Austria, 2007.

[2] Guy-Bart, Stan, Jean-Jacques Embrachts, and Dominique Archambeau. "Comparison of Different Impulse Response Measurement Techniques." Journal of Audio Engineering Society. Vol. 50, Issue 4, 2002, pp. 246–262.

[3] Armelloni, Enrico, Christian Giottoli, and Angelo Farina. "Implementation of Real-Time Partitioned Convolution on a DSP Board." Application of Signal Processing to Audio and Acoustics, 2003 IEEE Workshop, pp. 71–74. IEEE, 2003.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018b