我想将 VU 表输出(如arecord -V mono -f cd /home/sound
)保存在文件中作为简单的 ASCII 表而不是声波。换句话说,我需要每秒保存以 dB 为单位的 VU 表值。我怎样才能从命令行做到这一点?或者有其他软件可以代替吗arecord
?谢谢!!
答案1
您可以制作一个 bash shell 脚本来捕获 VU 表的标准输出。
#!/bin/bash
# redirect stdout to a text file
exec &> audio.info
# use -q so the contents of the text file are only vumeter data
arecord -q -f cd -V mono test.wav
# removes extra symbols except percentages,
# I'm sure this can be consolidated if needed
cat audio.info | sed 's/#//g' | sed 's/ //g' | sed 's/|//g' | sed 's/+//g' | sed 's/[^[:print:]]//g' > new.info
#resets stdout
exec &>/dev/tty
percents=$(cat new.info)
max="0";
#breaks up the values with '%' as the delimiter
IFS='%' read -ra values <<< $percents
for i in "${values[@]}"; do
if [ $i -gt $max ]
then
max=$i
fi
done
echo "maximum amplitude = $max"
The for loop will find the max amplitude during your recording, but you can replace this with
echo $i >> table.txt