Dual Mono setup


Dual Mono setup

The HiFiBerry sound cards are stereo sound cards. However, there are cases where you just want a Mono output, or even 2 independent mono outputs. Think about streaming music to your bathroom. Do you really need a stereo speakers there?

The easiest way would be to connect just one output. That works out-of-the box, but with sources that aren’t mono, you will miss something. Therefore, you need to make sure that both original channels (left and right) will be mixed together into the left channel.

Luckily ALSA already provides what is needed using so-called channel maps. Channel maps allow you to mix and map input and output channels.

Note: This guide comes “as-is”. It might not work on specific distributions without changes. There is no individual support from us for it. Feel free to post in our forum if you have questions.

Just create an /etc/asound.conf file like this:

pcm.hifiberry { 
 type hw card 0 

pcm.!default { 
 type plug 
 slave.pcm "dmixer" 
 ttable.0.0 1;
 ttable.1.1 0;
 ttable.0.1 0;
 ttable.1.0 1;

pcm.dmixer { 
 type dmix 
 ipc_key 1024 
 slave { 
  pcm "hifiberry" 
  channels 2 

ctl.dmixer { 
 type hw 
 card 0 

If you now play some music, you should hear it coming out only from the left output.

Let’s just use sox for a simple example:

play -n synth sine 1000

The 1kHz test tone will be played only on the left channel now.

Note that some applications might ignore /etc/asound.conf and will connect directly to the hardware device. Check the manual page of the application how the output device can be configured.

You now have one unused output. Why not use it as an independent sound card for another application? This is also easy to do. Just add the following:

pcm.card2 {
 type plug
 slave.pcm "dmixer"
 ttable.0.0 0;
 ttable.1.1 1;
 ttable.0.1 1;
 ttable.1.0 0;

Now you definitely need to make sure the second application used the sound card named “card2”. For our simple example here we use sox. sox expect the sound card name in an environment variable:

AUDIODEV=card2 play -n synth sine 500

We now have an 1kHz sine output on the left channel (from the command above) and another 500Hz sine on the right channel.
In an real-life application, you won’t use sox to play sine tones, but it’s usually a good way to check if everything is working fine before starting to configure your specific applications. Running 2 independent shairports or mpds should be easy now.

You might even think about having 2 independent Spotify connect clients running. While in general this is possible, there is one major drawback! For licensing reasons, there can be only one active stream per user. So if you want to have two independent Spotify clients, you also need two Spotify accounts.

Last updated: April 17, 2020