Elehobica's Digital Audio Recorder Captures S/PDIF Sound with a Raspberry Pi Pico
This minimal-component project can capture high-resolution audio from external sources, recording to a microSD card over SPI.
Pseudonymous maker Elehobica has turned a Raspberry Pi Pico into a high-resolution digital audio recorder, turning an S/PDIF input into WAV files on a microSD card.
"[This is a] Hi-Res recorder from S/PDIF input to WAV files on microSD card," Elehobica explains of the compact protoboard build. "Bit resolution: 16-bit or 24-bit (2 ch[annel]). Sampling frequency: 44.1kHz, 48.0kHz, 88.2kHz, 96.0kHz (176.4kHz, 192kHz). Recording only, no monitoring or playback functions."
The project, brought to our attention by Adafruit, is designed to support either the Raspberry Pi Pico or Raspberry Pi Pico W development boards and their RP2040 microcontroller — though doesn't make use of the wireless functionality of the Raspberry Pi Pico W if present. Rather than recording audio from an analog input, though, it concentrates on high-resolution digital audio from a DLR1160 TOSLINK S/PDIF input.
Data captured from the S/PDIF input is recorded as a WAV file to a microSD card — wired directly to the Raspberry Pi Pico's general-purpose as an SPI device. "Short wiring as possible is desired," Elehobica notes, "otherwise errors such as mount error and write fail will occur."
Coded using the Raspberry Pi RP2040 C/C++ software development kit (SDK), the recorded provides a serial interface over USB with optional hardware buttons. Files are automatically split during short periods of silence, while longer periods place the recorder into standby mode until audio is detected again.
For those looking for the highest of resolutions, though, there's one small caveat — and the reason why 176.4kHz and 192kHz are mentioned in brackets in Elehobica's summary of the tool's capabilities: "Due to the limitation of single bit SPI interface driven by Raspberry Pi Pico," the maker explains, "even with highest class microSD cards (as of 2024), recording in 24bit 176.4kHz or 192.0kHz is challenging. It will sometimes causes the drops of audio sampling data."
Source code and a wiring diagram are available on Elehobica's GitHub repository under the permissive BSD 2-Clause license.