Bare metal Pisound?

Hey all, first post here :wave:

I’m developing a hardware project using a Raspberry Pi 4 Compute Module as the platform, and I just ordered a Pisound for testing with a DAC/ADC so that I don’t have to think about the analog circuitry yet. I was wondering, has anyone done any bare metal programming with the Pisound, i.e. without using ALSA or drivers in between? I didn’t see any official documentation related to doing this, apart from the mention of how the DAC/ADC are configured for I2S. What are the steps to take to make this work?

1 Like

You’d have to somehow gain access to the audio related CPU registers to control the I²S peripheral. See Peripheral specification from BCM2835 - Raspberry Pi Documentation

Pisound specific kernel sources are here:

I don’t think there’s much to gain by bypassing ALSA APIs though. :slight_smile:

The main reason I want to do bare metal is that I’m only using Pisound for prototyping, the end product will not ship with Pisound. So instead of depending on drivers being available / writing them for the DAC and ADC chips I end up using, it feels like it would make sense to just skip the middleman and talk directly to them over I2S. If there’s an error in my thinking, corrections are more than welcome, as I’m new to this embedded Linux thing :slight_smile:

You’d just use ALSA drivers for ADC / DAC of your choice or if there’s none available, you’ll have to write that part yourself. That would be one off code that you get right one time. :slight_smile: Most of your energy will likely go on your actual PCM processing & generation routines which are sufficiently independent from underlying hardware.

Yep that makes sense, thanks for the perspective. Will try using ALSA then.

I have been writing the algorithm prototype on PC with JUCE so I already have the algorithm be completely independent from hardware, so that part’s already covered :grin:

1 Like

Probably JUCE can itself output to ALSA devices, you’ll just have to sort out the ALSA driver for your final hardware. :slight_smile:

minidexed, GitHub - probonopd/MiniDexed: Dexed FM synthesizer similar to DX7 running on a bare metal Raspberry Pi (without a Linux kernel or operating system) is a bare metal Pi project that can leverage PiSound as it’s sound card. 7 simultaneous DX7’s out of one RasPi 3 or 4. Don’t know if that is what you’re looking for as far as inspiration / guidance, but there it is.


@Ted_Kritzler Have you tried running it with Pisound?

Yes, but I am still trying to figure out how the .syx files for presets should be handled. I will update if I get it to make noise.

1 Like

MiniDexed is awesome, thanks for the reference. I just installed the release image on a B 3+ and I can get sound from 2 out of 3 ouputs by default.

  1. Bulit-in DAC has no latency but audible dithering I think. Sounds like some sample rate conversion noise
  2. HDMI with a sound bar has so much latency the instrument is not playable
  3. Pisound has no sound.

So…I can help something but I’m not sure where to start. This seems like quite an interesting embedded project.

@Giedrius Is there any documentation available on Pisound’s usage of the Pi’s GPIO pins? The “Detailed Specs” document doesn’t seem to go into that much detail … Also, is there any functionality of Pisound that’s “expendable”, i.e. will gracefully fail if its pins aren’t available (e.g. audio in, MIDI out, button … as they wouldn’t be needed for use with MiniDexed). The latter would probably be needed, as the number of available GPIO left by Pisound seems lower than what is needed by MiniDexed when using it with the display and rotary encoder.
Unfortunately, I’m not at all experienced when it comes to programming in C, so my main goal here would be to gather information for someone else to actually code Pisound support into MiniDexed :slight_smile:

1 Like

The best and most up to date documentation is always the source code itself. :slight_smile: Check out the kernel module and the device tree overlay:

They key GPIOs for audio are the OSR pins which select the sampling rate. See here for what OSR values to use for which rate (Pisound supports only 48kHz, 96kHz and 192kHz). Also the first Reset pin resets the ADC and DAC.

This should be enough for audio functionality, MIDI requires communication via SPI.


Thanks, @Giedrius!

For posterity, here’s a picture of the Pisound pinout and the optional headers on the top of the board.