Using the DAC+ DSP to record audio from S/PDIF

 

Using the DAC+ DSP to record audio from S/PDIF

The DAC+ DSP can also be used to send data from the DSP back to the Pi. One use case is to record audio from S/PDIF input. As our DSP profiles are optimised for playback, this requires some configurations.

Configure the DAC+ DSP driver with recording capabilities

First you need to make sure, you have enabled the DAC+ DSP driver by configuring

dtoverlay=hifiberry-dacplusdsp

in /boot/config.txt

To check if it is configured and loaded correctly, run

arecord -l

This should list the DAC+ DSP as an input source.

Configure the DSP to route S/PDIF audio to the Raspberry Pi

The next step is now to configure the Asynchronous Sample Rate Converter (ASRC) on the DSP to route the SPDIF input data to the Pi.
The easiest way is to download this small script and run it.

The main part of the script is quite simple configuring the ASRC and the DATA port that sends data to the Pi:

# ASRC6: Input from SPDIF
dsptoolkit write-reg 0xF106 0x0003

# ASRC6 output rate: SDATA_OUT3
dsptoolkit write-reg 0xF146 0x0004

# SOUT SOURCE20/21: ASRC6
dsptoolkit write-reg 0xF195 0x0000
dsptoolkit write-reg 0xF194 0x0033

# SDATA_OUT3 configuration: clock slave
dsptoolkit write-reg 0xF21C 0x6C40

Record audio

You can use basically any tools that can use the ALSA API. Her’s a simple example using arecord/aplay:

arecord -f cd -d 10 1.wav; sleep 1; aplay 1.wav

This will just record 10 seconds of audio and play it back again.

Last updated: August 5, 2020