Lusya/audiophonics ADC for Pi

caveat...I'm an older audiophile and Linux user. I claim no coding skills and won't be supporting this how-to and any querys. However, it does work for me today and, as has been said before on this forum, 'even a blind squirrel sometimes finds a nut" :)

ADC Analog to Digital Converter AKM5720 I2S 24Bit / 96kHz - Audiophonics
Lusya lossless digital audio I2S ADC decoder Support 24bit 96K I2S Signal output A1 003|Digital-to-Analog Converter| - AliExpress

This walk through should set-up the above mentioned ADCs for recording.
Connection to the ADC is as for an i2s dac but changing the default Pi output GPIO Data pin to the Pi Data input GPIO pin...look up the GPIO pins for those.

The setup script will auto-detect your Pi model. I used a Pi2B with no other peripherals attached.
I am assuming you have a little Linux knowledge and are running a Linux PC.

Download Raspberry Pi O/S lite
Operating system images – Raspberry Pi

Burn to a micro-sd card using Balena Etcher
balenaEtcher - Flash OS images to SD cards & USB drives

With the micro-sd card still in your computer write an empty file titled ssh to the boot partition of the card. Option #3...
SSH (Secure Shell) - Raspberry Pi Documentation

Eject the card and insert it into your Pi (ethernet wired) then boot.

ssh to your Pi from another PC and follow the prompt to change the password.

Run..
Code:
sudo raspi-config
and in the Advanced tab select to Expand the filesystem. Exit raspi-config but don't reboot yet.
Run...
Code:
sudo nano /boot/config.txt
and uncomment this line to read..
Code:
dtparam=i2s=on
Save and exit.

Now reboot and log back in.
Do both..
Code:
sudo apt-get -y update
sudo apt-get -y upgrade
Then reboot and log back in and..
Code:
sudo apt install python3-pip
then..
Code:
cd ~
sudo pip3 install --upgrade adafruit-python-shell
wget [url]https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2smic.py[/url]
and finally...
Code:
sudo python3 i2smic.py

When that's all done reboot, log back in and ..
Code:
sudo nano Raspberry-Pi-Installer-Scripts/i2s_mic_module/snd-i2smic-rpi.c
and change this line..
Code:
.daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
to read..
Code:
.daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM,

save and then rerun the installer script..
Code:
sudo python3 i2smic.py

reboot log in and run ..
Code:
arecord -l
output should be...
Code:
**** List of CAPTURE Hardware Devices ****
card 1: sndrpii2scard [snd_rpi_i2s_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 [simple-card_codec_link snd-soc-dummy-dai-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

then run ..
Code:
arecord -L
output should be..
Code:
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=sndrpii2scard
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Default Audio Device
sysdefault:CARD=sndrpii2scard
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Default Audio Device
dmix:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Direct sample mixing device
dsnoop:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Direct sample snooping device
hw:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Direct hardware device without any conversions
plughw:CARD=sndrpii2scard,DEV=0
    snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0
    Hardware device with all software conversions

If that is all good try recording with..
Code:
arecord -D sysdefault:CARD=1 -c2 -f S32_LE -r 96000 --vumeter=stereo test.wav
which should give (with no input to the adc card yet) the following output and a basic vu meter showing 00% for both channels. (ctrl + c to stop)
Code:
Recording WAVE 'test.wav' : Signed 32 bit Little Endian, Rate 96000 Hz, Stereo
                                  +00%|00%+

Connect a source to the card and adjust the #1 dip-switch for gain then rerun the recording command with some content playing.

With much thanks to forum member Phofman posts 7 & 9 here..
SBC with I2S codec drivers for playing/recording

and the information from this site..
Raspberry Pi Wiring & Test | Adafruit I2S MEMS Microphone Breakout | Adafruit Learning System

If IIUC the set-up above uses the scripts for an i2s device (microphone) modified to work with the ADC by changing it from slave to master mode ( CBS_CFS to CBM_CFM)

You will most probably need a Pi4 with 4GB ram (or better) (or set up a ram-drive for lesser Pi. I did this to allow one side of an LP to be recorded then moved the files to my PC ...rinse and repeat.)
To send the audio elsewhere in real time you may need to research piping to external devices or over the network.
 
Last edited:
  • Like
Reactions: 1 user
Hi Drone7.

Thanks a lot for having sorted out this tricky connexion of a WM8782 ADC to a RPi. Until now, the only way to inject audiophile analog to the Pi was using the HifiBerry DAC+ADC Hat. Very limiting if you already hook a high quality dac and only wanted to get the ADC feature.

I wondered if you could provide the pin connexion scheme between the I2S output of the card and the GPIO pins of RPi.

My intention is to benefit from the « analog input » feature of paid Volumio subscription to inject turntable audio in the system and correct it with FIR convolution filters before decoding in the DAC. Until now, only the digitally sourced music was benefiting from the DSP enhancement.

cheap DSP modules use most of the time low quality ADC and DAC chips with DSP limited to parametric correction, so I assume the proposed workflow should provide a higher quality output.

Thanks a lot for the connexion info you may provide.

Benoit
 
Hello Benoit
The connections are as follows From the ADC to the Pi.
VCC to 5vPWR(Pin2). ------ Mute = not connected.------- GND to GND(pin6).------ LRCK to GPIO19(pin 35).----- DATA to GPIO20(Pin 38). ------ BCLK to GPIO18(Pin 12)

Use the white jumper that ships with the board to connect MCLKin to the CLOCKout on the ADC.

_IGP2730-1024x1024.JPG

https://learn.microsoft.com/en-us/windows/iot-core/learn-about-hardware/pinmappings/pinmappingsrpi

All the best for your experiment. You will be using the DSP function to adjust for RIAA ?
 
Last edited:
Thanks for the connexion details, Drone7.
No I do not intend to RIAA compensate the raw turntable signal. I will use the turntable preamp signal (so already « RIAA reformatted ») and use CamillaDSP to correct for room and drivers irregularities.

When you digitalize your LP’s what frequency do you use : 48-96-192 KHz?

Cheers,

Benoit
 
I record at 96KHz/24Bit WAV using an RME Card in an HP thinclient and linear supply. Split to tracks with wavbreaker. Process for clicks pops and crackle with ClickRepair then adjust for levels,naming, etc in Audacity and export as .wav.
Often I can then load the resulting tracks into Musicbrainz and do a sigscan to get useful metadata and artwork. If not then I can convert to flac and try the same with beets for metadata and discogs for artwork.
 
I get the card and the connexion properly done.
Unfortunately, It seems I get stuck with a missing file preventing the script to properly compile the driver : /lib/modules/5.10.92-v7l+/build.

I followed all the steps but starting from the Debian coming with Volumio (updated and upgraded though).

Any thought? As I want the ADC to work on Volumio…

I could try anything you propose to testw

Benoit
 
Hi!
Thank you @DRONE7 for the excellent writeup! However...I'm on a RPi5 4GB running Raspberry Pi OS Bookworm 64bit and I'm getting errors.
sudo pip3 install --upgrade adafruit-python-shell
Does not work and in effect I cannot execute:
sudo python3 i2smic.py
So I opened i2smic.py and executed all commands by hand as best as possible, but I'm not getting any sound recording devices listed when I execute:
arecord -l
or
arecord -L

Can you help me out?
 
I forgot to specify the errors I was getting. So here you go:
error: externally-managed-environment


× This environment is externally managed

╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.

hint: See PEP 668 for the detailed specification.
Also, in the i2smic.py script the RPi5 is not recognized, so the script would exit if it would actually run, but this can be overcome I believe to edit the script.