Skip to content

Instantly share code, notes, and snippets.

@mperlet
Last active December 30, 2015 19:09
Show Gist options
  • Save mperlet/7872291 to your computer and use it in GitHub Desktop.
Save mperlet/7872291 to your computer and use it in GitHub Desktop.
execute commands if microphone input >= the level variable
#!/bin/bash
level=$1
i=0
while true;
do
l_value=$(rec -n stat trim 0 .5 2>&1 | awk '/^RMS amplitude/ { printf $3 }';)
is_loud=$(echo $l_value | awk -v lev="$level" '{ if ($0 >= lev) printf "1"; else printf "0" }')
if [ $is_loud == 1 ]
then
# execute...
i=$((i + 1))
clear
echo $l_value
echo "counter = $i"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment