stuartlangridge / hushboard

Mute your mic while you're typing. An app for Ubuntu.
https://kryogenix.org/code/hushboard/
MIT License
146 stars 12 forks source link

Fails to mute microphone (when there are multiple mics) #6

Closed alexmurray closed 3 years ago

alexmurray commented 3 years ago
$ snap info hushboard
name:      hushboard
summary:   Mute your microphone while you’re typing
publisher: Stuart Langridge (sil)
store-url: https://snapcraft.io/hushboard
contact:   https://kryogenix.org/
license:   unset
description: |
  Never listen to the thundering sounds of someone typing on a video call
  ever again!

  Well, nobody who talks to _you_ will have to listen to it. If you don’t
  want to listen to it either, encourage your friends and colleagues to
  install Hushboard. While you’re typing, your mic is muted. When you stop,
  it unmutes again. That’s it.
commands:
  - hushboard
snap-id:      FutbZuCUuNqaZgM0opJeyicf9ghfpMwM
tracking:     latest/edge
refresh-date: today at 11:18 ACDT
channels:
  latest/stable:    0+git.fe18d39 2021-01-07  (6) 184kB -
  latest/candidate: ↑                                   
  latest/beta:      ↑                                   
  latest/edge:      0+git.e195307 2021-01-07 (13) 184kB -
installed:          0+git.e195307            (13) 184kB -
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.10
Release:    20.10
Codename:   groovy
$ snap connections hushboard
Interface                 Plug                       Slot                             Notes
audio-playback            hushboard:audio-playback   :audio-playback                  -
content[gnome-3-34-1804]  hushboard:gnome-3-34-1804  gnome-3-34-1804:gnome-3-34-1804  -
content[gtk-3-themes]     hushboard:gtk-3-themes     gtk-common-themes:gtk-3-themes   -
content[icon-themes]      hushboard:icon-themes      gtk-common-themes:icon-themes    -
content[sound-themes]     hushboard:sound-themes     gtk-common-themes:sound-themes   -
desktop                   hushboard:desktop          :desktop                         -
desktop-legacy            hushboard:desktop-legacy   :desktop-legacy                  -
gsettings                 hushboard:gsettings        :gsettings                       -
opengl                    hushboard:opengl           :opengl                          -
wayland                   hushboard:wayland          :wayland                         -
x11                       hushboard:x11              :x11                             -

See the attached video - let me know if I can help debug further...

https://user-images.githubusercontent.com/56540/103961132-c0237380-51a3-11eb-8a6c-b1aecb0cdb4f.mp4

stuartlangridge commented 3 years ago

Apologies for that. The first thing to check is: is hushboard muting the correct microphone?

If you refresh to the latest edge version (0+git.b108be2) and then run it from a terminal as hushboard --verbose then it should tell you on stdout what it's muting and unmuting every time you press a key.

If that's the incorrect mic, then there's our problem. We attempt to identify the active mic; perhaps we're doing it wrong.

If it's the correct mic but it doesn't seem to be actually muting it even though hushboard thinks it is, then the next thing to try is to see whether hushboard is actually muting it. You can see this with pavucontrol; as hushboard mutes and unmutes a mic, you should see that reflected in pavucontrol (and you can see that in https://www.youtube.com/watch?v=icXB7j8zUQg).

If hushboard thinks it's muting the mic but pavucontrol doesn't think it is, then we're doing something wrong when actually muting it; if that's the case, I'm a bit puzzled (muting isn't hard!) but we can drill into it.

If the mic is being muted according to pavucontrol but it's not muting in audacity, then it's possible that audacity is configured to bypass pulseaudio and use ALSA directly, which would be annoying on audacity's part; you can doubtless test that, or try some other application which does use pulse as it should as part of the desktop to see if that's maybe the issue.

If you could give those things a try and report back, that would be useful. Apologies again, and thank you for trying hushboard!

nsg commented 3 years ago

I have the same problem, and I get this ... I have plenty of microphones :)

