This is an old revision of the document!


Audio Injector Installation

Audio Injector Stereo Soundcard and the Raspberry Zero Soundcard by Audio Injector are audio hats for the Raspberry Pi. These sound cards comes with two inputs and two outputs, plus a build in microphone.


Installation

This manual is made for an Raspberry Pi 4 running Raspian Buster on it. It's also tested with a Raspberry Pi Zero running Raspian Buster.

After connecting the Audio Injector to the Raspberry Pi some software should be installed.
First you have to download the deb package from http://forum.audioinjector.net/viewtopic.php?f=5&t=3. Unpack it:

 $ tar -xf audio.injector.scripts_0.1-1_all.deb.tar.gz

And install it:

 $ sudo apt install ./audio.injector.scripts_0.1-1_all.deb

Change some configurations, in:

 $ sudo nano /boot/config.txt

Comment out:

 # dtparam=audio=on

And type in:

 dtoverlay=audioinjector-wm8731-audio

ctl + o for saving, press return and ctl + x to leave.
Reboot your Raspberry Pi:

 $ sudo reboot


Alsa Mixer Settings

https://github.com/Audio-Injector/stereo-and-zero
There are two reference alsa mixer files which will allow you to setup default output with either line input or microphone input : Download:

 $ wget https://github.com/Audio-Injector/stereo-and-zero/archive/master.zip

Unpack it:

 $ unzip master.zip

go into the folder:

 $ cd stereo-and-zero-master/

and run:

 $ alsactl --file asound.state.MIC.thru.test restore
 $ alsactl --file asound.state.RCA.thru.test restore

Test

For the 10 kHz test follow the instructions on https://github.com/Audio-Injector/stereo-and-zero.
Then install sox:

 $ sudo apt install sox

In /home/pi/stereo-and-zero-master/ run:

 $ sudo chmod 755 audioInjector-test.sh
 $ ./audioInjector-test.sh

Simple Play and Record

Recording:

 $ arecord -r 48000 -f S16_LE -c 2 -d 20 test.wav

Playing back:

 $ aplay test.wav

I2S and I2C Pins

The following pins are used by the sound card, don't use them for anything else!
Beside the power (5V and 3V3) and ground (GND) the I2S bus needs the following pins:

 GPIO 18 (Pin12)    BIT CLOCK (BCLK);
 GPIO 19 (Pin 35)   IN and OUT LR CLOCK (DACLRC and ADCLRC);
 GPIO 20 (Pin 38)   DATA IN (ADCDAT);
 GPIO 21 (Pin 40)   DATA OUT (DACDAT);

And the I2C bus needs these pins:

 GPIO 02 (pin 03)   SDIN
 GPIO 03 (pin 05)   SCLK

graphic from: https://hifiduino.wordpress.com/2014/11/13/raspberry-pi-b-digital-audio/