Close

Audio capture & playback

A project log for Wandboard experiments

Setting up the WBQUAD

christoph-tackChristoph Tack 08/12/2020 at 14:010 Comments

Command line tools

Installation

sudo apt install alsa-utils

Audio playback

We want to route audio to the line-out.  In order to do that, let's find out what the possible output devices are.

ubuntu@wandboard:~$ aplay -L 
null
    Discard all samples (playback) or generate zero samples (capture)
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
default:CARD=DWHDMI
    DW-HDMI, dw-hdmi-ahb-audio
    Default Audio Device
sysdefault:CARD=DWHDMI
    DW-HDMI, dw-hdmi-ahb-audio
    Default Audio Device
dmix:CARD=DWHDMI,DEV=0
    DW-HDMI, dw-hdmi-ahb-audio
    Direct sample mixing device
dsnoop:CARD=DWHDMI,DEV=0
    DW-HDMI, dw-hdmi-ahb-audio
    Direct sample snooping device
hw:CARD=DWHDMI,DEV=0
    DW-HDMI, dw-hdmi-ahb-audio
    Direct hardware device without any conversions
plughw:CARD=DWHDMI,DEV=0
    DW-HDMI, dw-hdmi-ahb-audio
    Hardware device with all software conversions
usbstream:CARD=DWHDMI
    DW-HDMI
    USB Stream Output
default:CARD=imxspdif
    imx-spdif, S/PDIF PCM snd-soc-dummy-dai-0
    Default Audio Device
sysdefault:CARD=imxspdif
    imx-spdif, S/PDIF PCM snd-soc-dummy-dai-0
    Default Audio Device
dmix:CARD=imxspdif,DEV=0
    imx-spdif, S/PDIF PCM snd-soc-dummy-dai-0
    Direct sample mixing device
dsnoop:CARD=imxspdif,DEV=0
    imx-spdif, S/PDIF PCM snd-soc-dummy-dai-0
    Direct sample snooping device
hw:CARD=imxspdif,DEV=0
    imx-spdif, S/PDIF PCM snd-soc-dummy-dai-0
    Direct hardware device without any conversions
plughw:CARD=imxspdif,DEV=0
    imx-spdif, S/PDIF PCM snd-soc-dummy-dai-0
    Hardware device with all software conversions
usbstream:CARD=imxspdif
    imx-spdif
    USB Stream Output
default:CARD=imx6wandboardsg
    imx6-wandboard-sgtl5000, HiFi sgtl5000-0
    Default Audio Device
sysdefault:CARD=imx6wandboardsg
    imx6-wandboard-sgtl5000, HiFi sgtl5000-0
    Default Audio Device
dmix:CARD=imx6wandboardsg,DEV=0
    imx6-wandboard-sgtl5000, HiFi sgtl5000-0
    Direct sample mixing device
dsnoop:CARD=imx6wandboardsg,DEV=0
    imx6-wandboard-sgtl5000, HiFi sgtl5000-0
    Direct sample snooping device
hw:CARD=imx6wandboardsg,DEV=0
    imx6-wandboard-sgtl5000, HiFi sgtl5000-0
    Direct hardware device without any conversions
plughw:CARD=imx6wandboardsg,DEV=0
    imx6-wandboard-sgtl5000, HiFi sgtl5000-0
    Hardware device with all software conversions
usbstream:CARD=imx6wandboardsg
    imx6-wandboard-sgtl5000
    USB Stream Output

Mixer settings

  1. Run "alsamixer"
  2. F6: select sound card → imx6-wandboard-sgtl5000
  3. Headphone Mux : DAC
  4. Use "Headphon" to set audio output level on line-out.  The line-out setting in alsamixer doesn't control line-out.

Storing sound settings with "alsactl store" gives an error message. 

Let's play a wav-file now using hw:CARD=imx6wandboardsg,DEV=0 if we would use plughw:CARD=imx6wandboardsg,DEV=0 ve9qrp.wav, then the mono audio from the file will be sent only to the left or right channel of line-out.

ubuntu@wandboard:~$ aplay -D hw:CARD=imx6wandboardsg,DEV=0 ve9qrp.wav 
Playing WAVE 've9qrp.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono

The mono-wav file will be output to the left and right channel of line-out.

Audio recording

By default audio will be recorded from MIC_IN.  To record from LINE_IN, the capture multiplexer (mux) must first be adjusted:

ubuntu@wandboard:~$ amixer -c 2 cset name='Capture Mux' 1
numid=24,iface=MIXER,name='Capture Mux'
  ; type=ENUMERATED,access=rw------,values=1,items=2
  ; Item #0 'MIC_IN'
  ; Item #1 'LINE_IN'
  : values=1

After that, recording 5s of audio from line-in is as simple as:

ubuntu@wandboard:~$ arecord -D default:CARD=imx6wandboardsg -d 5 -f S16_LE -c 2 -r 48000 output.wav
Recording WAVE 'output.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

Python

see Python audio capture & playback

Discussions