Is it possible to play different audio, for example audio from video file to my HDMI and audio from music player to 3,5 jack in the same time?
3 Answers
It is possible for the Pi to source multiple different audio outputs. The sound output via HDMI is digital whereas the 3.5 mm jack is a PWM based analogue output. They're different from each other and alsa is perfectly capable to handle multiple outputs (see here). Different software tools (or multiple instances of the same) should then be able to output different sound files to those cards.
In this case, an exemplary setup could be:
kodioutputs A/V to HDMImpdormopidyoutput sound stream to the analog jack
The information on the web is slightly inconsistent, some claim that both support multiple instances running other say they don't.
related: Is it possible to have multiple audio outputs going to different speakers at the same time?
- 15,958
- 17
- 65
- 125
It turns out this is really easy. You just have to tell each program which audio device to use.
You can see the available devices with aplay -l. On my Pi 3, it tells me the following:
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/8
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
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
I don't know what all those subdevices are, but the important part to notice is that card 0 device 0 says at the end [bcm2835 ALSA] and then card 0 device 1 says [bcm2835 IEC958/HDMI]. In other words, they're both card 0, and device 0 is the analogue output while device 1 is HDMI.
I left the Raspberry Pi audio setting on "auto" (0). I also left my Kodi settings alone (though I wonder if there may be some edge cases where it might output to the wrong device so it may be worth setting the device explicitly). Then I configured MPD to use the analogue device. That looks like this:
audio_output {
type "alsa"
name "Raspberry Pi analogue output"
device "hw:0:0"
}
I now have MPD's output coming through the analogue output and Kodi's through HDMI. They can both output simultaneously.
I'm running OSMC, in case it's relevant.
- 111
- 4
look no further than this: https://www.raspberrypi.org/documentation/configuration/audio-config.md
amixer cset numid=3 1 #####jack output
amixer cset numid=3 2 ########hdmi output
- 2,929
- 3
- 26
- 34