question: How do phones avoid a feedback loop or echo in speaker mode
comment: /u/Uumus guessed it correctly. First of all, the phone is designed to try to minimize how much of the speaker output gets to the microphone. But it can't always do this well enough. In that case, a cancelling circuit is added. It "subtracts" the speaker output signal from the input of the microphone, so the feedback loop is virtually eliminated. This is typically done in the digital domain by a Digital Signal Processor, after your analog voice input has been turned into a stream of bits (1s and 0s). That's because there's a DSP chip being used anyway, and it's easier to do the subtraction accurately with digital signals.
passages: Modern mobile phones use a multi-microphone design to cancel out ambient noise from the speech signal. Software is used to subtract the sound captured by the microphone(s) placed furthest from the mouth, from the microphone closest to the mouth, which produces a much clearer speech quality.
  
  Section::::Active vs. passive noise control.
   BULLET::::- Hands-free car phone systems
  
  BULLET::::- A standard telephone or cellphone in speakerphone or hands-free mode
  
  BULLET::::- Dedicated standalone "conference phones"
  
  BULLET::::- Installed room systems which use ceiling speakers and microphones on the table
  
  BULLET::::- Physical coupling (vibrations of the loudspeaker transfer to the microphone via the handset casing)
   There are strong concerns that the ever-listening microphone of smart speakers presents a perfect candidate for a wiretap. In 2017, British security researcher Mark Barnes showed that pre-2017 Echos have exposed pins that allow for a compromised OS to be booted.
  
  Section::::Privacy concerns.:Voice assistance vs privacy.
   Full-duplex audio systems like telephones can create echo, which needs to be removed. Echo occurs when the sound coming out of the speaker, originating from the far end, re-enters the microphone and is sent back to the far end. The sound then reappears at the original source end, but delayed. This feedback path may be acoustic, through the air, or it may be mechanically coupled, for example in a telephone handset. Echo cancellation is a signal-processing operation that subtracts the far-end signal from the microphone signal before it is sent back over the network.
   TADs with digital storage for the recorded messages do not show this delay, of course.
  
  Section::::Pure voice operation.:Remote control.
  
  A TAD may offer a remote control facility, whereby the answerphone owner can ring the home number and, by entering a code on the remote telephone's keypad, can listen to recorded messages, or delete them, even when away from home.
   Section::::Operation.
  
  The echo cancellation process works as follows:
  
  BULLET::::1. A far-end signal is delivered to the system.
  
  BULLET::::2. The far-end signal is reproduced.
  
  BULLET::::3. The far-end signal is filtered and delayed to resemble the near-end signal.
  
  BULLET::::4. The filtered far-end signal is subtracted from the near-end signal.
  
  BULLET::::5. The resultant signal represents sounds present in the room excluding any direct or reverberated sound.
   When silence suppression is active, the line appears to have gone dead at the other (egress) end of the call. For this reason, so-called "comfort noise" needs to be generated to compensate for the lack of background noise. The ingress end must therefore signal the egress end that silence suppression is in effect. For best results, the level of comfort noise being generated on egress should match that of the background noise at the ingress end.
  
  Speech activity detection must occur very quickly, otherwise clipping might occur.
   Half-duplex speakerphones only allow sound to travel in one direction at a time, either: 1) into the speakerphone from the telephone line and out of its internal speaker to its user, or 2) from its user, into the microphone, and out through the telephone line. While the users of the speakerphone are speaking, the phone only transmits sound to the telephone line; its internal speaker is cut off and no sound arriving from the telephone line can be heard by the user. While the user of the speakerphone is quiet, the speakerphone only receives sound from the telephone line and its internal speaker broadcasts that sound to its user. There is a very definite, noticeable switching action each time the phone "changes directions" and a cough or other transient noise in the room may interrupt incoming sound from the far end of the telephone connection.
   Full-duplex speakerphones are able to transmit and receive simultaneously and there is no discernible change of transmission direction. These phones are much more complicated and often employ sophisticated digital signal processing algorithms to sort out the incoming sound and the sound in the room for echo cancellation. Their cost is also higher than for a half-duplex speakerphone.
  
  Section::::Speakerphone setup.
   BULLET::::- Clipping: Since the echo suppressor is alternately inserting and removing loss, there is frequently a small delay when a new speaker begins talking that results in clipping the first syllable from that speaker's speech.
  
  BULLET::::- Dead-set: If the far-end party on a call is in a noisy environment, the near-end speaker will hear that background noise while the far-end speaker is talking, but the echo suppressor will suppress this background noise when the near-end speaker starts talking. The sudden absence of the background noise gives the near-end user the impression that the line has gone dead.
   Though solid-state analog delays are less flexible than digital delays and generally have shorter delay times, several classic models such as the discontinued Boss DM-2 are still sought after for their "warmer", more natural echo quality and progressively decaying echos.
  
  Section::::Digital delay.
   Along with the microphone and speaker, additional circuitry is incorporated to prevent the incoming speaker signal and the outgoing microphone signal from interfering with each other. This is accomplished through a hybrid coil (A3). The incoming audio signal passes through a resistor (A8) and the primary winding of the coil (A3) which passes it to the speaker (A1). Since the current path A8 – A3 has a far lower impedance than the microphone (A2), virtually all of the incoming signal passes through it and bypasses the microphone.
   Since handsfree devices replace a phone's own speaker and microphone capability in a phone call, they now also must deal with the same issues that standard mobile phones and land phones deal with. The main acoustic issues are echo cancellation and noise suppression, although there are others as well. There have been many ways developed to cancel echo in phone calls and results range from poor to excellent. 
   Section::::Consumer models.:Crossfeed and other audio processing.
   The effects available in the Evolver include distortion, delay, hack, feedback, and grunge. The distortion is digital, and at the value of 1, the distortion acts as a noise gate. There is a 3-tap delay, meaning that the signal can be delayed with three flexibly programmable delays that are independent from each other. The hack effect "trashes" the output (it can also be applied to external audio before the low pass filter), it produces an effect similar to bit reduction or decimation. There is also an option to create independent stereo feedback loops, which is routed through the filter. The grunge option produces a nasty feedback at higher levels, but has no effect at lower levels.
   However, phonemes are not sounds in themselves. Rather, phonemes are, in a sense, converted to phones before being spoken. The phoneme, for instance, can actually be pronounced as either the phone or the phone since is frequently devoiced, even in fluent speech, especially at the end of an utterance. The sequence of phones for "nods" might be transcribed as or , depending on the presence or strength of this devoicing. While the phone has articulatory voicing, the phone does not have it.
   BULLET::::- Double-talk: It is fairly normal in conversation for both parties to speak at the same time, at least briefly. Because each echo suppressor will then detect voice energy coming from the far-end of the circuit, the effect would ordinarily be for loss to be inserted in both directions at once, effectively blocking both parties. To prevent this, echo suppressors can be set to detect voice activity from the near-end speaker and to fail to insert loss (or insert a smaller loss) when both the near-end speaker and far-end speaker are talking. This, of course, temporarily defeats the primary effect of having an echo suppressor at all.
   Leaked documents published by WikiLeaks, codenamed Vault 7 and dated from 2013 to 2016, described the capabilities of the United States Central Intelligence Agency (CIA) to perform electronic surveillance and cyber warfare, including the ability to compromise the operating systems of most smartphones, turning them into permanent listening devices. Millions of smartphones could also be vulnerable to hacking via accelerometers.
   The first problem means that we heard a sound directly in front of a subject when it is located at the back in fact or vice versa. This problem can be lessened by accurate inclusion of the subject's head movement and pinna response. And if these two are missed during the HRTF calculation, the reverse problem will occur. And there exists another method to solve this problem, the early echo response. Some people proposed a refined algorithm which exaggerates the differences for the sounds from different directions and strengthen the pinnae effects to reduce the front-to-back reversal rates.
   "Voice-Activated Switch" selectively chooses a feed to display at each endpoint, with the goal of showing the person who is currently speaking. This is done by choosing the feed (other than the viewer) which has the loudest audio input (perhaps with some filtering to avoid switching for very short-lived volume spikes). Often if no remote parties are currently speaking, the feed with the last speaker remains on the screen.
  
  Section::::Technology.:Echo cancellation.
   It is the case that a "stereo system" with external speaker attached by long leads to the main unit (holding the audio electronics) can be troubled by EMC problems which are caused by the speaker leads acting as a dipole antenna.
  
  One method of curing this is to add a ferrite choke to the speaker leads close to where they enter the main unit.
  
  Section::::Audio equipment.:Rectification in the audio equipment.
   There are two analog low pass filters, one for each stereo channel. Each low pass filter can be changed between 4-pole or 2-pole. Unless programmed otherwise (split), the two analog filters each retain the same settings, thus processing the audio in both channels identically. However, since the filters are analog, even if they are working at identical settings, there will be slight variations in each filter's output. Each filter has its own ADSR envelope generator, and the low pass filters are also resonant, and can self oscillate.
   BULLET::::- 2011 – Introduced TrulyHandsfree Voice Control with enhanced accuracy and command and control
  
  BULLET::::- 2012 – Partnered with Tensilica to offer complete speech recognition subsystem; introduced Speaker Verification and Speaker Identification for mobile phones and other consumer electronics; TrulyHandsfree integrated into Samsung's Galaxy S3 along with S2 and Note
  
  BULLET::::- 2013 – Partnered with Conexant to offer far-field voice triggers and Ceva and Wolfson to offer ultra-low power solution for Truly HandsfreeTM Voice Control; introduced TrulyHandsfree Voice Control 3.0 in SDKs and Tensilica's ultra-low power solution; integrated in Samsung Galaxy S4
   Some users of the iPhone 4S reported the random appearance of echoes during phone calls made with earphones in the initial release of iOS 5. The other party in the call was sometimes unable to hear the conversation due to this problem.
  
  Section::::Reception.
   Although echo suppressors and echo cancellers have similar goals—preventing a speaking individual from hearing an echo of their own voice—the methods they use are different:
  
  BULLET::::- Echo suppressors work by detecting a voice signal going in one direction on a circuit, and then muting or attenuating the signal in other direction. Usually the echo suppressor at the far end of the circuit does this muting when it detects voice coming from the near-end of the circuit. This muting prevents the speaker from hearing their own voice returning from the far end.
  