Pseudocode for an echo using recursion [closed]

Using pseudocode, what would the code for an echo using recursion be?

UPDATE: Appears I should have been more clear. By echo I mean the pattern sound exhibits when it echos, not echo as in repeatly add one to self where self equals zero. Any thought on what the code would look like for a "real" echo? For example, I'd thought about "echo(reduce-volume();exit-if-silent;echo())" but was sure if the logic made sense.

UPDATE-2: Working through my own logic above an noticed it lacks a way to account for "positive feedback", which I'm guessing is required.

http://en.wikipedia.org/wiki/Positive_feedback

closed as too broad by gnat, user40980, jwenting, ChrisF♦May 5 '14 at 10:37

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

``````echo sound clip S at volume V:
if V is zero, done. (Exit recursion.)
start playing S.
V = V * F.
Wait for time T.
echo sound clip S at volume V.
``````

`F` is the attenuation factor, and I suppose a good value for it would be 0.5

`T` is the delay between repetitions of the echo, it simulates the distance of the echoing wall.

Note: of course, this is just tail recursion, so it can be trivially converted into a loop. However, it is possible to extend it to simulate multiple echoing walls at different distances, in which case the recursion might be the best way to do it.

Positive feedback cannot be accounted for without working with the individual samples that the waveform is composed of, which calls for an altogether different, and far more complicated solution.