How to prevent applications from changing my mic level?

classic Classic list List threaded Threaded
17 messages Options
S.
Reply | Threaded
Open this post in threaded view
|

How to prevent applications from changing my mic level?

S.
Hi there, recently I've been running into major problems with Electron apps
for the Linux desktop (Microsoft Teams and Riot.im) modifying my mic input
levels. Also Chrome / Chromium do the same thing during WebRTC calls, they
raise my mic level to 100%, thus completely saturating the audio and making
it unusable. I drop it back down manually, but within a few seconds it
creeps back up to 100% again. In Windows there's an option to not allow
programs to control a specific device. Is there any way to do this with ALSA
and/or PulseAudio? Thanks a lot.



--
Sent from: http://linux-audio.4202.n7.nabble.com/linux-audio-user-f5.html
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Len Ovens
On Tue, 5 May 2020, S. wrote:

> Hi there, recently I've been running into major problems with Electron apps
> for the Linux desktop (Microsoft Teams and Riot.im) modifying my mic input
> levels. Also Chrome / Chromium do the same thing during WebRTC calls, they
> raise my mic level to 100%, thus completely saturating the audio and making
> it unusable. I drop it back down manually, but within a few seconds it
> creeps back up to 100% again. In Windows there's an option to not allow
> programs to control a specific device. Is there any way to do this with ALSA
> and/or PulseAudio? Thanks a lot.

Use jack as the back end for pulse and unload the alsa and udev modules
from pulse. Pulse sees jack as the only sink/source and has no access to
alsa controls. Any level adjustments pulse can do from there on are dsp
level changes.

Thats what I know best because I run jack all the time anyway. however, I
think it should also be possible to change the device profile for your
device in pulse to use that directly. (that is break the profile :) ) on
my machine pulse hides its profiles in:
/usr/share/pulseaudio/alsa-mixer/profile-sets/
I do not konw how to set profiles up or really how they work. I am blessed
with an audio device that pulse finds confusing and leaves alone (ice1712
based).

--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
S.
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

S.

Thanks a lot for the reply.


Len Ovens wrote
> Use jack as the back end for pulse and unload the alsa and udev modules
> from pulse.

Hmm, that's an interesting idea, I hadn't thought about Jack. (I use it Jack
on another machine for music production, but not on my main workstation.)

So you seem to be suggesting that Pulse is directly responsible for
manipulating the levels? I assumed that it was Chromium and its spinoffs
(Chrome and Electron apps), using an AGC function specifically as part of
the WebRTC protocol:
https://stackoverflow.com/questions/37326846/disabling-auto-gain-conctrol-with-webrtc-app
Another reason I suspect Chromium+WebRTC as the culprit is because the same
WebRTC platforms that manipulate my audio with those browsers/frameworks do
*not* do so in Firefox. I would just use them in Firefox, except for
unfortunately I can't do that in the case of an Electron app, and even some
WebRTC platforms are created specifically for Chrome and don't work in
Firefox. :-(


> however, I think it should also be possible to change the device profile
> for your
> device in pulse to use that directly. (that is break the profile :) ) on
> my machine
> pulse hides its profiles in:
> /usr/share/pulseaudio/alsa-mixer/profile-sets/

