Software

index page

This is one of a series of pages detailing attempts to play Ambisonic sound on cheap everyday equipment. This is not the ideal way to do it, but it does allow for experimentation. The faltering steps reported here are offered as one person's experience not as suggestions of how anything should be done!!

1. Operating system

Linux.

There is a acreenshot of AmbDec, gmplayer and jack-patch-bay running (208KB).

2. jackd

Part of my distribution, but not installed by default.

This is obligatory to run ambdec (see below).

As a non-root user start jack:
jackd -d alsa
but if you have more than one sound card you will have to identify the card you want and tell jack (otherwise it starts with the default card). Card identification is discussed on the ganging page.

To start with my USB card I use:
jackd -d alsa -d hw:1
as long as I plugged it in after booting (see previous paragraph's link for explanation).

To start with both cards (the internal one and the USB one):
jackd -d alsa -P eight
with the configuration file that defines 'eight' described on the ganging page.

I do get very occassional clicks in playback due to "xrun"s.

  1. I should pay more attention to how to set up jackd …
  2. One advice (which does not seem to have had any effect, but which I have implemented) is to but the line:
    none /tmp/jack-500 tmpfs defaults 0 0
    into /etc/fstab (which will obviously only take effect if you then mount it, or if you reboot (and then automatically on each reboot)).
    The jack-500 I found by running jackd and then searching for what it was calling its temporary file folder -this may vary, so you may need to do the same.

3. jack-patch-bay

Now we can see what is going on.
jack-patch-bay

4. AmbDec

Fons Adriaensen's AmbDec is available from www.kokkinizita.net/linuxaudio/.

I found it best to create a very basic configuration using ambdec, to save that and then to go into it with a text editor and finish the configuration. So much of the configuration is repetitive and 'cutting and pasting' simplifies it.

5. mplayer

(Obviously only mplayer or aplay is needed, but as I am undecided about the pro's and con's both are listed.)

There probably is a sensible way of playing *.amb files, but -anyway- I found that mplayer will play WXYZ (periphonic) files but not WXY (pantophonic) files (you have to add a fourth dummy track to those, it is easy, and they work fine afterwards).

So:
gmplayer -ao jack:port=ambdec -vo null myfile.amb

Unfortunately … the four sound channels (0 to 3) are then routed by jackd to the first four ambdec channels, that is 'Test', '0w', '1x' and '1y'. My only solution, to date is to hit pause, disconnect the four connections and then re-jack '0' to '0', etc. I have to re-do this for each track I play, and is the major item to cure!!!

(If I modify the .asoundrc file as suggested below, one might think that gmplayer -ao alsa:device=amb would work. It doesn't.)

6. aplay

aplay's jacking can be controlled by the .asoundrc file, thus avoiding the re-jacking problem discussed above. However, trying to play a conformant *.amb file results in the message:
can't play not PCM-coded WAVE-files

Opening the conformant *.amb file with audacity and saving as a four channel wave file (with the suffix .amb if you wish) does give a playable file. The conversion is 'one off' (compared with re-jacking all the time, but does mean the file is not a standard ambisonic file, anymore).

To automate the jacking, add the following:

pcm.amb {
	type plug
	slave {pcm "ambslave"}
}

pcm.ambslave {
	type jack
	playback_ports {
		0 ambdec:in_0w
		1 ambdec:in_1x
		2 ambdec:in_1y
		3 ambdec:in_1z
	}
}
to the .asoundrc file (see ganging).

Then to use aplay, use:
aplay -D amb myfile.amb
with the device amb defined by the addition to the .asoundrc file.

I seem to get less xruns with aplay as well …

8. Qjackctl

Many thanks to Etienne Deleflie (of ambisonia.com) for suggesting I try qjackctl.

Superficially, this has all the same problems. It does allow you to save your settings and then re-load them. But is uses what it calls 'sockets' (that is applications) and then jacks what it calls 'plugs' (the individual channels of each application) according to its own wisdom (unless I missed something). So the results are the same. (Even correctly setting up the connections with jack-patch-bay and then saving them with qjackctl only saves the socket/application connections.

But … you can go into the XML file that qjackctl saves the settings in and 'trick' it by re-ordering the list of plugs. I changed from the left column values to the right (cutting and pasting the 'Test' line) and it works!

  <socket exclusive="off" client="ambdec" type="audio" name="ambdec" >
   <plug>Test</plug>
   <plug>in_0w</plug>
   <plug>in_1x</plug>
   <plug>in_1y</plug>
   <plug>in_1z</plug>
  </socket>
  <socket exclusive="off" client="ambdec" type="audio" name="ambdec" >
   <plug>in_0w</plug>
   <plug>in_1x</plug>
   <plug>in_1y</plug>
   <plug>in_1z</plug>
   <plug>Test</plug>
  </socket>

8. Bringing it together

It just remains to write a script that does:

jackd -d alsa -P eight
qjackctl
ambdec -c Amdec-config.ambdec
gmplayer

and I should have a nice easy player …

9. Screenshot

There is a acreenshot of AmbDec, gmplayer and jack-patch-bay running (208KB).

10. Testing

Obviously any file … but Aaron Heller's Eight Directions AJH_eight-positions.amb from Ambisonia provides a good test of correct speaker jacking/wiring (though it lacks 'height'). The file was uploaded 2007-05-30, so you will have to search back through the pages.(Or, just go to Aaron J. Heller's page.)


September 2007.

Copyright © 2007 Michael Chapman.
No rights claimed for .asoundrc code.