播放、錄製及設定音訊串流。
重要事項
audio-driver-ctl 已淘汰,請改用 ffx audio device 工具。詳情請從主體機器執行 ffx audio device --help,並參閱 ffx audio 的 README://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% 的振幅播放 1 秒的 450 赫茲音調
這個指令等同於 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 版本。
此為裝置端指令,而非 fx 或 ffx 等主機端指令。換句話說,您必須先存取 Fuchsia 裝置的殼層,才能呼叫這項指令。
如何以互動方式存取 Fuchsia 裝置的殼層:
ffx component explore <component>
將 <component> 替換為可存取本頁所述指令的元件名稱。
如何呼叫單一指令,並將輸出內容傳回主機:
ffx component explore <component> -c "<command>"
將 <command> 替換為本頁列出的其中一項指令。
支援用於練習串流的指令版本
音訊串流指令 (例如 play) 僅支援診斷模式,例如 core。在其他版本中,系統僅支援 info 等資訊指令。
在主機和目標 Fuchsia 裝置之間複製 WAV 檔案
如要將 WAV 檔案從主機複製到目標 Fuchsia 裝置,或從目標 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/