element-call icon indicating copy to clipboard operation
element-call copied to clipboard

Configurable automatic gain control

Open ara4n opened this issue 3 years ago • 11 comments

We seem to be using WebRTC's defaults for AGC - we should probably either force it on via audioConstraints (https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/autoGainControl) and/or make it configurable.

ara4n avatar Mar 05 '22 18:03 ara4n

A checkbox to disable AGC would be particularly beneficial for podcast or production use, where mic gain is already carefully controlled and fluctuations would be detrimental.

foxlet avatar Mar 08 '22 20:03 foxlet

Also, the checkbox within Element Desktop that should disable AGC doesn't do anything when using Element Call in Element Desktop. https://github.com/element-hq/element-web/issues/24355

bblacher avatar Mar 11 '24 10:03 bblacher

For anyone who also can't use the call feature due to this unsolved issue (or with participants who regularly complain about their ears falling off), this is the workaround we're currently using:

Find out the correct number for your source with wpctl status. Then, when connecting to a call, execute while sleep 0.01; do wpctl set-volume 54 .25; done in a terminal (replace 54 with your source and .25 with the target volume, on a scale from 0.01 to 1.00). This will set the correct volume every 10 milliseconds.

natanox avatar Apr 08 '24 13:04 natanox

For anyone who also can't use the call feature due to this unsolved issue (or with participants who regularly complain about their ears falling off), this is the workaround we're currently using:

Find out the correct number for your source with wpctl status. Then, when connecting to a call, execute while sleep 0.01; do wpctl set-volume 54 .25; done in a terminal (replace 54 with your source and .25 with the target volume, on a scale from 0.01 to 1.00). This will set the correct volume every 10 milliseconds.

Well, it works but what an ugly workaround...

Me and all my contacts have this bug and nobody wanna use Element cause of it. Same on Linux and Windows.

perru avatar Apr 21 '24 09:04 perru

For anyone who also can't use the call feature due to this unsolved issue (or with participants who regularly complain about their ears falling off), this is the workaround we're currently using:

Find out the correct number for your source with wpctl status. Then, when connecting to a call, execute while sleep 0.01; do wpctl set-volume 54 .25; done in a terminal (replace 54 with your source and .25 with the target volume, on a scale from 0.01 to 1.00). This will set the correct volume every 10 milliseconds.

This probably also causes it to change all the time, meaning for some milliseconds, you are quieter/louder than you should be, which will sound very unprofessional

Ceiridge avatar Nov 04 '24 16:11 Ceiridge

This is just fixing an issue that shouldn't be there in the first place with a very sloppy workaround. I can't imagine that telling livekit not to do agc would be that hard.

bblacher avatar Nov 04 '24 16:11 bblacher

Any fix yet? This causes a friend of mine to be unable to play any other audio without muting his microphone entirely, or it immediately adjusts his gain to ridiculous levels to pick up the audio (and blows everyone else's ears out if he speaks after that.)

ParzivalWolfram avatar Jan 10 '25 04:01 ParzivalWolfram

@ParzivalWolfram

Any fix yet? This causes a friend of mine to be unable to play any other audio without muting his microphone entirely, or it immediately adjusts his gain to ridiculous levels to pick up the audio (and blows everyone else's ears out if he speaks after that.)

You can open the devtools in Element (Ctrl+Shift+I), use the element selector (Ctrl+Shift+C) to select an element inside the call iframe (important!!!) so that the javascript scope is inside the iframe, then run the Anti AGC JavaScript linked below and finally mute, unmute and temporarily select another microphone, then go back to the microphone you want to use. AGC is now disabled for this call.

Anti AGC: https://github.com/joeywatts/disable-autogain-control-extension/blob/master/disableAutogain.js

Ceiridge avatar Jan 10 '25 13:01 Ceiridge

That is far too much to explain to affected users, who will not not know what JavaScript is, or that Electron apps run in a browser. It was already a huge pain in the ass to get my group's affected user onto anything other than Discord at all.

On January 10, 2025 7:51:27 AM CST, Philipp Paul G @.***> wrote:

@ParzivalWolfram

Any fix yet? This causes a friend of mine to be unable to play any other audio without muting his microphone entirely, or it immediately adjusts his gain to ridiculous levels to pick up the audio (and blows everyone else's ears out if he speaks after that.)

You can open the devtools in Element (Ctrl+Shift+I), use the element selector to select an element inside the call iframe (important!!!) so that the javascript scope is inside the iframe, then run the Anti AGC JavaScript linked below and finally mute, unmute and temporarily select another microphone, then go back to the microphone you want to use. AGC is now disabled for this call.

Anti AGC: https://github.com/joeywatts/disable-autogain-control-extension/blob/master/disableAutogain.js

-- Reply to this email directly or view it on GitHub: https://github.com/element-hq/element-call/issues/248#issuecomment-2582757089 You are receiving this because you were mentioned.

Message ID: @.***>

ParzivalWolfram avatar Jan 10 '25 18:01 ParzivalWolfram

This is just fixing an issue that shouldn't be there in the first place with a very sloppy workaround. I can't imagine that telling livekit not to do agc would be that hard.

Agree, this should be more in focus to fix AGC and to make it configurable

Destinyg133 avatar Jan 12 '25 03:01 Destinyg133

Alright, I've found a workaround that's way cleaner, it only works when using pipewire and wireplumber though, maybe there are equivalent configuration options for pulseaudio that I don't know of.

~/.config/wireplumber/wireplumber.conf.d/99-stop-electron-microphone-auto-adjust.conf

access.rules = [
  {
    matches = [
      {
        application.process.binary = electron
      }
    ]
    actions = {
      update-props = {
        default_permissions = "rx"
      }
    }
  }
]

Followed by a restart of all relevant services:

systemctl --user restart wireplumber pipewire pipewire-pulse

Please note that this possibly also stops other electron apps from using agc.

Reference

bblacher avatar Jun 17 '25 07:06 bblacher

I just found something in a recent mr, this seems like it would be the way to turn off acg, if someone could wire this up to an option within ec, this issue would be solved.

https://github.com/element-hq/element-call/pull/3373/files#diff-e6a56839074725f7d4b9fc1475d6ac1b0794eddcd28db92ef01daf779e6548f0

bblacher avatar Jul 01 '25 08:07 bblacher

Why is this still an issue so many years later? The slider to turn the gain control off is still broken and in reality still does gain control, and the behaivour is not changed even if you exit a call or restart the client. So the option is just completely non-functional. Windows dont have a elegant way to fix this like pipewire, but either way the user shouldnt need to change settings on their system for this to work.

I would help if the instructions on setting this up locally wasnt so bad.

ghost avatar Nov 01 '25 14:11 ghost