Thanks for confirming this option, I had found a similar suggestion here:
https://askubuntu.com/questions/689209/how-to-disable-microphone-volume-auto-adjustment-in-cisco-webex/761103#761103
That looks like the solution I was hoping for of making it not possible for
processes to mess with the mic gain. But unfortunately the profiles are
under /usr/share/ , so the tweaks will be reverted every time Pulse is
updated... :-(




--
Sent from: http://linux-audio.4202.n7.nabble.com/linux-audio-user-f5.html
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Jacek Konieczny

On 06.05.2020 14:45, S. wrote:

> Len Ovens wrote
>> Use jack as the back end for pulse and unload the alsa and udev modules
>> from pulse.
>
> Hmm, that's an interesting idea, I hadn't thought about Jack. (I use it Jack
> on another machine for music production, but not on my main workstation.)
>
> So you seem to be suggesting that Pulse is directly responsible for
> manipulating the levels? I assumed that it was Chromium and its spinoffs
> (Chrome and Electron apps), using an AGC function specifically as part of
> the WebRTC protocol:

That is probably the source of the level change requests, but it is
PulseAudio that forwards this to the hardware (via ALSA drivers).

Without the direct hardware access PulseAudio can still fulfill the
request, but only by the digital signal manipulation which should be
less invasive.

I guess it might be possible to stop PA from using ALSA mixer controls
even without unloading ALSA support all together.

Jacek
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
S.
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

S.
Jacek Konieczny wrote
>> So you seem to be suggesting that Pulse is directly responsible for
>> manipulating the levels? I assumed that it was Chromium and its spinoffs
>> (Chrome and Electron apps), using an AGC function specifically as part of
>> the WebRTC protocol:
>
> That is probably the source of the level change requests, but it is
> PulseAudio that forwards this to the hardware (via ALSA drivers).

Ah OK, that makes sense.

> Without the direct hardware access PulseAudio can still fulfill the
> request, but only by the digital signal manipulation which should
> be less invasive.

So it looks like the core of the problem is that the only way to disable
PulseAudio's direct hardware access is via /usr/share/ . I wonder if I could
submit a bug/feature request for PulseAudio to optionally pull its profiles
from /etc/pulse/ ?

> I guess it might be possible to stop PA from using ALSA mixer controls
> even without unloading ALSA support all together.

This would be ideal. Any tips on how to do that?



--
Sent from: http://linux-audio.4202.n7.nabble.com/linux-audio-user-f5.html
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Len Ovens
In reply to this post by Jacek Konieczny
On Wed, 6 May 2020, Jacek Konieczny wrote:

> I guess it might be possible to stop PA from using ALSA mixer controls
> even without unloading ALSA support all together.

I am sure it is. In my case I have other reasons for making sure Pulse has
no access to ALSA. I have found that pulse will try to use any alsa device
it can find for sync and that this causes xruns when pulse is bridged to
jack as well as trouble when putting jack into freewheel. The pulse-jack
bridge is not properly buffered and works best if jack is the only
"device" pulse can see.

--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Len Ovens
In reply to this post by S.
On Wed, 6 May 2020, S. wrote:

> So you seem to be suggesting that Pulse is directly responsible for
> manipulating the levels? I assumed that it was Chromium and its spinoffs
> (Chrome and Electron apps), using an AGC function specifically as part of
> the WebRTC protocol:

Pulse poses as an alsa device to the application so that more than one
application can use the same device at the same time. So chrome controls
it's device which is pulse and pulse satisfies the request with either
direct device manipulation or digital if direct is not possible (or if
there is more than one application using that device).

> Thanks for confirming this option, I had found a similar suggestion here:
> https://askubuntu.com/questions/689209/how-to-disable-microphone-volume-auto-adjustment-in-cisco-webex/761103#761103
> That looks like the solution I was hoping for of making it not possible for
> processes to mess with the mic gain. But unfortunately the profiles are
> under /usr/share/ , so the tweaks will be reverted every time Pulse is
> updated... :-(

As with all things Linux these days, configuration can be done in more
than one place. While I am sure that an added profile file with a unique
name would not interfere with upgrades even in /usr/share, quite probably
the default profile could be overridden in /etc/pulse/*/ and failing that,
there is always ~/.local/share/ to play with. Really, it is all about
seaking documentation and examples to work from. If you only have one user
on the system, copying the file from:
/usr/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf
to:
~/.local/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf
and editing it there may be just as effective.

As before, I have not personally tried this as jack already fixes it for
me.

--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
S.
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

S.
Len Ovens wrote
> If you only have one user
> on the system, copying the file from:
> /usr/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf
> to:
> ~/.local/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf

Hmm that's in interesting idea, thanks. As of yet I don't have a
~/.local/share/pulseaudio directory, only ~/.config/pulse . I wasn't aware
that it would take override configs from ~/.local/share/* by just mirroring
the directory structure.

I'd also be interested in seeing your ALSA - JACK - PulseAudio bridge
configuration for my other audio workstation. I currently configure it with
Cadence, but I do indeed have occasional xruns, maybe something could be
optimized.



--
Sent from: http://linux-audio.4202.n7.nabble.com/linux-audio-user-f5.html
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Bill Purvis
In reply to this post by Len Ovens
On 06/05/2020 17:15, Len Ovens wrote:

> On Wed, 6 May 2020, S. wrote:
>
>> So you seem to be suggesting that Pulse is directly responsible for
>> manipulating the levels? I assumed that it was Chromium and its spinoffs
>> (Chrome and Electron apps), using an AGC function specifically as
>> part of
>> the WebRTC protocol:
>
> Pulse poses as an alsa device to the application so that more than one
> application can use the same device at the same time. So chrome
> controls it's device which is pulse and pulse satisfies the request
> with either direct device manipulation or digital if direct is not
> possible (or if there is more than one application using that device).
>
>> Thanks for confirming this option, I had found a similar suggestion
>> here:
>> https://askubuntu.com/questions/689209/how-to-disable-microphone-volume-auto-adjustment-in-cisco-webex/761103#761103 
>>
>> That looks like the solution I was hoping for of making it not
>> possible for
>> processes to mess with the mic gain. But unfortunately the profiles are
>> under /usr/share/ , so the tweaks will be reverted every time Pulse is
>> updated... :-(
>
> As with all things Linux these days, configuration can be done in more
> than one place. While I am sure that an added profile file with a
> unique name would not interfere with upgrades even in /usr/share,
> quite probably the default profile could be overridden in
> /etc/pulse/*/ and failing that, there is always ~/.local/share/ to
> play with. Really, it is all about seaking documentation and examples
> to work from. If you only have one user on the system, copying the
> file from:
> /usr/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf
> to:
> ~/.local/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf
> and editing it there may be just as effective.
>
> As before, I have not personally tried this as jack already fixes it
> for me.
>
> --
> Len Ovens
> www.ovenwerks.net
This thread prompted me to look at it. I tried

     pacmd set-default-sink jack_out

which does the trick, assuming you have the pulseaudio-jack module loaded.
Having got there, adding the command to the end of
/etc/pulseaudio/default.pa
should make it set that whenever it starts up. I've yet to try that as I
don't
reboot more often than necessary.

Bill

--
+----------------------------------------+
| Bill Purvis                            |
| email: [hidden email]                  |
+----------------------------------------+
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
S.
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

S.
Thanks @Bill for confirming. Did you do anything special first to set up
JACK?



--
Sent from: http://linux-audio.4202.n7.nabble.com/linux-audio-user-f5.html
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Len Ovens
In reply to this post by S.
On Wed, 6 May 2020, S. wrote:

> I'd also be interested in seeing your ALSA - JACK - PulseAudio bridge
> configuration for my other audio workstation. I currently configure it with
> Cadence, but I do indeed have occasional xruns, maybe something could be
> optimized.

I use ubuntustudio-controls (soon to be just studio-controls) which I
co-author. It is all python code and available at:
https://github.com/ovenwerks/studio-controls

--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Len Ovens
In reply to this post by Bill Purvis
On Wed, 6 May 2020, Bill Purvis wrote:

> This thread prompted me to look at it. I tried
>
>     pacmd set-default-sink jack_out
>
> which does the trick, assuming you have the pulseaudio-jack module loaded.

I do not know if you can test or not. What happens if you plug a USB audio
device while this is running? I have found in the past that default tends
to switch to the newly plugged in device on the assumption that if you
plugged it in you surely want to use it :)

> Having got there, adding the command to the end of
> /etc/pulseaudio/default.pa
> should make it set that whenever it starts up. I've yet to try that as I
> don't
> reboot more often than necessary.

This still leaves the effects access to another alsa device has on a
pulse-jack bridge. you may also wish to comment out:

-----------------8<----------------------
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev
support)
load-module module-detect
.endif
-----------------8<----------------------

