audio-driver-ctl

播放、录制和配置音频流。

重要提示

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>

使用中的通道掩码。例如,0xf15 表示通道 0、1、2 和 3。 默认为所有频道。

-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.096000.0 赫兹之间(默认值:440.0 赫兹)。“<seconds>”必须大于 0.001 秒。如果未提供 ,则一直播放提示音,直到按下按键。<amplitude> 会缩放输出(如果提供),并且必须在 0.11.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。

这是设备端命令,而不是 fxffx 等主机端命令。 换言之,在调用此命令之前,您必须先访问 Fuchsia 设备的 shell。

如需以交互方式访问 Fuchsia 设备的 shell,请执行以下操作:

ffx component explore <component>

<component> 替换为有权访问本页记录的命令的组件的名称。

如需调用单个命令并将输出返回到主机,请执行以下操作:

ffx component explore <component> -c "<command>"

<command> 替换为本页介绍的某个命令。

执行流的命令支持的 build

playcore在其他 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/