-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microphone volume is extremely quiet on built-in MacBook Pro microphone #239
Comments
(For the sake of simplicity, I have the output going to the default output device, which in this case is my headphones, so there should not be any echo cancellation effects) |
@Pehrsons should know about this. @mutexlox-signal, what mbp are you using here? There are lots of bugs or other weirdness that depend on macOS versions and the hardware in use, so it would help to get more info. The backend attempts to workaround most bugs, but maybe there's more. |
It happens on both a Mac14,9 and a Mac15,8 (both on sonoma, 14.6.1), but it does not happen with the older audiounit C++ backend, so I suspect it's not a new bug in the hardware? |
I'm not sure what you're experiencing, so I'll write a few different things here in the hope to provide enough context to characterize the issue. To make things clear, when you're running this program, is the output low, the input low, or both? The rust backend can use a widely different API underneath than the older C++ backend, called VoiceProcessingIO (often abbreviated VPIO). This VPIO is, as the name says, optimized for speech-type input output, and allows processing the audio to be much better for speech (echo cancellation, noise suppression, automatic gain adjustment etc. you name it). It's great but has lots of bugs, and here's the logic to use it or not: https://github.com/mozilla/cubeb-coreaudio-rs/blob/trailblazer/src/backend/mod.rs#L3351-L3358. It depends on the macOS version, the device hooked up, and whether Additionally, we're still attempting to understand what is going on in https://bugzilla.mozilla.org/show_bug.cgi?id=1896938 (Firefox's bug tracker), but so far we haven't been successful. As a cubeb API user, you can test various things, such as passing in @Pehrsons is the person working on this but is off this week. |
Both, but when I select a different default device in system settings (e.g. my webcam's mic) both input and output are normal. If I recall correctly, I saw the log:
for this device. That bugzilla bug does, indeed, seem very relevant, and perhaps even likely the same. |
Correction: other unrelated audio dips (or possibly pauses) momentarily when the stream starts and ends, but while the streams are going the output from other applications is a normal volume; it appears that it's just the input from the built-in microphone that's low |
Some arbitrary changes/experiments:
|
Following the suggestion in comment22 in the bugzilla thread, I tried: stream.set_input_processing_params(
cubeb_core::InputProcessingParams::ECHO_CANCELLATION
| cubeb_core::InputProcessingParams::NOISE_SUPPRESSION
| cubeb_core::InputProcessingParams::AUTOMATIC_GAIN_CONTROL,
); This seems to have made the audio as captured by cubeb audible, but System Settings does still show very low levels of input, so I suspect simultaneous use of the microphone by another application would still be affected. |
And in case it helps: Logs without the input processing params and with the rust backend:
and with the input processing params:
and with the older C++ backend:
|
Intriguingly, the issue does not reproduce with audiounit (the C++ one) and a manual request of the VOICE StreamPrefs. |
As you have found, this is an Apple issue with the VoiceProcessingIO audio unit. If the builtin mic is hooked up to VPIO its volume will be very low in any concurrent non-VPIO uses. Even in other processes. Try simultaneously using the builtin mic in Safari and Chrome or System Settings. Because of this we introduced a force-list forcing VPIO for builtin mics even if the VOICE pref isn't passed. With VPIO but without any applied processing params, we put the VPIO unit in bypass mode. You'd imagine then that it behaves like the HAL unit. It doesn't. But it seemed to work ok until the M3 MBPs came out. With them and VPIO in bypass we started getting reports of low volume again. Another Apple issue I am still pondering how best to fix. Maybe we should drop the force-list. But then 1 VOICE and 1 non-VOICE stream on the builtin device won't work as expected (Google Meet in Firefox results in this). My best bet so far is to disallow bypass when using VPIO, but that's a number of API and Gecko changes away from materializing (see https://bugzilla.mozilla.org/show_bug.cgi?id=1914046). If you're developing another client I think your best bet is to always request VOICE and set AEC+NS+AGC processing params. That should result in the least issues while getting Apple's excellent processing. Or do like the c++ backend and stick with the HAL unit by removing the force-list (you'd have to fork or perhaps we could add another pref) and never pass VOICE. |
Got it, I see! Seems like you've spent many frustrating days on this issue. I appreciate the info, and I'll just set AEC+NS+AGC where available. |
more like weeks or months, but yeah. |
Yeah that sounds right actually. 🙃 |
When the default device on an MBP is the built-in microphone, and I configure cubeb with mono input from the default device, the volume drops to an imperceptibly low level (even when the sound is very loud), both for the input cubeb receives and the sound the System Settings pane registers.
Reproduction code using cubeb-rs:
I created a repository to simplify reproduction, at https://github.com/mutexlox-signal/test-coreaudio-rs
To reproduce:
The text was updated successfully, but these errors were encountered: