• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Multichannel audio on a Pi will get a whole lot easier and cheaper!

charlielaub

Active Member
Joined
Jan 5, 2023
Messages
197
Likes
284
It's alive! Haven't done tons of listening but I'm getting clean output on all channels. Example FFT from ch 3 shown below as captured by a MOTU Ultralite Mk5.

Thanks for all your help @phofman!

Now to try some I2S input.

Michael

I'm a little confused about why you would bother with the I2S interface when you have a USB MOTU ULmk5 with 10 analog output channels and that (supposedly) works perfectly with CDSP... Was there a reason for going that route?
 

gordoste

Member
Joined
Nov 19, 2023
Messages
33
Likes
29
I'm a little confused about why you would bother with the I2S interface when you have a USB MOTU ULmk5 with 10 analog output channels and that (supposedly) works perfectly with CDSP... Was there a reason for going that route?
He said before he was looking at using the I2S input to bring surround sound into CDSP. I assume this would be much cheaper.
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
I'm a little confused about why you would bother with the I2S interface when you have a USB MOTU ULmk5 with 10 analog output channels and that (supposedly) works perfectly with CDSP... Was there a reason for going that route?

I am not personally very interested in multichannel I2S output but I figured others might be (although I always love to tinker). And as a first step in multichannel I2S with the RPi I figured multichannel output would have less variables as I already have a McFIFO / McDualXO + 8 channel AES output device sitting on the shelf that I know works with multichannel I2S input.

I am mostly interested in the potential for multichannel I2S input from a 7.1 HDMI to I2S extractor like this -> https://www.aliexpress.us/item/2251832845605595.html. An Apple TV + HDMI to I2S extractor + RPi 5 running CamillaDSP + multichannel USB DAC (like the UL Mk5) is a very interesting AVR replacement setup to me.

Michael
 

charlielaub

Active Member
Joined
Jan 5, 2023
Messages
197
Likes
284
I am not personally very interested in multichannel I2S output but I figured others might be (although I always love to tinker). And as a first step in multichannel I2S with the RPi I figured multichannel output would have less variables as I already have a McFIFO / McDualXO + 8 channel AES output device sitting on the shelf that I know works with multichannel I2S input.

I am mostly interested in the potential for multichannel I2S input from a 7.1 HDMI to I2S extractor like this -> https://www.aliexpress.us/item/2251832845605595.html. An Apple TV + HDMI to I2S extractor + RPi 5 running CamillaDSP + multichannel USB DAC (like the UL Mk5) is a very interesting AVR replacement setup to me.

Michael
OK, I see. A bit of a hardware mish mash but you are home cooking an interesting and challenging project. I used to try these things with the Pi, with HDMI audio extractor dongles or HATs, but not with input.

Are you planning to process audio from home theater (movies)? If so what sort of latency do you expect?
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
OK, I see. A bit of a hardware mish mash but you are home cooking an interesting and challenging project. I used to try these things with the Pi, with HDMI audio extractor dongles or HATs, but not with input.

Are you planning to process audio from home theater (movies)? If so what sort of latency do you expect?

Yes, 5.1/7.1 audio from streaming services

My hope would be to clock sync the UL Mk5 to HDMI extractor via the TOSLINK output of the HDMI extractor. This should allow me to avoid resampling in CamillaDSP. In synchronous systems I've been able to successfully use a chunk size of 256 and 48 kHz which gives around 15 ms latency with the UL Mk5, although I might need to increase chunk size. Long story short, under 30 ms.

Michael
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Congrats. Now you know we will be expecting a titorial ;)

Very brief tutorial assuming you know your way around a Pi / Linux.

1) Install raspberry pi os lite 64 bit using raspberry pi imager.

2) Clone 6.7 kernel.

Code:
git clone --depth=1 --branch rpi-6.7.y https://github.com/raspberrypi/linux

3) Configure kernel

Code:
cd linux
KERNEL=kernel_2712
make bcm2712_defconfig

4) Modify kernel to use all i2s inputs / outputs.

Code:
nano ~/linux/arch/arm/boot/dts/broadcom/rp1.dtsi

Rich (BB code):
rp1_i2s0_18_21: rp1_i2s0_18_21 {
   function = "i2s0";
   pins = "gpio18", "gpio19", "gpio20", "gpio22", "gpio24", "gpio26", "gpio21", "gpio23", "gpio25",  "gpio27";
   bias-disable;
};

rp1_i2s1_18_21: rp1_i2s1_18_21 {
    function = "i2s1";
    pins = "gpio18", "gpio19", "gpio20", "gpio22", "gpio24", "gpio26", "gpio21", "gpio23", "gpio25",  "gpio27";
    bias-disable;
};

5) Compile modified kernel. This will take around 45 minutes on a raspberry pi 5.

Code:
make -j4 Image.gz modules dtbs
sudo make modules_install
sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/firmware/
sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/firmware/overlays/
sudo cp arch/arm64/boot/dts/overlays/README /boot/firmware/overlays/
sudo cp arch/arm64/boot/Image.gz /boot/firmware/kernel_2712.img
sudo reboot

6) Clone RaspberryPi_I2S_Master

Code:
git clone https://github.com/AkiyukiOkayasu/RaspberryPi_I2S_Master

7) Compile RaspberryPi_I2S_Master and copy to /boot/overlays

Code:
cd RaspberryPi_I2S_Master
dtc -@ -H epapr -O dtb -o i2smaster.dtbo -Wno-unit_address_vs_reg i2smaster.dts
sudo cp i2smaster.dtbo /boot/overlays

8) Modify /boot/config.txt to use I2S.

Code:
sudo nano /boot/config.txt

Rich (BB code):
#dtparam=i2c_arm=on
dtparam=i2s=on
#dtparam=spi=on
dtoverlay=i2smaster

9) Reboot pi.

Code:
sudo reboot

10) Setup CamillaDSP configuration.

I used playback device as hw:I2Smaster, S32LE format and 8 channels.

----

Some good references where I gathered all this info, again thanks to @phofman.


----
Pin Mapping
GPIO 18: BLCK/SCLK
GPIO 19: WS/LRCLK
GPIO 20: I2S data IN 0
GPIO 22: I2S data IN 1
GPIO 24: I2S data IN 2
GPIO 26: I2S data IN 3
GPIO 21: I2S data OUT 0
GPIO 23: I2S data OUT 1
GPIO 25: I2S data OUT 2
GPIO 27: I2S data OUT 3
----

Michael
 
Last edited:

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Got the HDMI to I2S extractor working as an input in to the RPi5 running in slave mode!

Followed instructions from here -> https://github.com/AkiyukiOkayasu/RaspberryPi_I2S_Slave/tree/master. I needed to change all instances of <&i2s> to <&i2s_clk_consumer> as described here -> Re: Simple-audio-card I2s audio issues (bookworm). My CamillaDSP capture device is hw:GenericStereoAu,1 using 8 channels of S32LE.

Now getting 8 channels of perfect 24 bit audio at 48 kHz over HDMI from a MacBook Pro in to the RPi5 running CamillaDSP. Using the UL Mk5 as a playback device clocked via optical from the extractor. Currently using 512 chunk size in CamillaDSP and buffer level seems pretty stable but I'll need to listen for longer to see if I get buffer under runs.

Only oddity so far is channels 3 (center) and 4 (subwoofer) seem to swapped in the extractor, although this could also be something to do with routing from my Mac. This seems persistent through CamillaDSP restarts.

Looking forward to doing some testing with an Apple TV tomorrow.

Michael
 

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,659
Likes
2,274
I think this is excellent news for the DIY folks. With one of these Explore hdmi transceiver chips similar to the one Michael uses but the ones that don't need MCU (ie. EP92A3E), and a multichannel dac, one could now assemble a hat that takes HDMI, sends it to the pi for DSP and outputs more than decent up to 8 channels analog in a very compact cost effective device.
I have in a drawer the HDMI side reverse engineered from one of these extractors. It is a lot of parts, but only one IC and no programming involved.
If this works with stuff like netflix, it will make a very cool project (crossing fingers for no channel swapping this time :) )
 

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
503
Likes
328
@mdsimon2 : Maybe you could try an overlay like this which only changes the pins param of the rp1_i2s0/1_18_21 nodes (untested):

Code:
//Device tree overlay for 8ch RP1
/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&rp1_i2s0_18_21>;
        __overlay__ {
            pins = "gpio18", "gpio19", "gpio20", "gpio22", "gpio24", "gpio26", "gpio21", "gpio23", "gpio25",  "gpio27";
        };
    };

    fragment@1 {
        target = <&rp1_i2s1_18_21>;
        __overlay__ {
            pins = "gpio18", "gpio19", "gpio20", "gpio22", "gpio24", "gpio26", "gpio21", "gpio23", "gpio25",  "gpio27";
        };
    };
};

A very handy command is listing the whole tree, with overlays applied (the symbols are at the end):

dtc -I fs /sys/firmware/devicetree/base
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Apologize for my ignorance, should I try that overlay on an unmodified kernel?

Is that a replacement of a portion of the i2smaster.dts / genericstereoaudiocodec.dts or should it be used on it's own?

Michael
 

charlielaub

Active Member
Joined
Jan 5, 2023
Messages
197
Likes
284
Got the HDMI to I2S extractor working as an input in to the RPi5 running in slave mode!

Followed instructions from here -> https://github.com/AkiyukiOkayasu/RaspberryPi_I2S_Slave/tree/master. I needed to change all instances of <&i2s> to <&i2s_clk_consumer> as described here -> Re: Simple-audio-card I2s audio issues (bookworm). My CamillaDSP capture device is hw:GenericStereoAu,1 using 8 channels of S32LE.

Now getting 8 channels of perfect 24 bit audio at 48 kHz over HDMI from a MacBook Pro in to the RPi5 running CamillaDSP. Using the UL Mk5 as a playback device clocked via optical from the extractor. Currently using 512 chunk size in CamillaDSP and buffer level seems pretty stable but I'll need to listen for longer to see if I get buffer under runs.

