0
$\begingroup$

I had to read input .wav audio file first, then add Gaussian white noise to the input audio signal and I've finished that part. Now I have to add a channel model whose impulse response is:

h[n] = [−0.015, 0.058, −0.350, 1.000, −0.350, 0.058, −0.005] 

enter image description here

This is what the communication system should look like. I have to add this impulse response and then plot the output signal but I don't really understand how to do that. I've tried this using scipy:

system = ([1.0],[-0.015,0.058,-0.350,1.000,-0.350,0.058,-0.005])
t2, y = signal.impulse(system)
plt.figure(3)
plt.plot(t2, y)

But the output doesn't look right

Input signal enter image description here

enter image description here

Impulse response output

$\endgroup$
5
  • $\begingroup$ A signal does not have an impulse response. An impulse response itself is a signal, but it is the response of a specific sort of system to a specific sort of signal. To add to the confusion, you don't reference your input signal in your code at all. Could you please edit your question to state (a) what you're actually doing, and (b) what you're trying to achieve. $\endgroup$
    – TimWescott
    Dec 25, 2022 at 20:03
  • $\begingroup$ Sorry, I am just trying to understand this for an exam. I had to read input .wav audio file first, then add Gaussian white noise to the input audio signal and I've finished that part. Now I have to add a channel model whose impulse response is: h[n] = [−0.015, 0.058, −0.350, 1.000, −0.350, 0.058, −0.005] but I don't really understand how to do that. $\endgroup$
    – Xavi
    Dec 25, 2022 at 20:22
  • $\begingroup$ Oops -- I left out the part where I checked to see that you're a newbie and then tell you to edit your question with that information so that it is complete. It's a Stackexchange thing -- unlike other forums, we want complete questions and complete answers, without bits & pieces buried in the comments. $\endgroup$
    – TimWescott
    Dec 25, 2022 at 20:29
  • $\begingroup$ While you're going to the effort of editing the question, you should also look at the documentation for the signal.impulse function -- look at what you're giving it as input, and ask yourself if you're describing a system whose impulse response is as you specify? $\endgroup$
    – TimWescott
    Dec 25, 2022 at 20:33
  • $\begingroup$ Thanks, I edited my question, I hope it's understandble now. I also read the documentation, in fact I'm still reading but not quite sure how to add this channel block, I need to add the output of this impulse response to the previous signal, right,but how? $\endgroup$
    – Xavi
    Dec 25, 2022 at 20:45

1 Answer 1

0
$\begingroup$

Ok so your assignment is:

  1. Read an input .wav file, let's call it $x_1[n]$
  2. Add White Gaussian noise: $x[n] = x_1[n] + \nu[n]$

You've done these steps, I'll assume correctly.


3. Pass this noisy signal through a system with given impulse response $h[n]$. That's the part you're having trouble with.

Look at the documentation for scipy.signal.impulse: the first thing you'll see is

Impulse response of continuous-time system.

First, your system isn't continuous, it's discrete, and second, you already know the impulse response: $h[n]$.

Let's back-track a little bit. I'll assume you have some theoretical background on what a digital system is and how it can take an input and produce an output. I'll write it out here for completeness, it's called convolution:

$$y[n] = x[n] \star h[n] \tag{1}$$ where $y[n]$ is the output to the system with impulse response $h[n]$, when fed with input $x[n]$.

You have $x[n]$ and $h[n]$ already, and you're looking to compute $y[n]$, so you're looking for a way to implement (1). Here comes scipy.signal.lfilter which does just that. The documentation starts with:

Filter data along one-dimension with an IIR or FIR filter.

[...]

Parameters

b: array_like The numerator coefficient vector in a 1-D sequence.

a: array_like The denominator coefficient vector in a 1-D sequence. If a[0] is not 1, then both a and b are normalized by a[0].

x: array_like An N-dimensional input array.

Your system is what we call a FIR filter, so it does not have a denominator (to be more precise, its denominator is $1$), and its numerator is equal to the Finite Impulse Reponse $h[n]$

To implement (1):

y = signal.lfilter(h,1,x)
$\endgroup$
1
  • 1
    $\begingroup$ Thank you, that was a great explanation $\endgroup$
    – Xavi
    Dec 25, 2022 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.