diff --git a/README.md b/README.md index 43c6894..89e9449 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # bashtuner -A guitar tuner written in bash +A guitar tuner written in bash. +To extend, add new tunings to the array. More are coming soon. I may also add other instruments such as the mandolin + +Want to support my work? Check out my [Liberapay page](https://liberapay.com/stormdragon2976), or my membership options on [Patreon](https://patreon.com/stormdragon2976). diff --git a/bashtuner.sh b/bashtuner.sh new file mode 100755 index 0000000..1727fa8 --- /dev/null +++ b/bashtuner.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Written by Storm Dragon https://social.stormdragon.tk/storm +# Released under the terms of the WTFPL License http://wtfpl.net + +declare -A tuning=( + # Dropped 1 step. + [6d]="D2 G2 C3 F3 A3 D4" + # Standard tuning + [6e]="E2 A2 D3 G3 B3 E4" +) + +show_help() { + echo "Usage: $0 tune_id" + echo "Where tune_id is one of" + echo "${!tuning[@]}" +exit 0 +} + +[ $# -ne 1 ] && show_help +[ -z "${tuning[$1]}" ] && show_help +# Continuously play the notes until a key is press. +# Note key can not be enter or space. +# This will adjust how long each note plays. +timeout=2 +for i in ${tuning[$1]} ; do + unset continue + while [[ -z "$continue" ]]; do + ps $notePID &> /dev/null && kill $notePID &> /dev/null + play -qnV0 synth $timeout pl $i & + notePID="$!" + read -sn1 -t $timeout continue + done +done