播放、錄製及設定音訊串流。
重要事項
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>
有效管道遮罩。例如 0xf
或 15
代表管道 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.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 的 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 版本。
此為裝置端指令,而非 fx
或 ffx
等主機端指令。換句話說,您必須先存取 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/