probonopd / MiniDexed

Dexed FM synthesizer similar to 8x DX7 (TX816/TX802) running on a bare metal Raspberry Pi (without a Linux kernel or operating system)
https://github.com/probonopd/MiniDexed/wiki
962 stars 72 forks source link

Add support for 8 channel I2S mono audio output on RPi 5 #657

Closed diyelectromusic closed 6 days ago

diyelectromusic commented 1 month ago

Support for 8 channel mono audio output - one per Tone Generator - on a Raspberry Pi 5 only. This uses the four I2S lanes of the Raspberry Pi and can be configuring by adding QuadDAC8Chan=1 to minidexed.ini.

It will be off by default.

Note: if enabled, then pan and effects are ignored and each TG will just have a direct output to one of the four stereo outputs as follows: TG 0 = I2S module 1 L TG 1 = I2S module 1 R TG 2 = I2S module 2 L ... TG 8 = I2S module 4 R

I2S modules will share LCK/BCK but the four DIN lines will need to be connected to GPIO 21, 23, 25, 27.

Requires the latest circle develop branch.

See discussions here: https://github.com/probonopd/MiniDexed/discussions/655 and https://github.com/rsta2/circle/discussions/453

This should support the HiFiBerry DAC8X board (untested) or four GY-PCM5102 modules (tested) as described here: https://diyelectromusic.wordpress.com/2024/05/27/rpi-5-quad-stereo-sound-with-pcm5102a/

As always, this needs testing with more normal configurations to make sure nothing has been broken with sound output across all Pi versions with I2S.

Post reply below if you test it and with what configuration :)

Kevin

diyelectromusic commented 1 month ago

Build for testing here: MiniDexed_2024-05-28-ad61b48

probonopd commented 1 month ago

Wow, that's quite the advanced configuration. Way over my head, as this practically requires a 8-channel mixer or 8-channel audio interface, but I guess it's great for people working in a "real studio" 👍

What is the technical reason that this is only an option for RPi 5?

Edit: Found the answer in https://github.com/probonopd/MiniDexed/discussions/655#discussioncomment-9591072

Only the Pi 5 supports four I2S lanes via the new RP1 chip, so no, this is not possible on the Pi 4 in hardware (there might be software workarounds for another virtual I2S interface, but that is a major piece of bespoke work so really not worth the effort).

Should mention that in a source code comment and in the documentation.

Since I have no way to test, simply let me know when you think it should be merged. Thanks!

diyelectromusic commented 1 month ago

Yes, I haven't made the RPi 5 thing explicit in comments as it could be argued its the same as we don't write out the specification for other Pi hardware features in code (we don't explicitly talk about how only the Pi 1 is not multicore for example, or the Zero has no PWM interface by default, etc). I'd hope that anyone rebuilding the source and messing around with features down at the driver level like this would know the capabilities of the device they are building for :)

I'll make sure our wiki talks about it properly though.

In terms of testing, I need some people to test their own "normal" configurations to make sure the audio channels are correct and if someone could actually test it on a dac8x when they finally turn up that would be great!

I haven't done it yet, but I'll do my usual testing on the range of Pis I have at some point.

Kevin

diyelectromusic commented 1 month ago

OK, so I've tested with my own normal configurations for Pi V1, Pi Zero, Pi 3A+ and Pi 4 and all seems ok to me.

Kevin

probonopd commented 1 month ago

Let's get this merged before main deviates too much.

diyelectromusic commented 2 weeks ago

If you fancy merging this in at some point, I might start to look more closely at the polyphony/TG questions :)

Kevin

probonopd commented 6 days ago

Hi @diyelectromusic, currently I have no way of testing this, but if you are confident that this doesn't break anything and doesn't complicate the code too much then I'd merge it as-is.

diyelectromusic commented 6 days ago

Well I'd say if you test it with your own (non-quad) configuration as a double check and find its fine that confirms my findings and we'd be good to go.

But as I say, I've tried it with all the other configs/Pis I have access to and I think it's fine.

Kevin

probonopd commented 6 days ago

Thanks @diyelectromusic.

I'll make sure our wiki talks about it properly though.

Please go ahead. Thank you!

diyelectromusic commented 5 days ago

Option now added to the wiki.

probonopd commented 5 days ago

Maybe you'd also like to link to https://diyelectromusic.com/2024/06/09/minidexed-quad-dac-pcb-design/ if you like.

diyelectromusic commented 5 days ago

I've linked to the previous post as it was informational. I (as a rule) try not to link to actual project pages from our official documentation :)