Skip to content

Instantly share code, notes, and snippets.

@melissaboiko
Last active August 10, 2020 12:15
Show Gist options
  • Save melissaboiko/18a88b7b17fe0c0225b6f552a968e28f to your computer and use it in GitHub Desktop.
Save melissaboiko/18a88b7b17fe0c0225b6f552a968e28f to your computer and use it in GitHub Desktop.
make fun beep boop sounds
#!/bin/bash
# usage: soxbeep [N] [duration]
# where N = number of beeps (default 1) and duration = duration in seconds (default 0.2)
# try e.g. soxbeep.sh 7
# c g d a e # penta M
notes=( 323.63 384.87 432.00 513.74 576.65 647.27 769.74 864.00 1027.47 1153.30 1294.54 ) # 1539.47 1728.00)
duration=0.2
function beep() {
frequency=${notes[$RANDOM % ${#notes[@]} ]}
play -q -n synth $duration tri $frequency 2>&-
}
if [ "$1" ]; then
n="$1"
else
n=1
fi
if [ "$2" ]; then
duration=$2
fi
for blah in $(seq $n); do
beep
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment