5

Is it possible to play 2 sounds simultaneously?

For example: one via HDMI (audio from a video) and another one (custom audio, wav, or whatever) via analog output at the same time?

Piotr Kula
  • 17,307
  • 6
  • 65
  • 104
Caio Keto
  • 355
  • 1
  • 5
  • 10

2 Answers2

3

No.

The Raspberry Pi can only use one output. This is by hardware design and is to do with DMA (Direct Memory Access)

You can plug in a USB audio device then you can use two output sounds at the same time.

The next best thing could be to play a sound out on HDMI, switch to Analog and play a sound there. But not at the same time and switching could make strange noises on both sources.

Piotr Kula
  • 17,307
  • 6
  • 65
  • 104
  • So, if I got an USB audio I can do it via python? – Caio Keto Jun 13 '13 at 14:22
  • Yes. One line of code will reference the internal sound channel and the other the USB one. They can play, record and even stream to each other independently then. – Piotr Kula Jun 13 '13 at 14:31
  • If it's not asking too much, could you link somewhere for me to learn how to make it? – Caio Keto Jun 13 '13 at 14:32
  • Sorry. I do not know. You can try a Python Q&A also found somewhere on stackexchange network, programming sites or something like that. It will be the same as sending music using Raspberry,, you just need to change the output device for the USB. – Piotr Kula Jun 13 '13 at 14:39
  • 1
    Try the PyAlsaAudio homepage: http://pyalsaaudio.sourceforge.net/pyalsaaudio.html -- Raspbian comes with a package for that as well. – Arne Jun 13 '13 at 16:41
  • Sorry to bring it back, but it would work with bluetooth audio ? (Headset)? – Caio Keto Jun 25 '13 at 13:09
  • I think it should. As Bluetooth audio profile acts as a separate sound device. – Piotr Kula Jun 25 '13 at 13:10
0

It's possible (at least on Raspberry Pi 3). I have Kodi playing audio through HDMI and MPD playing audio through the analogue output. They can do so simultaneously. See my answer to a similar question.

In short, send one sound to card 0 device 0 (analogue) and another to card 0 device 1 (HDMI).

tremby
  • 111
  • 4