Registered User No edit summary |
Registered User No edit summary |
||
Line 73: | Line 73: | ||
=== Audio record from S/PDIF input === | === Audio record from S/PDIF input === | ||
{{Warning|The support of S/PDIF input is board dependent. Please, check available inputs with "''arecord -l''" command.}} | {{Warning|The support of S/PDIF input is board dependent. Please, check available inputs with "''arecord -l''" command.}} | ||
==== Get IEC958 status bits ==== | |||
Some restrictions may apply to IEC958 control, depending on the SPDIFRX device configuration as it is explained in [[SPDIFRX device tree configuration]] and [[SPDIFRX Linux driver]] articles. | |||
{{Board$}} amixer -c STM32MP1EV cget iface=PCM,name='IEC958 Capture Default' | |||
==== Record from ALSA device ==== | ==== Record from ALSA device ==== |
Revision as of 15:30, 11 December 2019
1. Article purpose
This article explains how to record audio via the kernel ALSA audio framework in Linux® OS context. The examples below, show how to record audio from the different audio hardware interfaces of the STM32MPU boards.
2. Audio record overview
The ALSA framework exposes audio devices associated to the board audio hardware interfaces.
The application audio streams are routed by default through the PulseAudio sound server. PulseAudio exposes audio profiles, which are mapped on the ALSA sound card audio devices. The PulseAudio server provides a command line interface to list audio profiles and to select one, in order to record from a specific audio interface.
The audio record examples in following sections are based on ALSA utilities. Some input paths are configured through ALSA controls. These configurations are detailed in sound card configuration article. If an error is issued when running an example, please refer to Audio troubleshooting grid article for debug.
3. Examples
3.1. Audio record from headset microphone input
3.1.1. Record from ALSA device
Start audio record from 'record_codec' ALSA device:
arecord -D record_codec -f S16_LE -d 10 /tmp/rec.wav
3.1.2. Record via PulseAudio
3.1.2.1. For ecosystem release ≥ v1.2.0 
- Configure Pulseaudio :
Change Pulseaudio default input source to 'analog_input':
pacmd set-default-source analog_input
- Start audio record :
arecord -d 10 /tmp/rec.wav
3.1.2.2. For ecosystem release ≤ v1.1.0 
- Configure Pulseaudio :
Change Pulseaudio active profile of the sound card, to 'analog-stereo' profile:
pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
- Start audio record :
arecord -d 10 /tmp/rec.wav
3.2. Audio record from digital microphone input
3.2.1. Record from ALSA device
Start mono audio record from 'record_dfsdm0' ALSA device:
arecord -D record_dfsdm0 -r 16000 -f S32_LE -c 1 -d 10 /tmp/rec.wav
3.2.2. Record multiple digital microphones from a virtual ALSA device
Start stereo audio record from 'multi' ALSA device:
arecord -D multi -r 16000 -f S32_LE -c 2 -d 10 /tmp/rec.wav
3.2.3. Record via PulseAudio
The record via Pulseaudio is only available for ecosystem release ≥ v1.2.0 .
- Configure Pulseaudio
Change Pulseaudio default input source to 'dmic1_input':
pacmd set-default-source dmic1_input
- Start audio record :
arecord -r 48000 -f S32_LE -c 2 -d 10 /tmp/rec.wav
3.3. Audio record from S/PDIF input
3.3.1. Get IEC958 status bits
Some restrictions may apply to IEC958 control, depending on the SPDIFRX device configuration as it is explained in SPDIFRX device tree configuration and SPDIFRX Linux driver articles.
amixer -c STM32MP1EV cget iface=PCM,name='IEC958 Capture Default'
3.3.2. Record from ALSA device
Start audio record from 'record_spdif' ALSA device:
arecord -D record_spdif -f S32_LE -c 2 -r 48000 -d 10 /tmp/rec.wav
3.3.3. Record via PulseAudio
The record via Pulseaudio is only available for ecosystem release ≥ v1.2.0 .
- Configure Pulseaudio
Change Pulseaudio default input source to 'iec958_input':
pacmd set-default-source iec958_input
- Start audio record :
arecord -r 48000 -f S32_LE -c 2 -d 10 /tmp/rec.wav
4. References