blob: acc6015c5dad9662a66965f016739361bd5e19af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/usr/bin/env bash
# I show you a string and a fret/note and you play matching note/fret, then hit any key to continue
export STRINGS='1-6'
export FRETS='0-12'
if [ $# == 0 ]; then
echo "No options given, use -n for notes or -f for frets" 1>&2
exit 1
fi
while getopts 'nf' opt; do
case $opt in
n) GUESS_NOTES=true;;
f) GUESS_FRETS=true;;
*) echo "Invalid option, use -n for notes or -f for frets" 1>&2; exit 1
esac
done
rand_note () {
shuf -e Do Do-di Re-be Re Re-di Mi-be Mi Fa Fa-di Sol-be Sol Sol-di La-be La La-di Ti-be Ti -n 1
}
clear
while true; do
test "$PRESSED" && echo "took $SECONDS second(s)"
SECONDS=0
printf "String %s; " "$(shuf -i "$STRINGS" -n 1)"
test "$GUESS_NOTES" && printf "Fret %s " "$(shuf -i "$FRETS" -n 1)"
test "$GUESS_FRETS" && printf "%s " "$(rand_note)"
# press any key to continue
read -n 1 -s -r
PRESSED=true
clear
done
|