匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“How to play audio”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
How to play audio
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
== Article purpose == This article explains how to play audio through the [[ALSA overview|ALSA]] audio framework in '''Linux<sup>®</sup> OS''' context. The examples below, show how to play audio on the different audio hardware interfaces of the STM32MPU [[:Category:ST boards| boards]]. == Audio playback overview == The [[ALSA overview|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_overview#How_to_use|ALSA utilities]]. However, the audio playbacks can be launched by other applications, such as [[Gst-play|gstreamer]] multimedia framework. == Examples == === Audio playback on headset output === ==== Playback on ALSA device ==== Run audio playback on 'playback_codec' ALSA device: {{Info|'playback_codec' is an alias defined in /etc/asound.conf, for headset output device.}} {{Board$}} aplay -D playback_codec /usr/share/sounds/alsa/Front_Left.wav ==== Playback via PulseAudio ==== * '''Configure Pulseaudio''' Change the Pulseaudio active profile of the sound card, to 'analog-stereo' profile: {{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.}} {{Board$}} pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo * '''Run audio playback:''' {{Board$}} aplay /usr/share/sounds/alsa/Front_Left.wav === Audio playback on HDMI output === {{Warning|The support of HDMI output is board dependent. Please, check available outputs with "''aplay -l''" command.}} ==== Playback on ALSA device ==== Run audio playback on 'playback_hdmi' ALSA device: {{Info|'playback_hdmi' is an alias defined in /etc/asound.conf, for hdmi output device.}} {{Board$}} aplay -D playback_hdmi /usr/share/sounds/alsa/Front_Left.wav ==== Playback via PulseAudio ==== * '''Configure Pulseaudio''' 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.}} {{Board$}} pacmd set-card-profile 0 output:hdmi-stereo * '''Run audio playback:''' {{Board$}} aplay /usr/share/sounds/alsa/Front_Left.wav === Audio playback on S/PDIF output === {{Warning|The support of S/PDIF output is board dependent. Please, check available outputs with "''aplay -l''" command.}} {{Info|S/PDIF ALSA device supports only {{highlight|32-bit audio streams}}. As 32-bit wave files are not provided in sample sound files, speaker-test is used instead of aplay, for convenience, here. Speaker-test generates a 440Hz sine wave in following examples.}} ==== Set IEC958 status bits ==== Example: set IEC958 mode bit. {{Board$}} iecset -c STM32MP1EV -n device=0 pro on ==== Playback on ALSA device ==== Run audio playback on 'playback_spdif' ALSA device: {{Info|'playback_spdif' is an alias defined in /etc/asound.conf, for S/PDIF output device.}} {{Board$}} speaker-test -D playback_spdif -c 2 -F S32_LE -f 440 -t sine -l 1 ==== Playback via PulseAudio ==== * '''Configure Pulseaudio''' 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.}} {{Board$}} pacmd set-card-profile 0 output:iec958-stereo * '''Run audio playback:''' {{Board$}} speaker-test -c 2 -F S32_LE -f 440 -t sine -l 1 <noinclude> {{PublicationRequestId | 10391 | 2019-01-21}} [[Category:How to run use cases]] [[Category:ALSA]] </noinclude>
该页面使用的模板:
模板:Board$
(
查看源代码
)
模板:Highlight
(
查看源代码
)
模板:Info
(
查看源代码
)
模板:STDarkBlue
(
查看源代码
)
模板:STPink
(
查看源代码
)
模板:Warning
(
查看源代码
)
返回至
How to play audio
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志