Registered User mNo edit summary |
Registered User |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 11: | 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 which allows to list audio profiles and to select a profile, to play on 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 which allows to list audio profiles and to select a profile, to play on 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 playback examples in following sections are given for [[ALSA_overview#How_to_use|ALSA utilities]]. However, the audio playbacks can be launched by other applications, such as [[Gst-play|gstreamer]] multimedia framework. | The audio playback examples in following sections are given for [[ALSA_overview#How_to_use|ALSA utilities]]. However, the audio playbacks can be launched by other applications, such as [[Gst-play|gstreamer]] multimedia framework. | ||
Line 29: | Line 33: | ||
{{Info|The Pulseaudio analog-stereo profile is the default profile. So next command is not required after boot.}} | {{Info|The Pulseaudio analog-stereo profile is the default profile. So next command is not required after boot.}} | ||
{{Info|Example below is given for {{highlight|sound card index 0}}. Check sound cards index with "''pactl list cards short''" command.}} | {{Info|Example below is given for {{highlight|sound card index 0}}. Check sound cards index with "''pactl list cards short''" command.}} | ||
{{Board$}} | {{Board$}} pactl set-card-profile 0 output:analog-stereo | ||
* '''Run audio playback:''' | * '''Run audio playback:''' | ||
Line 47: | Line 51: | ||
Change the Pulseaudio active profile of the sound card, to 'hdmi-stereo' profile: | Change the Pulseaudio active profile of the sound card, to 'hdmi-stereo' profile: | ||
{{Info|Example below is given for {{highlight|sound card index 0}}. Check sound card index with "''pactl list cards short''" command.}} | {{Info|Example below is given for {{highlight|sound card index 0}}. Check sound card index with "''pactl list cards short''" command.}} | ||
{{Board$}} | {{Board$}} pactl set-card-profile 0 output:hdmi-stereo | ||
* '''Run audio playback:''' | * '''Run audio playback:''' | ||
Line 70: | Line 74: | ||
Change the sound card active profile, to S/PDIF 'iec958-stereo' profile. | Change the sound card active profile, to S/PDIF 'iec958-stereo' profile. | ||
{{Info|Example below is given for {{highlight|sound card index 0}}. Check sound card index with "''pactl list cards short''" command.}} | {{Info|Example below is given for {{highlight|sound card index 0}}. Check sound card index with "''pactl list cards short''" command.}} | ||
{{Board$}} | {{Board$}} pactl set-card-profile 0 output:iec958-stereo | ||
* '''Run audio playback:''' | * '''Run audio playback:''' |
Latest revision as of 13:46, 8 June 2022
1. Article purpose[edit source]
This article explains how to play audio through the ALSA audio framework in Linux® OS context. The examples below, show how to play audio on the different audio hardware interfaces of the STM32MPU boards.
2. Audio playback overview[edit source]
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 which allows to list audio profiles and to select a profile, to play on a specific audio interface.
The audio playback examples in following sections are given for ALSA utilities. However, the audio playbacks can be launched by other applications, such as gstreamer multimedia framework.
3. Examples[edit source]
3.1. Audio playback on headset output[edit source]
3.1.1. Playback on ALSA device[edit source]
Run audio playback on 'playback_codec' ALSA device:
Board $> aplay -D playback_codec /usr/share/sounds/alsa/Front_Left.wav
3.1.2. Playback via PulseAudio[edit source]
- Configure Pulseaudio
Change the Pulseaudio active profile of the sound card, to 'analog-stereo' profile:
Board $> pactl set-card-profile 0 output:analog-stereo
- Run audio playback:
Board $> aplay /usr/share/sounds/alsa/Front_Left.wav
3.2. Audio playback on HDMI output[edit source]
3.2.1. Playback on ALSA device[edit source]
Run audio playback on 'playback_hdmi' ALSA device:
Board $> aplay -D playback_hdmi /usr/share/sounds/alsa/Front_Left.wav
3.2.2. Playback via PulseAudio[edit source]
- Configure Pulseaudio
Change the Pulseaudio active profile of the sound card, to 'hdmi-stereo' profile:
Board $> pactl set-card-profile 0 output:hdmi-stereo
- Run audio playback:
Board $> aplay /usr/share/sounds/alsa/Front_Left.wav
3.3. Audio playback on S/PDIF output[edit source]
3.3.1. Set IEC958 status bits[edit source]
Example: set IEC958 mode bit.
Board $> iecset -c STM32MP1EV -n device=0 pro on
3.3.2. Playback on ALSA device[edit source]
Run audio playback on 'playback_spdif' ALSA device:
Board $> speaker-test -D playback_spdif -c 2 -F S32_LE -f 440 -t sine -l 1
3.3.3. Playback via PulseAudio[edit source]
- Configure Pulseaudio
Change the sound card active profile, to S/PDIF 'iec958-stereo' profile.
Board $> pactl set-card-profile 0 output:iec958-stereo
- Run audio playback:
Board $> speaker-test -c 2 -F S32_LE -f 440 -t sine -l 1