Only oddity so far is channels 3 (center) and 4 (subwoofer) seem to swapped in the extractor, although this could also be something to do with routing from my Mac. This seems persistent through CamillaDSP restarts.

Looking forward to doing some testing with an Apple TV tomorrow.

Michael

Are doing, or plan to do, any processing within CamillaDSP or is CDSP just a tool to connect the I2S input to the ULmk5 output while maintaining sync?
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Are doing, or plan to do, any processing within CamillaDSP or is CDSP just a tool to connect the I2S input to the ULmk5 output while maintaining sync?

Yes, using CamillaDSP to implement processing. This is a bit of a far out project without any concrete plans but the intent would be to use DIY active speakers for at least L + C + R.

Michael
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
That should work (provided the overlay is correct) for the stock RPi kernel. Just put it into another DTS file, compile to dtbo, and add to config.txt https://raspberrypi.stackexchange.com/a/40220

Made a file called 8chi2s.dts with your code snippet and used the command "dtc -@ -H epapr -O dtb -o 8chi2s.dtbo -Wno-unit_address_vs_reg 8chi2s.dts" to compile which is just copy / paste from RaspberryPi_I2S_Master example. Copied the dbto to /boot/overlays and added dtoverlay=8chi2s to /boot/config.txt.

I don't see any difference when running "dtc -I fs /sys/firmware/devicetree/base" when the dtoverlay is specified or not (files attached for reference).

Michael
 

Attachments

  • Archive.zip
    32.1 KB · Views: 24

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Did some listening with an Apple TV HD, seems well behaved and am getting 5.1 PCM.

Haven't found anything that will send 7.1 from the Apple TV, it will either report "5.1" or "Dolby Atmos" but I never see anything on the rear channels. Although from some googling it doesn't seem like much if any non-atmos 7.1 is available on streaming services and even if it is technically 7.1 there is rarely any content on the rear channels. If you know of a 7.1 example available streaming let me know.

Center is coming through on channel 4 which seems to confirm the center / subwoofer channel swapping is occurring in the extractor.

Michael
 
  • Like
Reactions: MCH

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
503
Likes
328
I don't see any difference when running "dtc -I fs /sys/firmware/devicetree/base" when the dtoverlay is specified or not (files attached for reference).

IMO the 8ch pins were applied correctly, sure there is a difference:

Code:
pavel@hp:~$ diff overlay_*
1320c1320
<             rsts = <0x20>;
---
>             rsts = <0x1020>;
2765c2765
<                         pins = "gpio18\0gpio19\0gpio20\0gpio21";
---
>                         pins = "gpio18\0gpio19\0gpio20\0gpio22\0gpio24\0gpio26\0gpio21\0gpio23\0gpio25\0gpio27";
3083c3083
<                         pins = "gpio18\0gpio19\0gpio20\0gpio21";
---
>                         pins = "gpio18\0gpio19\0gpio20\0gpio22\0gpio24\0gpio26\0gpio21\0gpio23\0gpio25\0gpio27";

But I do not see any master/slave card changes in those dumps, no spdif or capture_link string, etc, all i2s configs have status disabled. Debugging e.g. https://forums.raspberrypi.com/viewtopic.php?t=186438 https://www.raspberrypi.com/documentation/computers/configuration.html#part5.2
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
IMO the 8ch pins were applied correctly, sure there is a difference:

Code:
pavel@hp:~$ diff overlay_*
1320c1320
<             rsts = <0x20>;
---
>             rsts = <0x1020>;
2765c2765
<                         pins = "gpio18\0gpio19\0gpio20\0gpio21";
---
>                         pins = "gpio18\0gpio19\0gpio20\0gpio22\0gpio24\0gpio26\0gpio21\0gpio23\0gpio25\0gpio27";
3083c3083
<                         pins = "gpio18\0gpio19\0gpio20\0gpio21";
---
>                         pins = "gpio18\0gpio19\0gpio20\0gpio22\0gpio24\0gpio26\0gpio21\0gpio23\0gpio25\0gpio27";

But I do not see any master/slave card changes in those dumps, no spdif or capture_link string, etc, all i2s configs have status disabled. Debugging e.g. https://forums.raspberrypi.com/viewtopic.php?t=186438 https://www.raspberrypi.com/documentation/computers/configuration.html#part5.2

Sorry, I had just grep'd the files for "i2s" and "8ch" and didn't see any changes. I also did not have any of the master / slave overlays in place.

Just set it up with the i2s slave overlay and works great! Much easier / faster than compiling the kernel. Also attached the overlay log for reference.

Michael
 

Attachments

  • overlay_slave.txt
    88.8 KB · Views: 29

DWPress

Major Contributor
Forum Donor
Joined
May 30, 2018
Messages
1,028
Likes
1,480
Location
MI
You guys are making me want a RPi5 just to get back into my audio coding days. BUT NOOOO - so much else to do - can't go down that rabbit hole.
:p
 
Top Bottom