From 34014b43e2778c44c4775ee0f1732c9d6c6302e6 Mon Sep 17 00:00:00 2001 From: Skladnayazebra Date: Sun, 27 Sep 2026 10:25:36 +0200 Subject: add guitar-notes.sh --- guitar-notes.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 guitar-notes.sh (limited to 'guitar-notes.sh') diff --git a/guitar-notes.sh b/guitar-notes.sh new file mode 100644 index 0000000..a03c3fa --- /dev/null +++ b/guitar-notes.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Every few seconds, I show you a string and a fret/note and you play matching note/fret + +export STRINGS='5-5' +export FRETS='0-12' +INTERVAL_SECONDS=5 + +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 + 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)" + sleep "$INTERVAL_SECONDS" + clear +done -- cgit v1.3.1