LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Blogs > sag47
User Name
Password

Notices

Rate this Entry

Monitoring sound over time for long periods to see trends using a microphone

Posted 02-09-2012 at 03:54 PM by sag47
Updated 02-09-2012 at 03:58 PM by sag47

Recently a post was made requesting a solution to detecting sound in a studio to see if it is populated with lots of noise (lots of noise=people/bands playing) this way the person monitoring it wouldn't have to go through the trouble of hulking all their stuff to the studio.

I posted an interesting solution so I'm sharing it here and a little more on this blog. See post #9 of this thread.

I'm going to expand upon that munin plugin and make it a little more robust and informative. I'll rewrite the munin plugin a bit to include more information on the same graph and be a little better.

Code:
#!/bin/sh

case $1 in
   config)
           cat <<EOM
graph_title Sound Amplitude
graph_args -l -1 --upper-limit 1
graph_vlabel Amplitude
graph_info Shows the sound amplitude values during the 1 second interval recorded discretely every minute.
mxamp.label max_ampl
mxamp.info Maximum amplitude
mnamp.label min_ampl
mnamp.info Minimum amplitude
mdamp.label mid_ampl
mdamp.info Midline amplitude
EOM
           exit 0;; 
esac

arecord -d 1 -f cd -t wav /tmp/foo.wav &> /dev/null
echo -n "mxamp.value " 
sox /tmp/foo.wav -n stat 2>&1 | grep 'Maximum amplitude' | awk '{print $3}'
echo -n "mnamp.value "
sox /tmp/foo.wav -n stat 2>&1 | grep 'Minimum amplitude' | awk '{print $3}'
echo -n "mdamp.value "
sox /tmp/foo.wav -n stat 2>&1 | grep 'Midline amplitude' | awk '{print $3}'
rm -f /tmp/foo.wav
Of course, that plugin can be further improved by writing an awk script which parses out all of the values and displays all three values at once that way the sox command is only run once and it uses less CPU. Though power savings will be almost negligible by doing that. I kept it this way for readability mostly.

The new munin plugin improves upon the last one by providing more information which is a little more useful than just knowing the maximum amplitude of the 1 second sample recorded at the time of running the plugin. At any rate I thought that was a cool little project I got myself into so I documented it here.

SAM
Posted in Uncategorized
Views 152 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 01:01 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration