Live data from Hacker News

Ask HN: How do browsers isolate internal audio from microphone input?

news.ycombinator.com

81–90 of 106 posts

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#81
post #41

Earlier quoted context omitted.

Assuming this isn't parody, the OS doesn't have to do it automatically. Having an application grab a microphone stream and say to the OS "take this and cancel any audio out streams" might be pretty useful.

I agree with that, but the point I'm trying to make is that audio i/o handling is pretty complicated and application specific. The idea I'm challenging is that "any app that wants microphone input wants this" is dubious. I'd say it's only a small number of audio applications that care about mic input want background noise reduced - and it makes sense for this to be configured per-input stream. Really what would be ni…

Every normal application already does it through the os because most do not care about this at all.

Music player, browser, games, video player...

Audio is not app specific

The only application were this is true is audio were you want full control and low latency.

I find your take very weird.

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#82

Earlier quoted context omitted.

> Why does the OS not provide a way to do this? Some do. But you need to have a strong-handed OS team that's willing to push everybody towards their most modern and highly integrated interfaces and sunset their older interfaces. Not everybody wants that in their OS. Some want operating systems that can be pieced together from myriad components maintained by radically different teams, some want to see their API's/inte…

[flagged]

Weird macrosensivity

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#83

Earlier quoted context omitted.

Echo cancellation is often disabled if you have headphones plugged in, under the assumption that headphones won't be audible in the microphone, and it's better to disable it to avoid it degrading your microphone signal. It might be that whatever program you're using doesn't know the difference between speakers and headphones (possibly because you're using the 3.5mm jack?)

jokes on them, some of us use the headphone jack

There's a whole subfield of "jack detection" (where the final amp stage attempts to determine what's plugged in) and probably a "jack assignment" panel in your driver software that can configure whether the OS thinks of it as "speakers" or "headphones".

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#84

The technical term that you're looking for is acoustic echo cancellation[1]. It's a fairly common problem in signal processing, and comes up in "simple" devices like telephones too. [1] https://www.mathworks.com/help/audio/ug/acoustic-echo-cancel...

I seem to remember analog telephone lines used a very simple but magic-looking transformer-based circuit of some sort for this purpose. Presumably that worked because they didn’t need to worry about a processing delay?

There used to be a transformer in phones for side tone, a small amount of what you say is piped back into the earpiece, they did this because they found people would shout if they couldn't here their own voice. I've often wished mobiles would do this.

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#85

Side note, this can also cause a bit of difficulty in some situations apparently as seen in a HN post from a few months ago that didn’t get much attention https://news.ycombinator.com/item?id=39669626 > I've been working on an audio application for a little bit, and was shocked to find Chrome handles simultaneous recording & playback very poorly. Made this site to demo the issue as clearly as possible https://chrome-…

Not sure if it's the whole story, but the latest response in the linked Chrome ticket seems to indicate that the api's were used incorrectly by the author

>

> Status: Won't Fix (Intended Behavior)

> Looking at the sample in https://chrome-please-fix-your-audio.xyz, the issue seems to be that the constraints just aren't being passed correctly [...]

> If you supply the constraints within the audio block of the constraints, then it seems to work [...]

> See https://jsfiddle.net/40821ukc/4/ for an adapted version of https://chrome-please-fix-your-audio.xyz. I can repro the issue on the original page, not on that jsfiddle.

https://issues.chromium.org/issues/327472528#comment14

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#86
post #71

Earlier quoted context omitted.

There is a third place: a common library that all the apps use. If it is in the OS then it becomes brittle. If there's an improvement in the technology which requires an API change, that becomes difficult without keeping backwards compatibility or the previous implementation forever. Instead, there would be a newer generation common library which might eventually replace the first but only if the entire ecosystem cho…

> If it is in the OS then it becomes brittle My experience is the opposite. When it's part of the OS, it's stable and you just say "you need OS version X or better" and it will just work. When it's a library, you eventually end up in dependency hell of deprecated libraries and differing versions (or worst case, the JavaScript ecosystem when the platform provides almost nothing and you get npm).

Depends on the OS I guess. When it's established enough, all distributions carry a high enough version that it's not an issue. If it's not established enough, I'd argue that it isn't ready to be part of an "OS" anyway (regardless of the definition of that word).

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#88
post #30
post #7

The way this works (and I'm obviously taking a high level view here) is by comparing what is being played to what is being captured. There is an inherent latency in between what is called the capture stream (the mic) and the reverse stream (what is being output to the speakers, be it people taking or music or whatever), and by finding this latency and comparing, one can cancel the music from the speech captured. With…

This reminds me of: >The missile knows where it is at all times. It knows this because it knows where it isn't. By subtracting where it is from where it isn't, or where it isn't from where it is (whichever is greater), it obtains a difference, or deviation https://knowyourmeme.com/memes/the-missile-knows-where-it-is

This is almost weirdly philosophical. I've been thinking about this all morning.

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#89

Earlier quoted context omitted.

As others have noted, this is trivial for most macOS and iOS apps to opt in to. Frankly, I imagine its also available at the system level on Windows (and maybe Android and Linux) but probably only among applications that happen to be using certain audio frameworks/engines.

It doesn't seem to me that module-echo-cancel in Pulseaudio completely meets the requirements here (only one source), but it looks close, and seems in general like where you would implement something like this. 1. https://www.freedesktop.org/wiki/Software/PulseAudio/Documen...

I think module-null-sink and module-loopback could be used to create a virtual source which combines multiple sources, though the source/sink thing makes my head spin. Or, more simply, I suppose using the loopback of whatever audio output device does the combination (and the same mixing) for you, if you play all audio through one output device (which is most likely)?

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#90
post #83

Earlier quoted context omitted.

jokes on them, some of us use the headphone jack

There's a whole subfield of "jack detection" (where the final amp stage attempts to determine what's plugged in) and probably a "jack assignment" panel in your driver software that can configure whether the OS thinks of it as "speakers" or "headphones".

Oh probably by the impedance/reactance and the DC resistance I'm guessing!
Post reply on HN