Skip to content
Frank Bauernöppel edited this page Jan 12, 2019 · 9 revisions

Raspi3 has an analog audio output. Digital audio output is also possible via HDMI connector.

Test audio output using gstreamer:

root@raspberrypi3:~# gst-launch-1.0 audiotestsrc ! omxanalogaudiosink
root@raspberrypi3:~# gst-launch-1.0 audiotestsrc !  omxhdmiaudiosink

Or, you "redirect" the audio to video output:

root@raspberrypi3:~# gst-launch-1.0 audiotestsrc ! spectrascope ! autovideosink

ALSA

ALSA can be used if your image was build with alsa in the DISTRO_FEATURES.

It comes with handy tools for recording and playing audio. It also enables low-level access to sound data buffers in a C prog for audio analysis etc..

audio source

Raspi has no built-in audio source. Many USB UVC Webcams come with a mike and there are special USB audio mikes available. Other solutions like audio HAT boards are not discussed here.

With USB UVC Webcam attached:

list audio devices

cat /proc/asound/cards
 0 [CinemaTM       ]: USB-Audio - Microsoft® LifeCam Cinema(TM)
                      Microsoft Microsoft® LifeCam Cinema(TM) at usb-3f980000.usb-1.2, high speed
root@raspberrypi3:~/test-launch# arecord --list-devices
**** List of CAPTURE Hardware Devices ****
card 0: CinemaTM [Microsoft® LifeCam Cinema(TM)], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

test recording for 10 seconds

arecord -d 10 test.wav

a more complex recording example if more than one audio source is present:

arecord --device=hw:1,0 --channels=1 --format=S16_LE --rate=48000 --duration 10 --vumeter=mono rec.wav

1 is the sound card number and 0 the sound device on that card. See also https://www.alsa-project.org/main/index.php/DeviceNames

audio sink

Raspi has a simple on-board analog audio output. To activate this, dtparam=audio=on must be set in config.txt

A simple test is

speaker-test

You may also playback the recorded sound:

aplay rec.wav

More Info

Clone this wiki locally