Funking up Pulseaudio microphone use
Project description
[[TOC]]
Pamic - Funking up Pulseaudio microphone use
Overview
Pamic aims to simplify finessing microphone use with Pulseaudio.
There are two modes available:
-
Echo cancellation (combined with some level of noise suppression)
Echo cancellation mode is for when you need to use a microphone with ordinary speakers. For example, your system has speakers attached, you're not using headphones, your microphone is picking up the sound coming from the speakers and echoing it back out to everyone else on the conference call!
The Pulseaudio echo cancellation module can also perform noise suppression, and Pamic makes use of that when in echo cancellation mode. It's not quite as capable as the freestanding noise suppression, but it saves the overhead of using two separate modules.
-
Standalone noise suppression
Standalone noise suppression mode is for when you are using headphones, but your microphone is picking up unwanted background noise. In my case this is my laptop's fan, but it's also good for office hubbub, crowds, construction, planes, trains, automobiles...
This mode requires an extra library (librnnoise) to be installed. See below for details.
Pamic's changes are not persistent by default. Configure the autostart feature in the Preferences
dialogue if you want the changes to persist across reboots.
Installation
Run the following command:
pip3 install pamic
Depending on your Linux distribution, you may need to use pip
rather than pip3
. (python3 -m pip install pamic
or python -m pip install pamic
are also options here.)
Echo cancellation is performed by a standard Pulseaudio module, so if you're running the latest version of Pulseaudio that should be covered.
Note: I've only tested Pamic on Pulseaudio version 13.0. If you're using a different version, please let me know how it goes.
Installing librnnoise
This is only necessary for standalone noise supression - i.e when you're using headphones rather than speakers.
For standalone noise suppression Pamic makes use of the marvellous https://github.com/werman/noise-suppression-for-voice
Download the latest linux_rnnoise_bin_x64.tar.gz
tarball from https://github.com/werman/noise-suppression-for-voice/releases/
Extract librnnoise_ladspa.so
and place it in /usr/local/lib/
:
tar xf ~/Downloads/linux_rnnoise_bin_x64.tar.gz bin/ladspa/librnnoise_ladspa.so
sudo mv librnnoise_ladspa.so /usr/local/lib/
Using Pamic
-
Launch Pamic's GUI. At a terminal run:
pamicg
Note: Pamic is made up of two components, the GUI
pamicg
, and the scriptpamic
. (For more information on the script see README_SCRIPT.md.) -
Select which mode you wish to use:
Echo Cancellation
orNoise Suppression
. (The latter is only available iflibrnnoise
is installed. See above.) -
Now select the devices you want to use from the drop down box(es). In
Echo Cancellation
mode select the source (microphone) and sink (sound output device). InNoise Suppression
mode you can only select a source (microphone). -
And finally, click the
Apply
button.
All being well, that should be it. Pamic should be working. See Troubleshooting if not.
See also Configuring individual applications below.
Unloading Pamic
Once loaded a Pamic configuration will remain active until Pulseaudio is told to unload the modules, or is stopped.
To unload an active configuration, click on the down arrow to the right of the Apply
button and select Unload
.
Configuring Pamic
Pamic has the following configuration options available in the Preferences
dialogue:
-
Force unload if already active
If this box is ticked, Pamic will unload any existing configuration before applying the new one. If the box is not ticked, Pamic will not apply the new configuration if there is one already loaded.
This is on by default.
-
Display monitor devices
In most instances the Pulseaudio monitor devices will not be of interest, so they are not displayed unless this box is ticked. Which it isn't by default.
-
Display device names
The human readable device descriptions are always displayed.
In most instances the Pulseaudio device names will not be of interest, so they are not displayed unless this box is ticked. Which it isn't by default.
-
Autostart
The following tasks can be automatically started when you login:
-
Pamic
Reinstate the last applied Pamic configuration
-
Pamic GUI
Start the Pamic GUI
These two are independent options, you can have one, the other, both, or neither.
-
Configuring individual applications
Once Pamic has configured its new virtual devices, any freshly started applications should use pamic virtual speaker as their sound output device.
You may still need to change the routing for applications which are already connected to a different output device, or for applications which have been configured to use a specific output.
I usually use pavucontrol to control which app uses what output. If you're using Pulseaudio, pavucontrol (or something similar) is probably already installed.
Using Pamic with PulseEffects
PulseEffects makes it a simple matter to extensively tweak the sound coming through PulseAudio.
Install it via your usual package management tool (e.g. sudo apt install pulseeffects
).
I use PulseEffects to boost bass, add some audio excitation, and fettle the stereo image.
The gotcha here is that Pamic's Echo-Cancel Sink Stream must be blacklisted, otherwise Pulseaudio will detect a loop and there'll be only silence.
- In PulseEffects's main tab...
- select Applications...
- find the Echo-Cancel Sink Stream item and...
- click its Blacklist button.
- Restart PulseEffects
(Pamic and PulseEffects must both be running of course.)
[This image is of PulseEffects 4.8.0, using some GTK theme or other, and displayed in AwesomeWM. YMWV😄]
Troubleshooting
Pulseaudio issues
Pulseaudio can get its knickers in a twist. My setup is more complicated than the average in that my sound output device is a remote connexion to Pulseaudio running on a different computer, but I find that restarting Pulseaudio and any streams using it, usually solves most problems.
I do this by running:
pkill pulseaudio
Pulseaudio automatically restarts.
The most common exception to this resolving a problem for me has been when Pulseaudio chooses to alternate between the two physical outputs on a device after Pulseaudio and the device have been restarted. I click Pamic's Refresh
button, select the new device, click Apply
, and I'm back up and running. (I should probably try to force one or other of the physical outputs to always be used, but it only happens infrequently.)
Autostart not working
If like me you're using a window manager that doesn't handle the common autostart mechanism, you can do the following. After making changes in Preferences
you can see how Pamic has configured the autostart file, and use that as a model in whatever mechanism you do have access to. Run:
sed -n 's/^Exec=\(.\+\)/\1/p' ~/.config/autostart/pamic.desktop
AOB
I'm expecting other problems to surface once Pamic is running on different Pulseaudio configurations. Please submit any issues, and if you have solutions, please post them too :)
Suggestions/problems/solutions?
Please open an issue.
Ingredients not already mentioned
Microphone icon from free-icon-download.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pamic-0.2.2.tar.gz
.
File metadata
- Download URL: pamic-0.2.2.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10dbf2d519dfee15f61f8ba3159594b5d555497382ab46b8356489da540d2100 |
|
MD5 | 240227f6e352c06a6ccae50367151705 |
|
BLAKE2b-256 | 979d25b95c4900fc35a2d2c2f137ee2ac160236f48520e43a5dc0be8b4abfd89 |
File details
Details for the file pamic-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: pamic-0.2.2-py3-none-any.whl
- Upload date:
- Size: 65.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 650f5235fc2b01a4c240d50146a1a50646c938854ced1462c8c502b2c855a72b |
|
MD5 | 038db6e96224ebc480b3a0f836f996f0 |
|
BLAKE2b-256 | 62e0a6345667929b7ce6b818d43ab7aeb0b5ef18642f62c35c8e61a3e2e3ff02 |