Same sound output via two sound cards

  • tl;dr, solution is HERE. Original thread below.

    I returned back to Raspberry Pi 3 and want to have two sound outputs: HDMI (for watching movies) and HiFi-Berry Analog (for listening music, when TV is off). Some time ago I've configured it to output same sound (best posibility for my configuration) on OSMC by adding following configuration (but, unfortunately, OSMC overwritted asound.conf with every update):

    That created virtual sound card which could be selected in Kodi settings. It worked fine - passthrough worked only via HDMI, PCM worked via both outputs. But when I've added this to /storage/.config/asound.conf - nothing happened. No new device is deceted neither by Kodi nor ALSA.

    What am I doing wrong?

    Edited once, last by REXus (September 25, 2023 at 8:21 PM).

  • Go to Best Answer
  • I've already read about this and probably I'll try it. But 1) this is unofficial build, with unofficial problems and unknown future 2) all I need is to clone audio to two sound cards (no separate config etc.) which can (?) be done by ALSA - so if it is possible, I would prefer to do it this way. Or maybe there are some diffrences in ALSA configuration in LE, so another build is nessesery?

  • It's best to refer to the various cards by name (eg CARD=vc4hdmi), not by number - the numbers can change. see the output of aplay -L

    For hdmi output you need to use the hdmi PCM (i.e. hdmi:CARD=vc4hdmi,DEV=0) or the default pcm - the vc4 hw pcm supports only iec958 format (not S16LE etc) which pretty much no software supports (the hdmi pcm will do the necessary conversion).

    It seems it's necessary to specify the number of slave channels (eg 4 if you want to output 2+2 channels via the multi pcm) in the route pcm.

    And, if you want aplay -L to show the "both" pcm you need to add a description hint.

    Please test with this asound.conf file:

    so long,

    Hias

  • Definitely your configration is better than mine - it shows in aplay :) but Kodi doesn't show "both" device. You don't have ctl.both - is that correct (I'm a total noob in ALSA things, but even in some guide I've found in Internet they adviced to add that lines without explanation)?

    One more question. You have configured my both devices as stereo. Of course, when video player will be using passthrough mode it doesn't matter, but what if software decoding of 5.1 will be nessesery?

  • Which LE version are you using?

    I did a quick test on LE12 nightly and oddly kodi showed it under the name of my soundcard but with empty parenthesis after them (usually they have he name of the soundcard, again). Certainly some kodi oddity but I saw it in the log, too:

    Code
    2023-09-25 18:58:05.085 T:1120     info <general>:     Device 3
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_deviceName      : both
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_displayName     : RPi-Cirrus ()
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_displayNameExtra: WM5102 AiFi wm5102-aif1-0
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_deviceType      : AE_DEVTYPE_PCM
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_channels        : FL, FR, BL, BR, FC, LFE, SL, SR, UNKNOWN1, UNKNOWN2, UNKNOWN3, UNKNOWN4, UNKNOWN5, UNKNOWN6, UNKNOWN7, UNKNOWN8
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_sampleRates     : 32000,44100,48000
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_dataFormats     : AE_FMT_S24NE4,AE_FMT_S32NE,AE_FMT_S16NE,AE_FMT_S16LE
    2023-09-25 18:58:05.085 T:1120     info <general>:         m_streamTypes     : No passthrough capabilities

    If you can't get it working please provide a debug log (enabled debug logging in settings, reboot, ssh in and run "pastekodi").

    If you play multichannel content and have the number of channels set to 2 in kodi audio config then kodi will downmix to 2ch automatically.

    OFC you could also configure more channels, like you did before (also increase the number of channels in the multi pcm accordingly) and eg map 6 channels to HDMI and only FL and FR to the soundcard - but then you'll loose the center channel at the soundcard when playing 5.1 contents.

    You could play around with ttable and down-mix more channels into left and right of the soundcard but that could have negative effects if you only output stereo content.

    It's tricky, you have to play around a bit what you prefer.

    so long,

    Hias

  • I had no idea that name of soundcard with empty parenthesis could be this. IT WORKS :) Thank you for your help.

    I hope some update won't break this :)

    For now I'll stay with your configuration (2x stereo), but I see the point of problem. Maybe I'll change it in the future, but for now... most 5.1 video files works in passthrough mode.

  • I returned back to Raspberry Pi 3 and want to have two sound outputs: HDMI (for watching movies) and HiFi-Berry Analog (for listening music, when TV is off).

    Hi, If I understod correctly, you don't need to have simultaneous audio, just to be used the HDMI for video files and the HiFi-Berry for music. For that I'm using the "Audio Profiles" addon to change automatically the audio output for different type of media (in my case HDMI for movies, TV and HiFi-Berry for music - net radio).

  • So this is another option. It all depends on what you need - in my case, Raspberry Pi is connected to TV via HDMI, and TV via Toslink to speakers; also HiFi-Berry is connected to same speakers via analog input. In your configuration I should care about selected input on speakers, in my (or rather @HiassofT's) it only matters when TV is off.

    And yes, there is a next step - to add IR led and send commands to speakers depending on what type of media is actually played. At this moment my Raspberry controls relays powering speakers and game console, depending on TV and playing status.