播放、錄製及設定音訊串流。
重要事項
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 的遮罩為 0xf 或 15。
預設為所有通道。
-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% 的振幅播放 1 秒的 450 赫茲音調
# 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 裝置,或從目標 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/