nsg@glamdring ~ $ hushboard --verbose
Gtk-Message: 02:12:09.277: Failed to load module "canberra-gtk-module"
There is more than one active microphone so I don't know which one to unmute
There is more than one active microphone so I don't know which one to unmute
stuartlangridge commented 3 years ago

@nsg thank you! Hm. So... I don't know what to do in that situation (and I don't have multiple active microphones, so I've never experienced this). What should hushboard do here? Mute all the active mics?

nsg commented 3 years ago

What should hushboard do here? Mute all the active mics?

That's a good question. For me, that would work. But I'm unsure if that's a good default ... hm. Maybe configurable?

stuartlangridge commented 3 years ago

I don't want to make it configurable; hushboard is deliberately and intentionally simple, because it's meant to do one thing. If people have to fiddle with configuration then it's a Terrible Linux Tool :-)

I will make it mute all the active microphones and we'll see if anyone dislikes that :-) New build coming shortly...

alexmurray commented 3 years ago

With the new build, I also see -There is more than one active microphone so I don't know which one to unmute - I agree, mute all microphones makes the most sense if we don't know which is the active one. :+1:

stuartlangridge commented 3 years ago

OK, version 0+git.3374c8f should be in the snap edge channel; give that a try and see if it works. It mutes (and unmutes) all active mics.

@nsg I too do not understand this :) If muting everything works but there's a cleverer way to only identify the mic that's actually being used then I'm happy to do that -- we'll see whether this version works first, and if it's enough to tide things over then that will help!

nsg commented 3 years ago

Mute works :)

For me this is completely fine and solves my problem, and this is probably the sane default anyway.

stuartlangridge commented 3 years ago

Excellent! If that works for @alexmurray too then I'll close this, and if anyone has a better suggestion of how to deal with PulseAudio and multiple mics then I'm happy to listen.

alexmurray commented 3 years ago

@stuartlangridge I did some basic testing - looks like we can get which sources are running (and hence the active mic) with something like:

active_sources = [s for s in self.pulse.source_list() if s.state == pulsectl.PulseStateEnum['running']]

So if you want to go back to only muting / unmuting the active mic, then I think this could work. However, I suspect if pulseaudio support multiple running mics you would still want the current logic to mute all 'running' ones, not just active, so perhaps a combination of the two would be the best approach?

stuartlangridge commented 3 years ago

OK. I have promoted this version to stable, which mutes all active mics. Thank you both for testing. Clearly I need to better understand the difference between active and running and possibly other states in order for hushboard to Do The Right Thing here; @alexmurray I suspect you're right here and that I want to find things which are both active and running, but I'd like to check out what all that means before doing it, and "mute all active mics" seems to be a material improvement over the current state at least! I'll leave this issue open for now to track that need.

alexmurray commented 3 years ago

Ok no worries - I sent a PR just in case you still want to go down that route - thanks again for this excellent tool - it is very neat.

dustinkrysak commented 3 years ago

Just a heads up, I have an install where I had used the Ubuntu Studio installer to setup Jack, etc. It seems to suffer from this (it states there are no microphones even though I can record audio without issue).

I am intentionally being vague as I am going to roll back to default and see if that fixes it. Then it may help give you some context and a heads up that jack might be an issue.

I will report back

denysvitali commented 3 years ago

Not sure if it's the same error, but in my case it only seems to work on certain applications (Wayland vs Xorg). We should probably adapt the software a little to get the keystrokes from both environments.

To reproduce the issue, you can use my setup:

Then open an alacritty terminal (wayland) and the Firefox browser. Start to type on the terminal and then try on Firefox. Result: keystrokes on Alacritty (Wayland) are not detected, thus the microphone is not muted. Keystrokes on Firefox (Xorg) are detected and the microphone is correctly muted.

stuartlangridge commented 3 years ago

@denysvitali I've moved that discussion over to https://github.com/stuartlangridge/hushboard/issues/13.

stuartlangridge commented 3 years ago

@dustinkrysak do file a new issue with Jack problems when you have them, certainly!

stuartlangridge commented 3 years ago

Closing this issue as being about multiple mics only, which should now be fixed.