सामग्री पर जाएँ

लेसन 35 · Projects and Practice

Project: Echo, Reverb and Inverse Filtering

Model an echo as an LTI system, study its comb-filter frequency response, add feedback for repeated echoes, estimate the delay by autocorrelation and remove the echo.

Shout in a canyon, and a delayed, quieter copy of your voice comes back. That is an echo, and it is one of the cleanest real-world LTI systems: an output equal to the input plus a delayed, scaled copy. In this project you describe it with an impulse response, a transfer function and a frequency response; add repeated echoes with feedback; find an unknown delay from a recording; and then undo the echo with an inverse filter.

Model 1: a single echo (FIR comb)

With delay D samples and gain a (0 < a < 1):

y[n] = x[n] + a x[n - D].

The impulse response is h[n] = δ[n] + a δ[n - D], two spikes. The transfer function is H(z) = 1 + a z^(-D), which has D zeros spread on a circle of radius a^(1/D) inside the unit circle. On the unit circle:

|H(e^(jω))| = |1 + a e^(-jωD)|.

This ripples between 1 + a (when ωD is a multiple of 2π, echo adds in phase) and 1 - a (when ωD is an odd multiple of π, the echo cancels part of the signal). The picture of peaks and valleys looks like a comb, so this is called a comb filter. It explains the hollow, "phasey" sound of a short echo, and why a hard wall behind a speaker colors its sound.

Python The comb in numbers

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The peaks repeat every fs / D = 200 Hz. A longer delay gives a denser comb.

Model 2: repeated echoes (IIR comb)

A cave or a hallway returns the echo of the echo. Feed the output back:

y[n] = x[n] + a y[n - D], with H(z) = 1 / (1 - a z^(-D)).

The impulse response is h[n] = Σ aᵏ δ[n - kD], an infinite train of spikes with geometrically falling heights. This is the simplest building block of artificial reverb: the Schroeder reverberator uses several such combs with different delays, followed by all-pass filters to thicken the sound. The system is stable when |a| < 1 because all D poles then lie at radius a^(1/D) < 1.

Python Single versus repeated echoes

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Estimating an unknown delay with autocorrelation

Suppose you only have the recording y and want to find D. For a signal x that is nearly random (like noise or speech over a long window), x is uncorrelated with itself shifted by a nonzero lag. The autocorrelation of y = x + a x[n - D] has a peak at lag 0 and another at lag D, of relative height about a / (1 + a²). Computing the autocorrelation with the FFT makes this fast.

Python Finding the echo delay

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Removing the echo: the inverse system

An echo with FIR transfer function 1 + a z^(-D) is undone by H_inv(z) = 1 / (1 + a z^(-D)), the inverse system, which is exactly a feedback comb with gain -a: x_hat[n] = y[n] - a x_hat[n - D]. Because |a| < 1 the inverse is causal and stable, so the original is recovered completely. If the echo were louder than the direct sound (|a| > 1), the zeros of H would lie outside the unit circle and the causal inverse would be unstable, a general rule: an inverse of a stable system is stable only if the system is minimum phase.

Python Dereverberate with the inverse filter

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The exact recovery works because you know a and D exactly and the data has no noise. With noisy data the inverse filter amplifies noise at the frequencies where |H| is small, so real dereverberation uses regularized or adaptive methods.

Ideas to extend the project

  • Load a WAV file locally with scipy.io.wavfile, apply the echo and write it back.
  • Combine four IIR combs with different delays (for example 29.7, 37.1, 41.1 and 43.7 ms) and sum them to build a simple Schroeder reverb.
  • Use the Fourier transform of a measured room impulse response to see its room modes.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What is the transfer function of the single-echo system y[n] = x[n] + a x[n - D]?

    A delay of D samples is z^(-D), so the output transform is X(z)(1 + a z^(-D)).
  2. 2. What is the largest gain of the comb filter 1 + a e^(-jωD)?

    When the echo is in phase with the direct sound, the two add to give 1 + a.
  3. 3. Why does the feedback comb y[n] = x[n] + a y[n - D] need |a| < 1?

    The poles satisfy z^D = a, so they lie at radius |a|^(1/D); only |a| < 1 puts them inside the unit circle.
  4. 4. How can you estimate an unknown echo delay from a recording of random-like sound?

    A delayed copy correlates with the original, so the autocorrelation has a second peak at lag D.

Summary

  • An echo is an LTI system; its impulse response has spikes at the delays.
  • The single echo gives a comb filter with peaks at 1 + a and valleys at 1 - a, spaced fs / D apart.
  • Feedback creates repeated echoes and the first building block of reverb; stability needs |a| < 1.
  • Autocorrelation reveals an unknown delay; a feedback inverse filter removes a known echo.

Next: Practice Problems for Signals and Systems

अपनी प्रगति ट्रैक करें

मुफ़्त अकाउंट बनाएँ, लेसन पूरे के रूप में चिह्नित करें और किसी भी डिवाइस पर वहीं से शुरू करें जहाँ छोड़ा था।