Audio-Driver-Cct

播放、錄製及設定音訊串流。

重要事項

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 的 0xf15。預設值為所有管道。

-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>

在所選輸出裝置上重複播放 WAV 檔案,直到按下鍵為止。<playpath>

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 版本。

此為裝置端指令,而非 fxffx 等主機端指令。換句話說,您必須先存取 Fuchsia 裝置的殼層,才能呼叫這項指令。

如何以互動方式存取 Fuchsia 裝置的殼層:

ffx component explore <component>

<component> 替換為可存取本頁所述指令的元件名稱。

如何呼叫單一指令,並將輸出內容傳回主機:

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

<command> 替換為本頁列出的其中一項指令。

支援用於測試串流的指令

執行音訊串流的指令 (例如 play) 僅適用於診斷模式。core在其他版本中,系統僅支援 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/