2

I want to save a VU meter output (like arecord -V mono -f cd /home/sound) in a file as a simple ASCII table and not as a sound wave. In other words, I need to save VU meter value in dB every second. How can I do that from command line? Or is there other software that can do this instead of arecord? Thanks!!

1 Answer 1

0

You can make a bash shell script which will catch the standard output of the VU meter.

 #!/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 
2
  • 1
    You can apply several sed expressions in one call using sed -e 'expr1' -e 'expr2' etc.
    – AdminBee
    Dec 10, 2019 at 13:14
  • this works too: cat audio.info | grep -o '[0-9]\{2\}%' | tr -d '\n' > new.info
    – JoeyH
    Dec 10, 2019 at 21:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .