Raspbian:检查声音输出

Raspbian:检查声音输出

如何从命令行检查音频线输出(使用 ALSA 插件创建的虚拟设备)是否有音频信号?并检查信号强度?

答案1

我找到了使用“sox”工具的解决方案(袜人)。我可以使用这个答案中提出的方法(将声音输出发送到应用程序和扬声器)要在 alsa 虚拟设备中获取信号,请调用“Loopback”,同时将其发送到输出设备,然后使用 sox 查找是否有信号及其强度:

sox -b 16 -t alsa hw:Loopback,1,0 -r 48000 -n stat

(-b -> 16 位信号,-t (alsa hw:Loopback,1,0) -> 给我信号的虚拟设备,-r 48000 -> 采样频率和 -n stat -> 分析信号)

该命令给出如下输出:

Input File     : 'hw:Loopback,1,0' (alsa)
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Sample Encoding: 16-bit Signed Integer PCM


In:0.00% 00:00:02.47 [00:00:00.00] Out:115k  [-=====|=====-] Hd:3.9 Clip:0  

Samples read:            229376
Length (seconds):      2.389333
Scaled by:         2147483647.0
Maximum amplitude:     0.630951
Minimum amplitude:    -0.630981
Midline amplitude:    -0.000015
Mean    norm:          0.159916
Mean    amplitude:    -0.004383
RMS     amplitude:     0.198459
Maximum delta:         1.176422
Minimum delta:         0.000000
Mean    delta:         0.223984
RMS     delta:         0.278537
Rough   frequency:        10721
Volume adjustment:        1.585

当你收到信号时,以及当没有信号时:

Input File     : 'hw:Loopback,1,0' (alsa)
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Sample Encoding: 16-bit Signed Integer PCM

In:0.00% 00:02:23.70 [00:00:00.00] Out:6.89M [      |      ]        Clip:0

Samples read:          13787136
Length (seconds):    143.616000
Scaled by:         2147483647.0
Maximum amplitude:     0.000000
Minimum amplitude:     0.000000
Midline amplitude:     0.000000
Mean    norm:          0.000000
Mean    amplitude:     0.000000
RMS     amplitude:     0.000000
Maximum delta:         0.000000
Minimum delta:         0.000000
Mean    delta:         0.000000
RMS     delta:         0.000000
Rough   frequency:            0

“-n stat”工具的含义可以在(红袜队手册页

相关内容