播放、录制和配置音频流。
重要提示
audio-driver-ctl 已被弃用。请改用 ffx audio device 工具。如需了解详情,
请在宿主机上运行 ffx audio device --help,并参阅
ffx audio 的自述文件://src/developer/ffx/plugins/audio/README.md
用法
audio-driver-ctl [-d <id>] [-t (input|output)] agc (on|off)
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] duplex <playpath> <recordpath>
audio-driver-ctl [-d <id>] [-t (input|output)] gain <decibels>
audio-driver-ctl [-d <id>] [-t (input|output)] info
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] loop <playpath>
audio-driver-ctl [-d <id>] [-t (input|output)] mute
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] noise [<seconds>] [<amplitude>]
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] play <playpath>
audio-driver-ctl [-d <id>] [-t (input|output)] pmon [<seconds>]
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] record <recordpath> [<seconds>]
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] tone [<frequency>] [<seconds>] [<amplitude>
audio-driver-ctl [-d <id>] [-t (input|output)] unmute
选项
-a <mask>
活动通道掩码。例如,对于通道 0、1、2 和 3,使用 0xf 或 15。
默认值为所有通道。
-b (8|16|20|24|32)
每个样本的比特数。默认值为 16。
-c <channels>
录制或生成音调/噪声时要使用的通道数。
这不会影响 WAV 文件播放,因为 WAV 文件会在其标头中指定要使用的通道数。默认值为驱动程序报告的第一个值。运行 info 可查看目标 Fuchsia 设备
有多少个通道。通道数必须与音频驱动程序预期的通道数一致,因为 audio-driver-ctl 不会进行任何混音。
-d <id>
数据流的设备节点 ID。默认值为 0。如需确定 <id>,请运行
info。您会看到类似 /dev/class/audio-input/000 的路径值。
<id> 在此示例中为 000。
-t (input|output)
设备类型。默认值为 output。对于仅对其中一种类型有意义的命令(例如
play),系统会忽略此选项。
-r <hertz>
帧速率(以赫兹为单位)。默认值为 48000。
命令
agc
audio-driver-ctl [-d <id>] [-t (input|output)] agc (on|off)
启用或停用数据流的自动增益控制。
duplex
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] duplex <playpath> <recordpath>
同时播放位于 <playpath> 的 WAV 文件,并将
另一个 WAV 文件录制到 <recordpath> 中,以便分析系统中的
延迟。如果提供了 -c 选项,则该选项适用于录制端,因为播放的通道数取自 WAV 文件标头。
gain
audio-driver-ctl [-d <id>] [-t (input|output)] gain <decibels>
设置数据流的增益(以分贝为单位)。
info
audio-driver-ctl [-d <id>] [-t (input|output)] info
获取数据流的功能和状态信息。
loop
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] loop <playpath>
在选定的输出上重复播放 <playpath> 中的 WAV 文件,直到按下某个键
为止。
mute
audio-driver-ctl [-d <id>] [-t (input|output)] mute
将数据流静音。
noise
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] noise [<seconds>] [<amplitude>]
播放伪白噪声。<seconds> 用于控制噪声的播放时长,且必须
至少为 0.001 秒。如果未提供 <seconds>,则噪声会一直播放,直到
按下某个键为止。
play
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] play <playpath>
播放 WAV 文件。
pmon
audio-driver-ctl [-d <id>] [-t (input|output)] pmon [<seconds>]
监控数据流的插拔状态。<seconds> 必须大于 0.5 秒
(默认值:10.0 秒)。
record
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] record <recordpath> [<seconds>]
从选定的输入录制到指定的 WAV 文件。如果未提供 <seconds>,则输入会一直录制,直到按下某个键为止。
tone
audio-driver-ctl [-a <mask>] [-b (8|16|20|24|32)] [-c <channels>] \
[-d <id>] [-r <hertz>] tone [<frequency>] [<seconds>] [<amplitude>
播放正弦音调。<frequency> 必须介于 15.0 和 96000.0 赫兹之间
(默认值:440.0 赫兹)。<seconds> 必须大于 0.001 秒。如果未提供 <amplitude> 如果提供了,则该值会缩放
输出,且必须是介于 0.1 和 1.0 之间的 0.1 的增量。
unmute
audio-driver-ctl [-d <id>] [-t (input|output)] unmute
取消数据流的静音。请注意,数据流的增益将重置为其默认值。
示例
对数据流启用自动增益控制
$ audio-driver-ctl agc on
获取数据流信息
# Equivalent to `audio-driver-ctl -t output -d 000 info`
$ audio-driver-ctl info
Info for audio output at \"/dev/class/audio-output/000\"
Unique ID : 0100000000000000-0000000000000000
Manufacturer : Spacely Sprockets
Product : acme
Current Gain : 0.00 dB (unmuted, AGC on)
Gain Caps : gain range [-103.00, 24.00] in 0.50 dB steps; can mute; can AGC
Plug State : plugged
Plug Time : 12297829382473034410
PD Caps : hardwired
Number of channels : 1
Frame rate : 8000Hz
Bits per channel : 16
Valid bits per channel : 16
...
将数据流的增益设置为 -40 分贝
# Equivalent to `audio-driver-ctl -t output -d 000 gain -40`
$ audio-driver-ctl gain -40
将数据流静音
# Equivalent to `audio-driver-ctl -t output -d 000 mute`
$ audio-driver-ctl mute
在数据流上重复播放(循环)WAV 文件
# Equivalent to `audio-driver-ctl -t output -d 000 loop /tmp/test.wav`
$ audio-driver-ctl loop /tmp/test.wav
Looping /tmp/test.wav until a key is pressed
在数据流上播放一次 WAV 文件
# Equivalent to `audio-driver-ctl -t output -d 000 play /tmp/test.wav`
$ audio-driver-ctl play /tmp/test.wav
在数据流上以 50% 的振幅播放 450 赫兹的音调 1 秒
# Equivalent to `audio-driver-ctl -t output -d 000 tone 450 1 0.5`
$ audio-driver-ctl tone 450 1 0.5
Playing 450.00 Hz tone for 1.00 seconds at 0.50 amplitude
取消数据流的静音
# Equivalent to `audio-driver-ctl -t output -d 000 unmute`
audio-driver-ctl unmute
备注
访问此命令
此命令仅适用于某些诊断和测试 Fuchsia build。
这是一个设备端命令,而不是 fx 或 ffx 等主机端命令。
换句话说,在调用此命令之前,您必须先访问 Fuchsia 设备的 shell。
如需以交互方式访问 Fuchsia 设备的 shell,请执行以下操作:
ffx component explore <component>
将 <component> 替换为有权访问
此页面上记录的命令的组件的名称。
如需调用单个命令并将输出返回到主机,请执行以下操作:
ffx component explore <component> -c "<command>"
将 <command> 替换为此页面上记录的其中一个命令。
支持执行数据流的命令的 build
执行音频流的命令(例如 play)仅在诊断
in diagnosticcore在其他 build 中,仅支持信息性命令(例如 info)。
在主机和目标 Fuchsia 设备之间复制 WAV 文件
如需将 WAV 文件从主机复制到目标 Fuchsia 设备,或
反之,请在主机上运行 fx cp (--to-target|--to-host) <source> <destination>
。<source> 是您要复制的文件,<destination>
是您要放置复制文件的位置。
从主机复制到目标 Fuchsia 设备的示例:
$ fx cp --to-target /path/on/host/source.wav /path/on/target/destination.wav
从目标 Fuchsia 设备复制到主机的示例:
$ fx cp --to-host /path/on/target/source.wav /path/on/host/destination.wav
这两个命令都应在主机上运行,而不是在目标 Fuchsia 设备上运行。
源代码
audio-driver-ctl 的源代码://src/media/audio/tools/audio-driver-ctl/