Updated July 2nd 2009: Now using Sebastian Pipping's bs2b LADSPA plug-in instead of tap-bs2b
After picking up some new headphones yesterday, I wondered whether there was any way to convert stereo audio to binaural audio. It took an hour of time but now I've got it working wonderfully, by feeding ALSA the LADSPA plug-in for
Bauer stereophonic-to-binaural.
Read on for my how-to.
If you wonder what this is actually doing: most sound recordings out there are delivered as stereo, which is meant to simulate a directionally accurate reproduction of the original sound source in front of the listener using two channels which each can be heard by both ears. When listening to it via headphones, which aren't a stereo but binaural listening arrangement, with seperate channels which each can be heard by only one ear, the directional positioning of the sound source seems to be the center of your head. This tends to be immensely irritating after some listening and especially with audio-supported visuals as in games or movies where the sound sources are seen in front of you but the sound seems to origin from totally different angles. You can read more about the problem on
Wikipedia and the
bs2b homepage.
Now to fix this on a non-per-program basis in Linux, we'll fiddle the bs2b LADSPA plug-in into ALSA. Keep in mind I'm not an ALSA expert - so maybe it won't work for you at all.
First you'll fetch, compile and install the bs2b LADSPA plug-in by Sebastian Pipping. You may have to install the LADSPA development package first using your distribution's package management. Then follow these instructions:
Go to
Sourceforge download page and download the LADSPA plug-in package.
$ cd folder_where_you_downloaded_the_package
$ tar xf ladspa-bs2b-VERSION.tar.X # the VERSION and X depend on the downloaded version and package type
$ cd ladspa-bs2b-VERSION
$ ./configure --prefix=/usr # Prefix may be different depending on your distribution but usually /usr is fine
$ make
$ su -c "make install"
Now edit your
/etc/asound.conf (for a system-wide configuration) or
~/.asoundrc (for user-only configuration):
pcm.headphonesplug {
type plug
slave.pcm "headphonesduplex"
}
pcm.headphonesduplex {
type asym
capture.pcm "hw:1,0"
playback.pcm "hw:1,0"
}
pcm.bs2b {
type ladspa
slave.pcm "headphonesplug"
path "/usr/lib/ladspa"
plugins [
{
label bs2b
input {
controls [ 700 4.5 ]
}
}
]
}
pcm.headphones {
type plug
slave {
pcm "bs2b"
rate 44100
}
}
The
controls [ 700 6 ] line sets the default values for the lowpass filter cut frequency (700 Hz) and the crossfeed level (4.5 dB). Possible values are 300-1000 for the lowpass filter cut frequency and 1 to 15 for the crossfeed level. The default for bs2b versions pre-3.0 was 500 Hz and 4.5 dB. Other "presets" can be found on the
bs2b homepage.
You'll have to replace hw:1,0 with the device your headphones sit on. You can find out which numbers to place behind the hw: by running
$ aplay -l
You can also use dmix and dsnoop:
dmix:CARD=1,RATE=44100 for playback.pcm and
dsnoop:CARD=1 for capture.pcm, where CARD= is the number or name of your sound card from the aforementioned command and RATE should be the same sample rate your music is stored in, so probably 44100.
When you're done, everything should be working. Try it out with a stereo wav file (shouldn't be hard to find) and do a
$ aplay -D headphones file.wav
to do a simple test. Then configure your other applications to use the
headphones ALSA device, or make it the default by adding
pcm.!default {
type plug
slave.pcm "headphones"
}
to your ALSA configuration.
If everything went fine, congratulations. If not, mail me or post a comment.
Monday, October 1. 2007 at 17:55 (Reply)
First I can't hear any difference with or without it.
Then it seems some things are missing in your config file:
...
slave.pcm "hw:1,0"
Monday, October 1. 2007 at 19:23 (Reply)
Tuesday, October 2. 2007 at 22:50 (Reply)
Tuesday, June 23. 2009 at 20:18 (Reply)
Debian "Lenny+" on an Intel DP35DP.
Tuesday, June 23. 2009 at 22:02 (Reply)
Wednesday, July 1. 2009 at 05:28 (Reply)
Saturday, January 9. 2010 at 22:38 (Reply)
I have debian lenny too and there was "tic-tic-tic..." instead of sound too. I moved some parts in .asoundrc file to up/down, added dmix 'slave.pcm "plug:dmix0"' (thanks to http://jeanbruenn.info/dokumente/equalized-system-using-alsa) and it works.
My .asoundrc is http://notsu.pri.ee/static/linux/a.asoundrc
Friday, June 26. 2009 at 03:15 (Link) (Reply)
I didn't realize you'd have to compile bs2b separately, but that's not too difficult. Then I compiled the ladspa plugin, and it seemed to go fine. There are some .o's sitting happily in the /usr/lib/ladspa folder.
I'm having trouble with getting output. .asoundrc is the alsa confic file? I've been trying to do this without logging out, so using
> alsa force-reload
after changing something.
When I use aplay -D headphones somefile.wav i get an error
> ALSA lib pcm.c:2205:(snd_pcm_open_noupdate) Unknown PCM bs2b
> aplay: main:590: audio open error: File exists
Any suggestions? Also at the top you said you've made changes July 2nd 2009, but that's still in the future.
Sunday, September 13. 2009 at 03:10 (Reply)
Thursday, September 24. 2009 at 14:21 (Link) (Reply)
Saturday, January 9. 2010 at 21:36 (Reply)
There are plugins for many players, first download is just lib and tools