Audio in Linux becomes annoying again
January 11, 2015 1 Comment
At the moment I seem to be having more audio problems than usual. Last month I blogged about having to fix the ALSA Speaker volume level resetting to zero at boot, and recently two other audio problems have cropped up.
I have been having trouble with Thunderbird’s ‘system sound’ that announces the arrival of a new e-mail. Lately, Thunderbird has started playing too loud and with significant distortion the audio clip it had been playing perfectly for the last four years. This is especially strange because I created that audio clip with Audacity from another audio clip that sounded too loud when Thunderbird played it. Ironically, the work-around for this latest problem was to switch to the original, much louder sound clip
alert.wav instead of the quieter
alert_quiet.wav. Not only does Thunderbird now play
alert.wav at a lower volume than
alert_quiet.wav, but the sound of
alert.wav is not distorted when Thunderbird plays it. Yet if I play
alert_quiet.wav using SMPlayer, the former is much louder than the latter and neither is distorted. Figure that one out.
The event notification sound that Thunderbird uses to remind me about an impending meeting scheduled in the calendar has now started sounding very distorted too. I still have not found a work-around for that. Event sounds played by the desktop environment I use (KDE) are not distorted, so what is Thunderbird doing? Perhaps the problem is not Thunderbird itself but the audio library it uses, so I need to investigate further.
Yet another audio problem cropped up this morning when I connected my laptop to an external monitor and keyboard (and thus I left the laptop’s lid almost closed) in an open-plan office and booted the laptop. I entered my username and password on the KDM log-in screen, and the KDE splash screen appeared as usual. After a few seconds the laptop’s speakers suddenly emitted a piercing, continuous howl; the well-known sound of audio feedback from speakers to microphone. It was LOUD. The volume control buttons on the keyboard made no difference, and the sound was so loud that everyone in the office noticed and several people came over to tell me to reset the BIOS (apparently that had fixed the problem for their laptops running Windows).
I kept my finger on the laptop’s power switch and, after several seconds, the laptop powered off. My laptop dual boots Windows 7 and Gentoo Linux, and the audio feedback did not occur when I booted Windows 7. After booting Linux again a couple of times and annoying everyone in the office even more, I discovered I could open the laptop’s lid far enough back to reduce the feedback to a low whine, so I could let KDE finish launching and display the Desktop. I then launched ALSAMixer and discovered that ‘Internal Mic Boost’ was set to 100%. So I immediately lowered it to zero. Then the penny dropped: I had used Skype the previous night without bothering to connect my headphones and external microphone, and Skype had automatically raised ‘Internal Mic Boost’ all the way up to 100%. So I immediately launched Skype, selected ‘Options’ > ‘Sound Devices’ and unticked ‘Allow Skype to automatically adjust my mixer levels’. The next thing I did was add the following lines to the script
/etc/local.d/20set_alsa_volume.start mentioned in my previous blog post Fix for ALSA Speaker volume level resetting to zero at boot:
su -c "amixer -c 0 -- sset 'Internal Mic Boost' 0%" -s /bin/sh fitzcarraldo su -c "amixer -c 0 -- sset 'Internal Mic' 0%" -s /bin/sh fitzcarraldo su -c "amixer -c 0 -- sset 'Mic Boost' 0%" -s /bin/sh fitzcarraldo su -c "amixer -c 0 -- sset 'Mic' 0%" -s /bin/sh fitzcarraldo
From now on, only I am allowed to adjust microphone settings! To avoid any possibility of feedback loops in future, the above-mentioned script sets all the microphone channels to zero and I will have to adjust them myself before use. I already have ALSAMixerGUI in the KDE Launcher menu, so it won’t be a big deal to do that.
This fiasco with Skype got me thinking: if Skype is set to automatically adjust mixer levels when you are in a conversation, when you exit Skype why doesn’t it automatically set mixer levels back to the way they were when Skype was launched? It could be done easily and would be more user-friendly than the current way Skype works.
Interrelationship between PulseAudio and ALSA
The final thing I did (yet again) was to adjust all the various ALSA channels and PulseAudio channels to try and get the resulting audio input and output sounding reasonable. This is easier said than done. I often have to mess around with ALSAMixer and PulseAudio Volume Control in order to get audio input and output working satisfactorily in all applications that use audio. It is actually more difficult than it sounds (ouch!) to get ALSA and PulseAudio ‘balanced’ (for want of a better word). In the days before PulseAudio existed, one only had to adjust ALSA. Now, with two agents controlling audio, the task turns out to be surprisingly awkward sometimes.
To sum up, boo to Thunderbird (or whatever it uses to play sounds), boo to Skype and boo to PulseAudio. I’m fed up with audio issues in Linux at the moment. 😡
Update (January 19, 2015): It turns out that the problem in Thunderbird was due to PulseAudio. See my next post for details of how I fixed it.