pHAT DAC - mixing stereo to mono (mpd/alsa)?

Hi,

I’ve seen this other topic, but that didn’t seem to work for me.

Set-up:

  • Raspberry Pi Zero W (Jessie 4.9)
  • pHAT DAC (Pimoroni standard install)

I’m just streaming a single internet radio channel using mpd (and mpc directly in the command line) and that works fine for stereo. However I’m going to build this into an old radio with a single speaker, so I’d like to mix the stereo to mono. And I’d prefer to do it in software rather than hardware, just to be elegant… :)

I tried changing /etc/asound.conf to the following (as described in this post):

pcm.card0 {
  type hw
  card 0
}

ctl.card0 {
  type hw
  card 0
}

pcm.monocard {
  slave.pcm card0
  slave.channels 2
  type route
  ttable {
    # Copy both input channels to output channel 0 (Left).
    0.0 0.5
    1.0 0.5
    # Send nothing to output channel 1 (Right).
    0.1 0
    1.1 0
  }
}

ctl.monocard {
  type hw
  card 0
}

pcm.!default monocard
ctl.!default monocard

But after a reboot I get no audio at all and the mpc and mpc stop commands are met with "ERROR: Failed to open audio output".

The only /etc/asound.conf that produces audio for me is the Pimoroni pHAT DAC standard one of…

pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}

…which doesn’t do any stereo->mono mixing.

Any ideas?

Hmm, interesting. What do you see if you run:

asound -L
asound -l
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0

…and…

aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=sndrpihifiberry
    snd_rpi_hifiberry_dac, 
    Default Audio Device
dmix:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Hardware device with all software conversions

I was just assuming you need aplay output, not asound… Does everything look ok here?

Oh yes, I did. D’oh!

I expected to see a “monocard” output, I wonder if there’s something up with the asound.conf that I can’t spot. I’ll see if I can rig up a test for this tomorrow if I remember!

You’re probably far from the only person who’s likely to want to downmix to mono.

Ah, ok, my turn to d’oh: the above aplay output is using the standard Pimoroni asound.conf. When using the stereo mono mixing one, I get this output:

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0

…and…

aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
monocard
sysdefault:CARD=sndrpihifiberry
    snd_rpi_hifiberry_dac, 
    Default Audio Device
dmix:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0
    snd_rpi_hifiberry_dac, 
    Hardware device with all software conversions

And… guess what? Today that same file works! I get audio and ok level just on left channel, so I assume the asound.conf is doing its job correctly!

Dunno why that didn’t work before, maybe a copy and paste error, anyway, works now. Thanks for your help anyway :)

1 Like

Excellent! Glad you’re up and running.

1 Like