Monday, July 24, 2017

Spatial Audio: ALSA Virtual Devices Using LADSPA


Spatial Audio: ALSA Virtual Devices Using LADSPA

1 Overview

I have long wanted to apply HRTF filters to soundscapes on the
Emacspeak Audio Desktop to produce effects that are better
spatialized. I just got this working over the weekend using LADSPA
Plugin ZamHeadX2-ladspa.so from package zam-plugins.


2 Getting ZAM Plugins

git clone https://github.com/zamaudio/zam-plugins.git 

And follow the instructions in the README file.


Next, do

sudo make install

to install the plugins.


Finally, make sure that the install location is on your LADSPA path.


2.1 Adding HRTF Virtual Devices Via ASOUNDRC

After updating Emacspeak from GitHub,
open file servers/linux-outloud/asoundrc
and copy the section marked HRTF to your personal .asoundrc
this defines a number of virtual devices that use the newly installed
LADSPA plugin.
Beware: Back-up your .asoundrc first and make sure you can restore
it even if you lose speech.


3 Spatialized Soundscapes

In a running Emacspeak session, invoke command

soundscape-restart

with an interactive prefix arg and specify one of the available
devices using standard Emacs completion.


For use with Soundscapes, I recommend one of the devices that place
sound directly in front of the listener (azimuth 0) but with a non-0
elevation.


The HRTF devices are named with prefix tts because I would like to
use these with software TTS; but for now the result with TTS is not
as good as it is with Soundscapes.


Notice that command soundscape-restart offers a number of virtual
ALSA devices based on your .asoundrc; see the next section for a
summary.

4 Virtual ALSA Devices For Use As A Soundscape Filter

Here is a list of available LADSPA devices in my setup that can be
used to add additional effects to Soundscapes:


  • crossfeed: Apply a BS2B filter.
  • default: No filters, vanilla audio.
  • tap-reverb: Reverb filter from package tap-plugins.
  • reverb-crossfeed: Reverb filter followed by BS2B.
  • tts-a0-e15: HRTF at (0, 15).
  • tts-a0-e30: HRTF at (0, 30).
  • tts-a0-e60: HRTF at (0, 60).
  • tts-a0-e90: HRTF at (0, 90).
  • tts-a0-em15: HRTF at (0, -15).
  • tts-a0-em30: HRTF at (0, -30).
  • tts-a0-em45: HRTF at (0, -45).
  • tts-a135-e45: HRTF at (135, 45).
  • tts-a135-em45: HRTF at (135, -45).
  • tts-a225-e45: HRTF at (225, 45).
  • tts-a225-em45: HRTF at (225, -45).
  • tts-a45-e45: HRTF at (45, 45).
  • tts-a45-em45: HRTF at (45, -45).
  • tts-am45-e45: HRTF at (-45, 45).
  • tts-am45-em45: HRTF at (-45, -45).

5 Other Uses Of HRTF Devices

You can experiment with these devices using aplay e.g.:

aplay -Dtts_a0_e0 filename.wav

You can also apply the HRTF Ladspa plugin from within MPlayer when
using emacspeak.
To try this, use C-e ; f and pick the Zam effect when prompted.
Invoke that command with an interactive prefix arg — C-u C-e ; f
— to edit the params passed to the Zam filter.


HRTF filters when playing media are mostly useful to position a
radio station in 3d space when playing more than one station
simultaneously.