DAC - mxmxmx/terminal_tedium GitHub Wiki
#testing the codec / setting up the PCM5102a (or wm8731)
to set up the codec, either run the install.sh script or do it manually, specifically:
1) /boot/config.txt
- make sure you've added the codec device tree overlay to
/boot/config.txt
(see here)
2) asound.conf
- configure
/etc/asound.conf
:
sudo nano /etc/asound.conf
- then add:
pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}
- save.
3) amixer
- if/when using wm8731, open alsamixer and unmute "Output Mixer HiFi Playback Switch" manually. or do:
amixer cset numid=13 on
- which should result in:
numid=13,iface=MIXER,name='Output Mixer HiFi Playback Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
-
(also double-check the master-volume and ADC settings: run
amixer
and look out forMaster Playback Volume
,Line Capture Switch
, andCapture Volume
). alternatively, runalsamixer
, presstab
to go the capture settings and selectLine
(first select the column sayingLine
, then press the space bar). -
store the settings:
alsactl store
4) aplay/test
- reboot. running
aplay -l
you should now see:
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0
- or corresponding message for wm8731:
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpiproto [snd_rpi_proto], device 0: WM8731 HiFi wm8731-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
- if that's not what you see (but some additional cards), blacklist the onboard audio: create a file called raspi-blacklist.conf in
/etc/modprobe.d/
(if it's not already there) and add this line:
blacklist snd_bcm2835
- reboot.
5) play test wav
-
let's test the DAC is working. move a wav file (stereo, 16 bit/44.1kHz) onto your rpi/odroid (with scp, say). plug a patchcable(s) into the L and/or R outputs.
-
run
aplay /path_to_file/file.wav
. you should see this:
Playing WAVE 'file.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
. -
respectively
Playing WAVE 'file.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
.
-
... more importantly, you should also hear some sound, nice and clean, from both the L and R outputs
-
alternatively, use the speaker-test app, eg.
speaker-test -t sine -f 440 -c 2 -Dplug:sysdefault
; that should result in a 440Hz test tone sent to the left and right outputs, alternatingly.
6) testing the ADC (wm8731 only)
-
make sure you've got the alsa settings right (see above, #3), and you have the patch called passthru.pd ready.
-
start the patch: eg.
sudo pd -rt -r 48000 -nogui passthru.pd
. this is basically just feeding the signal through pd (plus some high-pass and attenuation): -
now, feed a signal into the left input, say a sine wave; as there's no onboard attenuation, typically it'll make sense to use an attenuator such as A183-1. the signal should be present at both the left and right outputs (R_in is normalled to L_in); next, the right input (in which case the signal should be present at R_out only). it shouldn't clip and not look distorted (when you look at it with, say, a scope).
-
alternatively, to inspect things, you can record the input signal with
arecord
. e.g.arecord -f dat -vvv test.wav
; record it for a few seconds, then play the file withaplay test.wav
(and listen to it / look at it with a scope / inspect the recording in your DAW). you can also record/loopback the output signal. for instance, say you have prepared a file called sinetest.wav. then run a cable from the left output back into the left input and doarecord -f dat -vvv test.wav | aplay -Dplug:default sinetest.wav
.aplay test.wav
will play the recording.