Skip to content

Instantly share code, notes, and snippets.

@rsalmond
Created May 31, 2018 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsalmond/52bc5dc22c218ceb42f4f5a7340ba231 to your computer and use it in GitHub Desktop.
Save rsalmond/52bc5dc22c218ceb42f4f5a7340ba231 to your computer and use it in GitHub Desktop.
Pin osx audio input level, prevent "smart" adjustment.
#!/usr/bin/env bash
#Keep the gain pegged at the desired input level
poll=3
vol=100
help() {
cat <<EOF
Usage:
$0 [-h|--help] [-p|--polling=<polling rate>] [-v|--volume=<volume>]
-h, --help Show help
-p, --polling=polling_rate Specify the polling rate in seconds
-v, --volume=volume Specify the input volume (0 - 100)
EOF
}
grip() {
while true; do
osascript -e "set volume input volume $vol"
sleep $poll
done
}
while test $# -gt 0; do
case "$1" in
-h|--help)
help
exit 0
;;
-p)
shift
if test $# -gt 0; then
poll=$1
else
echo "polling rate not specified"
exit 1
fi
shift
;;
--polling*)
poll=`echo $1 | sed -e 's/^[^=]*=//g'`
shift
;;
-v)
shift
if test $# -gt 0; then
vol=$1
else
echo "volume not specified"
exit 1
fi
shift
;;
--volume*)
vol=`echo $1 | sed -e 's/^[^=]*=//g'`
shift
;;
*)
echo "Unknown option: $1"
help
exit 1
;;
esac
done
grip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment