Augmented Headphone Listening On Linux For The Emacspeak Audio Desktop
1 Executive Summary
A combination of ALSA, Ladspa and OpenAL can provide an enhanced
headphone listening experience on Linux — this article summarizes
various tools and techniques for leveraging these affordances on the
Emacspeak Audio Desktop.
2 Glossary
- ALSA
- Advanced Linux Sound Architecture. This is my prefered means of controlling audio, and I entirely avoid Pulseaudio on all my machines.
- Ladspa
- Linux Audio Developer's Simple Plugin API. Enables the injection of Digital Signal Processing (DSP) when playing media. It is a layer that sits above ALSA. Ladspa filters can be used by user-space applications like MPlayer and SoX when playing media. They can also be used within the user's ASoundRC to define virtual audio devices that inject DSP plugins into the media stream.
- OpenAL
- OpenAL is an API for enabling cross-platform 3D audio. User-space applications like MPlayer can use OpenAL as the audio output driver — note that OpenAL on Linux writes to ALSA under the covers.
3 Playing Media Using MPlayer
- With Ladspa and its associated plugins installed — at the minimum
I would recommend installingtap-plugins
, module
emacspeak-m-player
provides a number of affordances for
interactively applying Ladspa filters. See commands
emacspeak-m-player-apply-reverb-preset_(bound to _P inM-Player
)
and command emacspeak-m-player-add-filter (bound to f in
M-Player
). - Command emacspeak-m-player-apply-reverb-preset lets you pick
among a total of 42 reverb presets defined by Ladspa moduletap_reverb
. - Command emacspeak-m-player-add-filter lets you add some of the
more commonly used Ladspa effects with smart minibuffer
prompts. Use tab completion to discover some of the predefined
filters — these are just convenience shortcuts — and you can
add any filters you use commonly to this list. - Note that
mplayer
also has its own
HRTF filter, but that filter requires that the stream being played is
a 48K stream. - Command emacspeak-m-player-using-openal bound by default to
Hyper ; launchesmplayer
with OpenAL as the audio output
driver — adding the following line
to your _~/.alsoftrc~ file will apply a suitable HRTF filter for
augmented headphone listening.
hrtf=true
4 Defining Virtual Audio Devices For Use With Soundscapes
I use soundscapes to provide a pleasant auditory background as I work
— see earlier blog article that describes Soundscapes On The
Emacspeak Audio Desktop. Defining virtual ALSA devices that inject
Ladspa plugins into the output processing chain is an elegant means
for enhancing the auditory experience provided by these
soundscapes. In this instance, I apply one of the predefined reverb
effects (Ambiance) from Ladspa module tap-plugins
and pass the
results through a BS2B (Bauer Stereo To Binaural) filter — see file
scapes/ladspa-asoundrc in the emacspeak Github Repo. Notice that that
file defines a number of virtual audio devices and can serve as a
template for injecting any installed Ladspa plugins — you can first
experiment with filters using Emacspeak's Laudible module to find
settings that work for you before applying them via a virtual device
defined in your asoundrc
file. Finally, you can customize option
soundscape-manager-options
to add –device <devicename> to have
the soundscapes use the desired virtual device.
5 Summary
Laptops today have plenty of processing power and some really nice
audio hardware. Linux has a powerful audio processing stack in ALSA,
Ladspa and OpenAL. Connecting the dots can be fun and provide an
enhanced auditory environment.