Let say we have a microphone and a speaker. The microphone will receive the surrounding sound, and the speaker will amplify it. Assume we have unlimited power for the microphone and speaker, so they can work forever. When we speak to the microphone, the sound should be repeated by the speaker. While the speaker generates sound, the sound should input to the microphone, and the microphone should repeat to the speaker. So, the sound should never stop, in a loop. But in reality, we don't have this issue. What's going on? Do my assumptions have something missing?
2 Answers
Anyone who's ever set up a public address system knows that we do have this issue. It's generally called feedback, and tends to result in a high-pitched screaming sort of sound. It can be kept under control by careful use of EQ (graphic equaliser) and correct positioning of the microphone and speakers. (Pro audio people probably have lots of other tricks for dealing with it as well.) Basically you get feedback if the overall gain of any frequency is greater than 1, so you need make sure that doesn't happen. If you have a specific system such as a phone or computer where feedback doesn't happen, this is because it's been carefully designed to avoid it.
Nathaniel has provided a good overview of the problem. I am just gonna add some more info on it.
In general, as Nathaniel also mentions, if the feedback gain is less than unity then the response of the system will be an (in theory infinitely) decaying signal (it will also have some frequency "preferences", which means that it will resemble a resonating system, whose behaviour is better described by the term comb filter - https://support.biamp.com/General/Audio/Comb_filters -. For more info look at this DSPRelated article - https://www.dsprelated.com/freebooks/pasp/Comb_Filters.html). This is because the signal coming out from the speaker and being captured back by the microphone will always have a smaller amplitude than the initial signal. This will lead the signal to have a constantly diminishing amplitude, thus it will not loop infinitely.
For an infinite loop to happen the signal/sound emitted by the speaker and then received back from the microphone would have to be at the exact same amplitude as the initial signal, minus the total gain of the system. In addition to that, you have to always keep in mind that since it is audio we are talking about, the phenomenon is frequency-dependent! For more information on the topic, you can have a look at Sound System Engineering book by Davis and Patronis (Chapter 14 of the 4th Edition).
Now, regarding the P.A. "shenanigans" that allow for some increase on the total gain of the system, these include the utilisation of polar patterns (both radiation- loudspeakers- and reception -microphones-) in order to decrease the "amount of signal" coming out of the speakers bleeding back to the microphone(s), as well as the use of filters. Although graphical equalisers were a big thing in the past and are still being used quite a lot, we have the technology and the means in our arsenal to fix the problem in a more "sophisticated" and elegant manner. This is with notch filters, or high Q (for more info see the Wikipedia article - https://www.dsprelated.com/freebooks/pasp/Comb_Filters.html) bandstop filters, in order to attenuate only very small parts of the spectrum that the system prefers to resonate at (usually you can assume that they will have minimum impact on quality, due to masking effect - https://en.wikipedia.org/wiki/Auditory_masking -, and you will always have to consider the tradeoff between quality and quantity -loudness!-). One more way to "optimise" the feedback system is to introduce some delay, thus changing the resonance frequencies of the system to those that your equipment (mics and/or speakers) are not very efficient, resulting in less sound energy circulating the system.
For more information about "fighting feedback", you can have a look at this - https://hub.yamaha.com/how-to-fight-feedback-part-1/- and this - https://hub.yamaha.com/how-to-fight-feedback-part-2/ - articles by Yamaha, and this video - https://hub.yamaha.com/how-to-fight-feedback-part-2/ -. Keep in mind that the material presented there constitutes well-established practices, but it may or may not suit your preferences, case, or equipment availability.