2

OK, so on Raspbian 9, on Raspberry Pi 3, if I try to list audio devices, I get this:

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]

You can notice that card 0: device 0: bcm2835 ALSA has 7 subdevices.

I had always thought that a subdevice corresponds to a "channel" in multichannel soundcards; but as far as I know, the Raspberry Pi 3 does not have separate outputs for 7 audio channels (or at least, they do not advertise it).

So why are there 7 subdevices in card 0: device 0? What is their purpose?

0

Edit:

These subdevices indicate that the hardware is capable of hardware mixing of the outputs. You can use them independently but the audio will be then mixed to the single analog output (in case of Raspi MONO).

Note: If you need better audio you have to use either (1) HDMI embedded audio (card0,device1 - IEC958) or (2) I2S with some of various DACs HATs (see Confirming the I2S pins on Raspberry Pi 3 model B? for pinout) or eventually (3) USB Sound card.

In practice it means that you can run:

aplay -vvv /usr/share/sounds/alsa/Front_Center.wav -D sd1

simultaneously with:

aplay -vvv /usr/share/sounds/alsa/Front_Center.wav -D sd2

It is actually an alternative to dmix (software based sound output mixing). The same should be achievable on SW level by (thanx to @perex=alsaman):

Edit(dmix):

pcm.dmixmono {
  type dmix
  ipc_key 5678293
  ipc_perm 0600
  slave {
    pcm {
      type hw
      card 0
    }
    format S16_LE
    rate 48000
    channels 1
  }
}

I have used this setup for multiple instances of mpd that let's me play multiple sounds simultaneously. Or you can play music using mpd, mplayer or omxplayer and play some anoucements via other subdevice treated as independent output.

...assuming this contents of /etc/asound.conf:

pcm.sd1 {
  type plug
  slave.pcm "hw:0,0,1"
}

ctl.sd1 {
    type hw
    card 0
}

pcm.sd2 {
  type plug
  slave.pcm "hw:0,0,2"
}

ctl.sd2 {
    type hw
    card 0
}

pcm.sd3 {
  type plug
  slave.pcm "hw:0,0,3"
}

ctl.sd3 {
    type hw
    card 0
}
  • 1
    Please focus on the question you're answering. – Dmitry Grigoryev Mar 11 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.