# How can I convert the sweep signal into the impulse response?

Does someone know, how to convert the sweep signal into the impulse response?

What kind of results will come out?

I generated a sweep signal from REW software and then correct the output value sweep signal from the compressor.

How can I convert the sweep signal into an impulse response with MATLAB?

• Hello Heimishyun and welcome to DSP SE. I think you should provide a little bit more information as to what exactly you are trying to achieve. What is that you are measuring, which measurement method do you use (I assume you use the Exponential Sine Sweep - ESS), what have you achieved so far and where exactly are you stuck. This way will be easier for people to provide help. Mar 12, 2023 at 12:16
• Your question seems to suggest that you are trying to capture the response of a dynamics compressor. Such a deeply nonlinear system cannot be characterised by its impulse response and a sweep also cannot be used to measure this response. Mar 13, 2023 at 0:50
• Relevant answer: dsp.stackexchange.com/a/41700/8202 However, few notes on your approach. First of all, measuring IR of compressor is not a good idea - it's a Time Variant system due to attack / release. You will get different results depending on length of sweep, it's level, etc. Second of all, RoomEqWizard has a measurement sweep option, where in signal generator you create a recording, play it back through whatever chain you want and capture the output. Then, in the menu, you can go into "Import" and select measurement sweep. After that, provide both original and recording.
– jojeck
Mar 13, 2023 at 8:05
• @jojek actually, dynamics processors are not usually time variant. A time-shifted input produces an output with the same time-shift. The envelope follower and its modulation of the output gain is non-linear, however. Mar 16, 2023 at 11:08

I assume you are using the Exponential Sine Sweep (ESS) method introduced by Angelo Farina which Room EQ Wizard (I assume this is your REW software) uses for measurements.

## The Method

The "mathematical idea" behind the use of the technique is similar (if not identical) to the Maximum Length Sequence (MLS) and the Time Domain Spectroscopy (TDS) (TDS is very similar to ESS with the former using a sine whose frequency changes linearly with time). The idea behind all those methods is to measure a Device Under Test (DUT) (which of course can be any system modelled as a "device") with a specific signal. The result of the measurement will be the convolution of the measurement signal and the impulse response of the DUT. This is shown mathematically in equation \ref{1} below

$$y \left( t \right) = x \left( t \right) * h \left( t \right) \tag{1} \label{1}$$

where $$*$$ denotes convolution and $$h \left( t \right)$$ is the impulse response of the DUT. The same operation (convolution) can be performed in the frequency domain like

$$\mathcal{FT} \left\{ y \left( t \right) \right\} = \mathcal{FT} \left\{ x \left( t \right) \right\} \mathcal{FT} \left\{ h \left( t \right) \right\} \implies Y \left( \omega \right) = X \left( \omega \right) H \left( \omega \right) \tag{2} \label{2}$$

with $$\mathcal{FT}$$ denotes the Fourier Transform and $$\omega$$ is the radial frequency for which $$\omega = 2 \pi f$$ is true with $$f$$ being the temporal frequency.

The next step is to deconvolve the measurement signal from the measurement result so that we are left with the impulse response of the DUT. The easiest way to do that is in the frequency domain like shown in equation \ref{3}. Starting from equation \ref{2} and solving for the transfer function (actually the frequency response of the impulse response) we get

$$Y \left( \omega \right) = X \left( \omega \right) H \left( \omega \right) \implies H \left( \omega \right) = \frac{Y \left( \omega \right)}{X \left( \omega \right)} \tag{3} \label{3}$$

Then, by applying the Inverse Fourier Transform operator to the transfer function we end up with the impulse response (time-domain) of the DUT. This is shown in equation \ref{4} below.

$$h \left( t \right) = \mathcal{IFT} \left\{ Y \left( \omega \right) \right\} \tag{4} \label{4}$$

## MATLAB Code

Now, regarding the MATLAB code to achieve that. I assume you already have some of the variables/data you need and I'll make this explicit in the code with comments. One way to achieve that is the following, where equations \ref{3} and \ref{4} are directly implemented.

% x is the sweep used for the measurement
% y is the measurement (output of the DUT when excited with the sweep)

% Here I assume the length of the measurement vector is adequately long to avoid aliasing artifacts from the DUT's impulse response
X = fft(x, length(y)); % Input signal in frequency domain
Y = fft(y); % Output signal in frequency domain

% Calculate the transfer function
H = Y./X; % Transfer function (frequency-domain)

% Go back to time domain
h = ifft(h); % Impulse response (time-domain)
fftshift(h); % This is needed due to the implementation of the FFT algorithm



$$Y \left( \omega \right) = X \left( \omega \right) H \left( \omega \right) \implies H \left( \omega \right) = Y \left( \omega \right) \frac{1}{X \left( \omega \right)} \tag{5} \label{5}$$
where $$\frac{1}{X \left( \omega \right)}$$ is the inverse filter that performs the deconvolution process you are after. If any of the frequency bins has a zero, or very small (or possible a very high) value then you'll end up introducing high numerical errors and the inversion will not be correct. In the best case scenario, if this happens, you'll end up with something completely wrong which will be easy to identify. In the worst case, the errors will not be extreme and will be very hard to spot and you'll have to resort to evaluation methods, of which the easiest is to compare with some known DUTs measured with some qualified and completely characterised system.