Perhaps on a system with only one device this is not a problem, but most
mother boards now have at least two, internal and HDMI. Add a USB device
to that and the chance of pulse having two different deadlines to deal
with is higher...

--
Len Ovens
www.ovenwerks.net

_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Bill Purvis
In reply to this post by S.
On 06/05/2020 20:31, S. wrote:
> Thanks @Bill for confirming. Did you do anything special first to set up
> JACK?
I use Qjackctl to control Jack, and in the Setup->Options I put:
     pacmd set-default-sink jack_out
in the box labelled: 'Execute script on startup'.
So that's basically duplicating the effect.

I don't tend to do much plug-n-play, so I don't know what effect that
would have on the setup.
I do know that Jack seems to lock onto the device specified in
Setup->Settings->Advanced->Output Device
which is a bind on my laptop as most of the time I have it set to the
headphones socket, and it
doesn't switch to the internal speakers if I unplug it. I think ALSA
used to do that automatically.
I don't think much of the built-in speakers anyway and plug in a
mini-boombar if I'm away from
my desk.

Bill

--
+----------------------------------------+
| Bill Purvis                            |
| email: [hidden email]                  |
+----------------------------------------+
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
S.
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

S.
Bill Purvis wrote
> it doesn't switch to the internal speakers if I unplug it. I think ALSA
> used to do that automatically.

