レコードからVUテーブル値をテキストとして抽出

レコードからVUテーブル値をテキストとして抽出

arecord -V mono -f cd /home/soundVUテーブル出力(例:)を音波の代わりに単純なASCIIテーブルとしてファイルに保存したいと思います。つまり、VUメーターの値を1秒ごとにdB単位で保存する必要があります。コマンドラインでこれを行うにはどうすればよいですか?または、代わりに使用できる他のソフトウェアがありますかarecord?ありがとうございます! !

ベストアンサー1

Bashシェルスクリプトを作成して、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 

おすすめ記事