Skip to content

Instantly share code, notes, and snippets.

@jdowner
Forked from rsvp/noise.sh
Last active August 29, 2015 14:04
Show Gist options
  • Save jdowner/8d3b20c04ba3a194487f to your computer and use it in GitHub Desktop.
Save jdowner/8d3b20c04ba3a194487f to your computer and use it in GitHub Desktop.
ambient noise
duration='00:59:00'
noisetype='pinknoise'
progress='--no-show-progress'
noisetype="pinknoise"
band_center="1000"
band_width="499"
tremolo_speed="0.01"
tremolo_depth="43"
reverb="19"
bass="-11"
treble="-1"
vol="14dB"
#!/bin/bash
set -u
set -e
# Load the default values from the config file
CONFIG="${HOME}/.config/noise.cfg"
if [[ -f ${CONFIG} ]]; then
source ${CONFIG}
fi
# Use any values specified via the command line
while [[ $# > 0 ]];
do
case $1 in
-c|--config)
if [[ ! -f $2 ]]; then
echo "ERROR: ${2} is not a file"
exit 1
fi
source ${2}
shift
;;
-d|--duration)
duration=$2
shift
;;
-p|--progress)
progress='--show-progress'
;;
-t|--type)
case $2 in
'white'|'pink'|'brown'|'tpdf')
noisetype=${2}noise
shift
;;
*)
echo "ERROR: unrecognized type of noise"
exit 1
esac
;;
-v|--volume)
vol=$2
shift
;;
*)
echo "ERROR: unrecognized option"
exit 1
esac
shift
done
if [[ -z ${duration} ]]; then
echo "ERROR: you need to provide a duration"
exit 1
fi
if [[ -z ${noisetype} ]]; then
echo "ERROR: you need to proivde a noise type"
exit 1
fi
play ${progress} --null --channels 2 \
synth ${duration} ${noisetype} \
band -n ${band_center} ${band_width} \
tremolo ${tremolo_speed} ${tremolo_depth} \
reverb ${reverb} \
bass ${bass} \
treble ${treble} \
vol ${vol}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment