# Modelling an existing DSP filter by analysing the differences between its inputs and outputs

A DSP filter produces always the same output.

$$\boxed{\textrm{wav file}}{\longrightarrow}\boxed{\textrm{DSP}}{\longrightarrow}\boxed{\textrm{wav file(modified)}}$$

The DSP is a black box as I don't have access to its code, but I have access to original and modified wav files.

Questions:

1. Can the DSP filter be mathematically modelled (say in MATLAB) by comparing the original and modified wav files?
2. If so, would the resulting modelled DSP, when applied to any wav file, generate a wav equals to the one that will be produced by the original DSP?
• Yes, thanks Ollie for spotting that. I have fix it. Also, thanks for the formatting improvements. – John Casablanca Oct 26 '16 at 2:30
• "A DSP filter produces always the same output"... when fed the same input, I hope. – Rodrigo de Azevedo Oct 26 '16 at 11:14
• Yes, you're right. I was trying to outline that the DSP, from a system perspective, was time-invariant, which is what we "expect" anyway. – John Casablanca Oct 28 '16 at 6:05

If I understood correctly, you have a signal $x[n]$ and an unknown discrete-time LTI filter, so that you can look at the output of the filter $y[n]$. Now you are looking for the impulse response of the filter $h[n]$.

The output follows a convolution rule $$y[n]=x[n]*h[n]=\sum_{m=-\infty}^{\infty}x[m]h[n-m]$$ The process to find $h[n]$, given $x[n]$ and $y[n]$ is called deconvolution. There are some approaches to do that.

For example, if the Fourier transform of the signals exist, using convolution theorem, the convolution can be converted to product in the frequency domain: $$Y(\omega)=X(\omega)H(\omega)$$ Therefore, $$H(\omega)=\frac{Y(\omega)}{X(\omega)}$$ You should however be careful about the zeros of $X(\omega)$. If $x[n]$ can be an option, then you should choose it such that it can excite the system at all frequencies such that you can probe the desired frequency range that you are interested in $H(\omega)$. Alternatively, you can excite the filter in repeated number of times at different frequencies, which can be interpreted as sampling the frequency response. This will give you a sampled spectrum, so if you know the filter does not have singularities between the sample frequencies, then you can model it by an LTI filter with your desired order (depending on your acceptable approximation error).

In response to your second question, after you acquired an approximation such as $\hat{h}[n]$ for the impulse response, then you can apply it to any desired input by using convolution.

• You're welcome @JohnCasablanca – msm Oct 25 '16 at 21:34

the name of this sub-field of electrical engineering (and signal processing, but the control theory guys are also into it) is "System Identification".

msm's answer is good. but there is enough to this that i remember at Northwestern, there was an entire graduate-level class for it.

another method of doing system identification is to use the LMS or normalized LMS adaptive filter.

i s'pose i could toss up equations, but i better go look them up to make sure i don't err in repeating.