Possibly in `alsamixer`, then F6, select the card, and then make sure the
"Auto Mute" options are enabled?




--
Sent from: http://linux-audio.4202.n7.nabble.com/linux-audio-user-f5.html
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Bill Purvis
On 07/05/2020 13:59, S. wrote:
> Bill Purvis wrote
>> it doesn't switch to the internal speakers if I unplug it. I think ALSA
>> used to do that automatically.
> Possibly in `alsamixer`, then F6, select the card, and then make sure the
> "Auto Mute" options are enabled?
I don't rate that as automatic. I can't confirm but I think it used to do it
before I switched to Jack a good while back. Pull out the plug and the
speakers
take over and vice versa.

On the other hand I could be wrong...  ;-(

Bill

--
+----------------------------------------+
| Bill Purvis                            |
| email: [hidden email]                  |
+----------------------------------------+
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

Len Ovens
In reply to this post by Bill Purvis
On Thu, 7 May 2020, Bill Purvis wrote:

> which is a bind on my laptop as most of the time I have it set to the
> headphones socket, and it
> doesn't switch to the internal speakers if I unplug it. I think ALSA
> used to do that automatically.

No, ALSA does not do this, pulse does. So when jack takes the device,
pulse no longer deals with it. Most newer systems can be switched by
changing levels in ALSA. Some systems have pin switching that needs to be
done (as root) and yet other systems do the switching physically in the
plug. headphone plugin/out are not hard to detect, but knowing what to do
is system dependent even with alsa, while most systems use the "headphone"
label, it is a tossup if the speakers are "Speakers", "Front" or something
else.


--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent applications from changing my mic level?

hollundertee
In reply to this post by S.
On Wed, 6 May 2020 06:19:52 -0700 (MST)
"S." <[hidden email]> wrote:

> Jacek Konieczny wrote
>  [...]
>  [...]
>
> Ah OK, that makes sense.
>
>  [...]
>
> So it looks like the core of the problem is that the only way to
> disable PulseAudio's direct hardware access is via /usr/share/ . I
> wonder if I could submit a bug/feature request for PulseAudio to
> optionally pull its profiles from /etc/pulse/ ?
>
>  [...]
>
> This would be ideal. Any tips on how to do that?

This has been Pulse Audio behaviour for ages and seems to be directly
inspired by OSX, like most things these people do.
Years ago, when I tried to use Jitsi to stay in touch with someone,
this "feature" already caused me endless frustration as it made Jitsi
nigh unusable.

There may be a config option somewhere to prevent this. I think I
eventually found one that at least prevented PA to enable the extremely
noise inducing "mic boost" on the intel interface, but it may have been
a more general option. Of course that was not considered a bug in PA
but one in the ALSA drivers, following the motto that bugs are always
someone else's bugs. And yes, we lost contact, which frustrates me
until today.

I think this is the option that helped me. This is not the general PA
page on the Arch wiki, just the dedicated troubleshooting page.
https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Volume_gets_louder_every_time_a_new_application_is_started

Regards,
Philipp
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user