2

I have a Raspberry Pi 3, with OSMC installed as its OS.

I used to have audio through HDMI and the 3.5mm jack at the same time, allowing me to either listen through the speakers of a TV, or through headphones, without the need to change the settings. However, since the 3.5mm jack produces too much hissing noise, I decided to buy a cheap USB dongle.

My question is how can I reroute audio to be outputted both through HDMI and the USB card simultaneously.

1 Answer 1

2

You can do this whether you are using a GPIO sound card or USB sound card. It may be better to use a GPIO sound card short list here, because it will have less latency then blocking out to USB using UAC2... But that remains to be seen.

Before I launch into how to implement this, have you considered using a sound card with both headphones and RCA outputs? If you are happy to take input to your TV from the RCA jacks, that may be neater, with fewer clock drift and format problems. Some of the listed GPIO sound cards have that feature.

You need to create an asoundrc which copies audio to both sound cards using ttable.

pcm.!default plug:both

pcm.both {
  type route;
  slave.pcm {
      type multi;
      slaves.a.pcm "card0";
      slaves.b.pcm "card1";
      slaves.a.channels 2;
      slaves.b.channels 2;
      bindings.0.slave a;
      bindings.0.channel 0;
      bindings.1.slave a;
      bindings.1.channel 1;

      bindings.2.slave b;
      bindings.2.channel 0;
      bindings.3.slave b;
      bindings.3.channel 1;
  }

  ttable.0.0 1; # Map card 0 ch0 to ch0
  ttable.1.1 1; # Map card 0 ch1 to ch1

  ttable.0.2 1; # copy audio from 0 to card 1 first ch at full vol.
  ttable.1.3 1; # copy audio from 1 to card 1 second ch at full vol.
}

Beware as you may get clock drift between the cards and various other formatting issues. To get around this, investigate using plughw as the device when defining the card in the slaves.a.pcm line and equivalent for b. Something like plughw:CARD=card0,DEV=0 where card0 is your actual card. This info can be found using the aplay -L command.

2
  • Thanks for your answer, but I have already bought a USB sound dongle (or what it's called), so a GPOI sound card is out of the question. I will try this to check if it works with the USB sound dongle.
    – gertab
    Sep 28, 2016 at 14:23
  • Just to add a note. I have an old USB nuForce uDAC that has 3.5mm headphone out and also rca outs. It puts out pretty nice sound and you cam probably find one for $20
    – pathfinder
    May 22, 2018 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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