匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“How to record audio”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
如何录制音频
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
== Article purpose == This article explains how to record audio via the kernel [[ALSA overview|ALSA]] audio framework in '''Linux® OS''' context. The examples below, show how to record audio from the different audio hardware interfaces of the STM32MPU [[:Category:ST boards| boards]]. == Audio record 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 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_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. == Examples == === Audio record from headset microphone input === ==== Record from ALSA device ==== Start audio record from 'record_codec' ALSA device: {{Info|'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 ==== Record via PulseAudio ==== ===== For {{EcosystemRelease | revision=1.2.0 | range=and after}} ===== * '''Configure Pulseaudio :''' Change Pulseaudio default input source to 'analog_input': {{Info|The Pulseaudio analog_input is defined in /etc/pulse/system.pa configuration file.}} {{Board$}} pacmd set-default-source analog_input * '''Start audio record :''' {{Info|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 <div class="mw-collapsible mw-collapsed"> ===== For {{EcosystemRelease | revision=1.1.0 | range=and before}} ===== <div class="mw-collapsible-content"> * '''Configure Pulseaudio :''' Change Pulseaudio active profile of the sound card, to 'analog-stereo' profile: {{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 * '''Start audio record :''' {{Info|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 </div></div> === Audio record from digital microphone input === {{Warning|The support of digital microphone input is board dependent. Please, check available inputs with "''arecord -l''" command.}} ==== Record from ALSA device ==== Start mono audio record from 'record_dfsdm0' ALSA device: {{Info|'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 ==== Record multiple digital microphones from a virtual ALSA device ==== Start stereo audio record from 'multi' ALSA device: {{Info|'multi' device, based on ALSA multi plugin<ref>[https://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html| ALSA PCM plugins]</ref>, 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 ==== Record via PulseAudio ==== The record via Pulseaudio is only available for {{EcosystemRelease | revision=1.2.0 | range=and after}}. * '''Configure Pulseaudio''' Change Pulseaudio default input source to 'dmic1_input': {{Info|The Pulseaudio dmic1_input is defined in /etc/pulse/system.pa configuration file.}} {{Board$}} pacmd set-default-source dmic1_input * '''Start audio record :''' {{Info|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 === Audio record from S/PDIF input === {{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 ==== Start audio record from 'record_spdif' ALSA device: {{Info|'record_spdif' is an alias defined in /etc/asound.conf, for S/PDIF input device.}} {{Info|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 ==== Record via PulseAudio ==== The record via Pulseaudio is only available for {{EcosystemRelease | revision=1.2.0 | range=and after}}. * '''Configure Pulseaudio''' Change Pulseaudio default input source to 'iec958_input': {{Info|The Pulseaudio iec958_input is defined in /etc/pulse/system.pa configuration file.}} {{Board$}} pacmd set-default-source iec958_input * '''Start audio record :''' {{Info|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 == References == <references /> <noinclude> {{PublicationRequestId | 10588 | 2019-02-06}} [[Category:How to run use cases]] [[Category:ALSA]] </noinclude>
返回至
如何录制音频
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志