播放、录制和配置音频流。
重要提示
audio-driver-ctl
已被弃用。请改用 ffx audio device
工具。如需了解详情,请从宿主机运行 ffx audio device --help
,并参阅 ffx audio
的 README://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
仅在诊断模式下支持使用 core
等命令来操控音频串流。play
在其他 build 中,仅支持 info
等信息性命令。
在主机和目标 Fuchsia 设备之间复制 WAV 文件
如需将 WAV 文件从主机复制到目标 Fuchsia 设备,或将 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/