Jonas_raspi
Posts: 1
Joined: Sun Mar 11, 2018 5:15 pm

How to enable 5.1 channel audio over HDMI

Sun Mar 11, 2018 5:28 pm

Hey all,

I'm trying to use my Raspberry Pi to apply some room correction algorithms when playing my music. For this it is connected to my receiver via HDMI. In order for this to properly work, I need to be able to let the Pi give individual signals for each channel to the speakers (especially the subwoofer needs to be separate, so technically 2.1 would be sufficient (the receiver is able to handle up to 7.1).
I remember reading somewhere that this is possible, I just don't know how.
Right now when I connect the Pi to my reciever the receiver says "Audio input format: 2.0 ch (PCM, 48kHz), and when I run

Code: Select all

pi@raspberrypi:~ $ speaker-test  -c 6

speaker-test 1.1.3

Playback device is default
Stream parameters are 48000Hz, S16_LE, 6 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 256 to 32768
Period size range from 256 to 32768
Using max buffer size 32768
Periods = 4
was set period_size = 8192
was set buffer_size = 32768
 0 - Front Left
 4 - Center
 1 - Front Right
 3 - Rear Right
 2 - Rear Left
 5 - LFE
Time per period = 16.757463
 0 - Front Left
 4 - Center
 1 - Front Right
 3 - Rear Right
 2 - Rear Left
 5 - LFE
I only hear something for 0 - Front Left and 1 - Front Right. For 5 - LFE it remains silent. (For all the other as well since I only have two speakers and a subwoofer connected :p)

Does anybody know how to activate 5.1 channel output?

Oh, in case its helpful, aplay -l shows 8 subdevices. (Maybe indicating 7.1 capability?)

Code: Select all

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/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

goatherd
Posts: 1
Joined: Fri Apr 20, 2018 4:13 am

Re: How to enable 5.1 channel audio over HDMI

Fri Apr 20, 2018 4:21 am

Subdevices are used for sound mixing so that multiple applications can play sounds simultaneously without taking exclusive control of the output, so that does not indicate that surround-sound is active.

The snd_bcm2835 kernel module that is included with Raspbian requires a minor change in order to support multi-channel sound output. To get it working you will have to rebuild the kernel and patch the bcm2835-pcm file to increase the max_channels value from 2 to 8 (if you want to use 7.1 surround). If you also need to be able to redirect channels to other speakers then you will need to find a patch that adds that functionality as well since that is not implemented at all.

yossichay
Posts: 1
Joined: Wed Nov 23, 2016 2:53 am

Re: How to enable 5.1 channel audio over HDMI

Mon Dec 17, 2018 4:44 pm

I'm trying for long time to enable 8 channels over HDMI using Raspbian without much success.

Would you be able to share the process of patching snd_bcm2835 kernel module?

User avatar
innocent_bystander
Posts: 73
Joined: Mon Oct 15, 2018 12:15 am
Location: Florida, USA

Re: How to enable 5.1 channel audio over HDMI

Sun Jul 28, 2019 1:53 pm

Sorry for beating a dead horse, but has anyone been able to successfully expand the number of channels in ALSA by patching snd_bcm2835 as @goatherd mentioned?
The motto of the Sirius Cybernetics Corporation is "Share and Enjoy."

To show appreciation for our efforts, please deposit any amount into our Nutri-Matic Drinks Dispenser: https://paypal.me/buy1coffee4me

User avatar
innocent_bystander
Posts: 73
Joined: Mon Oct 15, 2018 12:15 am
Location: Florida, USA

Re: How to enable 5.1 channel audio over HDMI

Thu Aug 01, 2019 6:19 pm

It turns out no patching is needed for 5.1 output in ALSA. I believe the 2 channel channels_max limit in snd_bcm2835 is for the analog output.

I am able to get 5.1 output with the following command:

Code: Select all

speaker-test -c6 -D hw:0,1
The motto of the Sirius Cybernetics Corporation is "Share and Enjoy."

To show appreciation for our efforts, please deposit any amount into our Nutri-Matic Drinks Dispenser: https://paypal.me/buy1coffee4me

pitibonom
Posts: 55
Joined: Tue Jan 02, 2018 7:20 pm

Re: How to enable 5.1 channel audio over HDMI

Sun Apr 19, 2020 5:19 pm

@innocent_bystander

you might have a special setup/hardware on your pi as your command line only outputs sound on FL and FR and not on other speakers ^^

User avatar
innocent_bystander
Posts: 73
Joined: Mon Oct 15, 2018 12:15 am
Location: Florida, USA

Re: How to enable 5.1 channel audio over HDMI

Sun Apr 19, 2020 6:34 pm

Thanks @pitibonom. I was able to resolve it. It was indeed a problem with my hardware/setup. Had to add this to my pulse audio settings:

Code: Select all

load-module module-alsa-sink name=HDMI device=hw:0,1 channels=8 tsched=0

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
The motto of the Sirius Cybernetics Corporation is "Share and Enjoy."

To show appreciation for our efforts, please deposit any amount into our Nutri-Matic Drinks Dispenser: https://paypal.me/buy1coffee4me

pitibonom
Posts: 55
Joined: Tue Jan 02, 2018 7:20 pm

Re: How to enable 5.1 channel audio over HDMI

Fri Apr 24, 2020 6:19 pm

errrrr....

what is 'load-module' ???? i don't have it in my raspbian !
:(

pitibonom
Posts: 55
Joined: Tue Jan 02, 2018 7:20 pm

Re: How to enable 5.1 channel audio over HDMI

Fri Apr 24, 2020 6:33 pm

awwww i just installed pulse audio and some things changed 8-D

read speakers give sound when

speaker-test -c6 -D hw:0,1

:o

digging in this again :D
Thanks a lot @innocent_bystander !

tlong
Posts: 3
Joined: Fri May 29, 2020 1:18 pm

Re: How to enable 5.1 channel audio over HDMI

Tue Jun 02, 2020 12:51 pm

Any updates on this? Is this still working for folks?

shrinath
Posts: 3
Joined: Tue Jan 19, 2021 12:39 pm

Re: How to enable 5.1 channel audio over HDMI

Thu Jan 21, 2021 6:16 pm

Hi,

I am unable to get 5.1 playback in Rasp Pi 3B model. The speaker-test -c8 -t wave can playback only stereo output.

Here you mentioned like the 5.1 playback has been achieved. Could you please share me the exact steps that I need to follow to get 5.1 channels working?

Return to “Graphics, sound and multimedia”