Registered User mNo edit summary |
Registered User mNo edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude>{{ApplicableFor | |||
|MPUs list=STM32MP13x, STM32MP15x | |||
|MPUs checklist=STM32MP13x,STM32MP15x | |||
}}</noinclude> | |||
== Article purpose == | == Article purpose == | ||
This article explains how to record audio via the kernel [[ALSA overview|ALSA]] audio framework in '''Linux® OS''' context. | This article explains how to record audio via the kernel [[ALSA overview|ALSA]] audio framework in '''Linux® OS''' context. | ||
Line 7: | Line 11: | ||
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 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. | ||
{{Warning|The applications interacting with Weston framework have to be launched as "Weston" user instead of "root" user. The Pulseaudio commands can, for instance, be launched as follows: | |||
su -l "weston" -c "pactl info" | |||
}} | |||
The audio record examples in following sections are based on [[ALSA_overview#How_to_use|ALSA utilities]]. Some input paths are configured through ALSA controls. These configurations are detailed in [[Soundcard_configuration|sound card configuration]] article. If an error is issued when running an example, please refer to [[Audio troubleshooting grid]] article for debug. | The audio record examples in following sections are based on [[ALSA_overview#How_to_use|ALSA utilities]]. Some input paths are configured through ALSA controls. These configurations are detailed in [[Soundcard_configuration|sound card configuration]] article. If an error is issued when running an example, please refer to [[Audio troubleshooting grid]] article for debug. | ||
Line 25: | Line 33: | ||
Change Pulseaudio default input source to 'analog_input': | Change Pulseaudio default input source to 'analog_input': | ||
{{Info|The Pulseaudio analog_input is defined in /etc/pulse/system.pa configuration file.}} | {{Info|The Pulseaudio analog_input is defined in /etc/pulse/system.pa configuration file.}} | ||
{{Board$}} | {{Board$}} pactl set-default-source analog_input | ||
* '''Start audio record :''' | * '''Start audio record :''' | ||
Line 49: | Line 57: | ||
Change Pulseaudio default input source to 'dmic1_input': | Change Pulseaudio default input source to 'dmic1_input': | ||
{{Info|The Pulseaudio dmic1_input is defined in /etc/pulse/system.pa configuration file.}} | {{Info|The Pulseaudio dmic1_input is defined in /etc/pulse/system.pa configuration file.}} | ||
{{Board$}} | {{Board$}} pactl set-default-source dmic1_input | ||
* '''Start audio record :''' | * '''Start audio record :''' | ||
Line 74: | Line 82: | ||
Change Pulseaudio default input source to 'iec958_input': | Change Pulseaudio default input source to 'iec958_input': | ||
{{Info|The Pulseaudio iec958_input is defined in /etc/pulse/system.pa configuration file.}} | {{Info|The Pulseaudio iec958_input is defined in /etc/pulse/system.pa configuration file.}} | ||
{{Board$}} | {{Board$}} pactl set-default-source iec958_input | ||
* '''Start audio record :''' | * '''Start audio record :''' |
Latest revision as of 12:35, 8 June 2022
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 applications interacting with Weston framework have to be launched as "Weston" user instead of "root" user. The Pulseaudio commands can, for instance, be launched as follows:
su -l "weston" -c "pactl info"
|
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:
File:Info.png | 'record_codec' is an alias defined in /etc/asound.conf, for headset microphone input device. |
Board $> arecord -D record_codec -f S16_LE -d 10 /tmp/rec.wav
3.1.2. Record via PulseAudio
- Configure Pulseaudio :
Change Pulseaudio default input source to 'analog_input':
File:Info.png | The Pulseaudio analog_input is defined in /etc/pulse/system.pa configuration file. |
Board $> pactl set-default-source analog_input
- Start audio record :
File:Info.png | The Pulseaudio device is the default one, so "-D pulse" option can be omitted in the record command. |
Board $> arecord -d 10 /tmp/rec.wav
3.2. Audio record from digital microphone input
![]() |
The support of digital microphone input is board dependent. Please, check available inputs with "arecord -l" command. |
3.2.1. Record from ALSA device
Start mono audio record from 'record_dfsdm0' ALSA device:
File:Info.png | 'record_dfsdm0' is an alias defined in /etc/asound.conf, for digital microphone U1 input device. |
Board $> 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:
File:Info.png | 'multi' device, based on ALSA multi plugin[1], has to be defined in /etc/asound.conf file. |
Board $> arecord -D multi -r 16000 -f S32_LE -c 2 -d 10 /tmp/rec.wav
3.2.3. Record via PulseAudio
- Configure Pulseaudio
Change Pulseaudio default input source to 'dmic1_input':
File:Info.png | The Pulseaudio dmic1_input is defined in /etc/pulse/system.pa configuration file. |
Board $> pactl set-default-source dmic1_input
- Start audio record :
File:Info.png | The Pulseaudio device is the default one, so "-D pulse" option can be omitted in the record command. |
Board $> arecord -r 48000 -f S32_LE -c 2 -d 10 /tmp/rec.wav
3.3. Audio record from S/PDIF input
![]() |
The support of S/PDIF input is board dependent. Please, check available inputs with "arecord -l" command. |
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.
Board $> 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:
File:Info.png | 'record_spdif' is an alias defined in /etc/asound.conf, for S/PDIF input device. |
File:Info.png | A S/PDIF signal must be available on S/PDIF RCA input connector before starting the record command. The record rate must be set according to S/PDIF signal sampling rate. |
Board $> arecord -D record_spdif -f S32_LE -c 2 -r 48000 -d 10 /tmp/rec.wav
3.3.3. Record via PulseAudio
- Configure Pulseaudio
Change Pulseaudio default input source to 'iec958_input':
File:Info.png | The Pulseaudio iec958_input is defined in /etc/pulse/system.pa configuration file. |
Board $> pactl set-default-source iec958_input
- Start audio record :
File:Info.png | The Pulseaudio device is the default one, so "-D pulse" option can be omitted in the record command. |
Board $> arecord -r 48000 -f S32_LE -c 2 -d 10 /tmp/rec.wav
4. References