播放、录制和配置音频流。
重要提示
audio-driver-ctl 已被弃用。请改用 ffx audio device 工具。如需了解详情,
请在宿主机上运行 ffx audio device --help,并参阅
ffx audio 的自述文件://src/developer/ffx/plugins/audio/README.md
用法
audio-driver-ctl [-d <device>] [-t {input|output}] agc {on|off}
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-r <hertz>] duplex <playpath> <recordpath>
audio-driver-ctl [-d <device>] [-t {input|output}] gain <decibels>
audio-driver-ctl [-d <device>] [-t {input|output}] info
audio-driver-ctl list
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] loop <playpath>
audio-driver-ctl [-d <device>] [-t {input|output}] mute
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-r <hertz>] noise [<seconds>] [<amplitude>]
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] play <playpath>
audio-driver-ctl [-d <device>] [-t {input|output}] pmon [<seconds>]
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-r <hertz>] record <recordpath> [<seconds>]
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-r <hertz>] tone [<frequency>] [<seconds>] [<amplitude>]
audio-driver-ctl [-d <device>] [-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 <device> 选项
设备路径或服务实例名称。如果未指定,该工具会选择找到的第一个设备。如果它不包含 /,该工具会将其视为服务实例
名称(例如,default -> /svc/.../default/stream_config_connector)。
-t {input|output} 选项
设备类型。默认值为 output。对于仅对其中一种类型有意义的命令(例如
play),此选项会被忽略。
-r <hertz> 选项
帧速率(以赫兹为单位)。默认值为 48000。
命令
agc 命令
audio-driver-ctl [-d <device>] [-t {input|output}] agc {on|off}
为数据流启用或停用自动增益控制。
duplex 命令
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-r <hertz>] duplex <playpath> <recordpath>
同时播放位于 <playpath> 的 WAV 文件,并将
另一个 WAV 文件录制到 <recordpath> 中,以分析系统中的
延迟。如果提供了 -c 选项,则该选项适用于录制端,因为 WAV 文件标头决定了播放的渠道数。对于双工模式,-d 参数必须是实例名称,而不能是完整路径。
gain 命令
audio-driver-ctl [-d <device>] [-t {input|output}] gain <decibels>
设置数据流的增益(以分贝为单位)。
info 命令
audio-driver-ctl [-d <device>] [-t {input|output}] info
获取数据流的功能和状态信息。
list 命令
audio-driver-ctl list
列出所有可用的输入和输出设备。
loop 命令
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] loop <playpath>
在选定的输出上重复播放 <playpath> 中的 WAV 文件,直到按下某个键
为止。
mute 命令
audio-driver-ctl [-d <device>] [-t {input|output}] mute
将数据流静音。
noise 命令
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-r <hertz>] noise [<seconds>] [<amplitude>]
播放伪白噪声。<seconds> 控制噪声的播放时长,且必须
至少为 0.001 秒。如果未提供 <seconds>,则噪声会一直播放,直到
按下某个键为止。
play 命令
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] play <playpath>
播放 WAV 文件。
pmon 命令
audio-driver-ctl [-d <device>] [-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 <device>] [-r <hertz>] record <recordpath> [<seconds>]
从选定的输入录制到指定的 WAV 文件。如果未提供 <seconds>,则输入会一直录制,直到按下某个键为止。
tone 命令
audio-driver-ctl [-a <mask>] [-b {8|16|20|24|32}] [-c <channels>] \
[-d <device>] [-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 <device>] [-t {input|output}] unmute
取消数据流的静音。请注意,数据流的增益将重置为其默认值。
示例
为数据流启用自动增益控制
audio-driver-ctl agc on获取数据流信息
此命令等效于 audio-driver-ctl -t output -d default info:
audio-driver-ctl infoInfo for audio output at "/svc/fuchsia.hardware.audio.StreamConfigConnectorOutputService/default/stream_config_connector"
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
...
列出所有可用的输入和输出设备
audio-driver-ctl listInput Devices:
default
Output Devices:
default
将数据流的增益设置为 -40 分贝
此命令等效于 audio-driver-ctl -t output -d default gain -40:
audio-driver-ctl gain -40将数据流静音
此命令等效于 audio-driver-ctl -t output -d default mute:
audio-driver-ctl mute在数据流上重复播放(循环)WAV 文件
此命令等效于 audio-driver-ctl -t output -d default loop /tmp/test.wav:
audio-driver-ctl loop /tmp/test.wavLooping /tmp/test.wav until a key is pressed
在数据流上播放一次 WAV 文件
此命令等效于 audio-driver-ctl -t output -d default play /tmp/test.wav:
audio-driver-ctl play /tmp/test.wav在数据流上以 50% 的振幅播放 450 赫兹的音调 1 秒
此命令等效于 audio-driver-ctl -t output -d default tone 450 1 0.5:
audio-driver-ctl tone 450 1 0.5Playing 450.00 Hz tone for 1.00 seconds at 0.50 amplitude
取消数据流的静音
此命令等效于 audio-driver-ctl -t output -d default 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/