by bnegreve · 13y ago · 0 comments
while true; do sox -t .wav "|arecord -d 1" -n stat 2> /tmp/tmp; echo -n `date +"%Y%m%d%H%M%S"` " "; cat /tmp/tmp | grep "Maximum amplitude" | cut -d ":" -f 2 | tr -d '\n'; cat /tmp/tmp | grep "Midline amplitude" | cut -d ":" -f 2 | tr -d '\n'; cat /tmp/tmp | grep "Rough *frequency" | cut -d ":" -f 2; done
and got this: http://i.imgur.com/oD6ZKIg.png?1
Interesting things: When my neighbor walks in his apartment above mine, it creates a amp peak with low frequency.
I have no idea what are those approx. one hour long periodic variations in the frequency, maybe my computer's fan or me snoring.
Anyway, pretty useless...
* You didn't write a single line of code (well technically you did write one), nor researched about sound APIs or any kind of sound analysis algorithms or theory.
* You used several tools that just seamlessly shared their inputs and outputs and each one worked as supposed.
Granted, you need to know some bash and figure out how every utility works and the right command line switches to use, but still, pretty impressive.
while true; do sox -t .wav "|arecord -d 1" -n stat 2> /tmp/tmp; echo -n $( date +%Y%m%d%H%M%S ); grep -e "Maximum amplitude" -e "Midline amplitude" -e "Rough *frequency" /tmp/tmp | cut -d ":" -f 2 | tr -d "\n"; echo; done
Shortening a line like this reminds me of a discussion on a forum about picking a random movie to play. It started off with loops and scripts of all kinds, and eventually ended with "shuf" :)