2020-12-11 21:20:48 -05:00
|
|
|
#!/usr/bin/env bash
|
2017-09-13 19:30:52 -04:00
|
|
|
|
|
|
|
# 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"
|
2018-08-05 21:13:45 -04:00
|
|
|
# Half step down
|
|
|
|
[half-step-down]="D#2 G#2 C#3 F#3 A#3 D#4"
|
2018-08-04 20:28:05 -04:00
|
|
|
#dadgad 6-string
|
|
|
|
[dadgad]="D2 A2 D3 G3 A3 D4"
|
2018-07-30 19:47:10 -04:00
|
|
|
#Open D
|
|
|
|
[open-d]="D2 A2 D3 F#3 A3 D4"
|
2018-08-04 20:28:05 -04:00
|
|
|
#drop D 6 String
|
|
|
|
[drop-d]="D2 A2 D3 G3 B3 E4"
|
2018-07-30 19:33:40 -04:00
|
|
|
#Drop DG
|
|
|
|
[Drop-dg]="D2 G2 D3 G3 B3 E4"
|
2018-07-30 19:36:33 -04:00
|
|
|
#Open G
|
|
|
|
[[open-g]]="D2 G2 D3 G3 B3 D4"
|
2017-09-13 20:02:05 -04:00
|
|
|
# 12 string dropped 1 step.
|
2017-09-13 21:02:23 -04:00
|
|
|
[12d]="D3 D2 G3 G2 C4 C3 F4 F3 A3 D4"
|
2017-09-13 20:02:05 -04:00
|
|
|
# 12 string standard tuning
|
2017-09-13 21:02:23 -04:00
|
|
|
[12e]="E3 E2 A3 A2 D4 D3 G4 G3 B3 E4"
|
2017-09-13 20:02:05 -04:00
|
|
|
# Mandolin
|
|
|
|
[mandolin]="G3 D4 A4 E5"
|
2018-08-04 20:28:05 -04:00
|
|
|
#Ukulele
|
2018-07-17 21:27:53 -04:00
|
|
|
[ukulele]="G4 C4 E4 A4"
|
2018-12-31 11:19:12 -05:00
|
|
|
[ukulele-half-step-down]="F#4 B3 D#4 G#4"
|
2018-07-30 19:50:45 -04:00
|
|
|
#lap Steel 6 String C6
|
|
|
|
[steel-C6]="C3 E3 G3 A3 C4 E4"
|
2018-07-27 14:14:01 -04:00
|
|
|
#Nick Drake Tuning
|
2018-07-28 10:23:12 -04:00
|
|
|
[nick-drake-tuning]="C2 G2 C3 F3 C4 E4"
|
|
|
|
#banjo
|
|
|
|
[banjo]="G4 D3 G3 B3 D4"
|
2018-08-04 20:28:05 -04:00
|
|
|
# Chromatic Scale, 2 octaves.
|
|
|
|
[chromatic-scale]="C2 C#2 D2 D#2 E2 F2 F#2 G2 G#2 A2 A#2 B2 C3 C#3 D3 D#3 E3 F3 F#3 G3 G#3 A3 A#3 B3 C4 C#4 D4 D#4 E4 F4 F#4 G4 G#4 A4 A#4 B4 C5"
|
2017-09-13 19:30:52 -04:00
|
|
|
)
|
2018-07-30 22:25:35 -04:00
|
|
|
|
|
|
|
# For multi-language support
|
|
|
|
export TEXTDOMAIN=bashtuner
|
|
|
|
export TEXTDOMAINDIR=/usr/share/locale
|
|
|
|
source gettext.sh
|
|
|
|
|
2018-07-27 13:58:20 -04:00
|
|
|
export DIALOGOPTS='--insecure --no-lines --visit-items'
|
2017-09-13 19:30:52 -04:00
|
|
|
|
2018-07-28 10:39:19 -04:00
|
|
|
flush_keys() {
|
2018-07-28 11:24:52 -04:00
|
|
|
local keys
|
|
|
|
read -st0.001 keys
|
2018-07-28 10:39:19 -04:00
|
|
|
}
|
|
|
|
|
2017-09-13 19:30:52 -04:00
|
|
|
show_help() {
|
2018-07-30 22:34:52 -04:00
|
|
|
echo "$(eval_gettext "Usage: \$0 tune_id")"
|
|
|
|
echo "$(gettext "Where tune_id is one of")"
|
2018-07-30 23:14:21 -04:00
|
|
|
echo "${!tuning[@]}"
|
2017-09-13 19:30:52 -04:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2018-07-27 13:58:20 -04:00
|
|
|
if [[ $# -eq 0 ]]; then
|
2018-07-30 22:34:52 -04:00
|
|
|
set -- $(dialog --backtitle "$(gettext "Welcome to Bash Tuner")" \
|
2018-07-27 13:58:20 -04:00
|
|
|
--no-tags \
|
2018-07-30 22:34:52 -04:00
|
|
|
--menu "$(gettext "Select tuning")" 0 0 10 \
|
2018-07-27 13:58:20 -04:00
|
|
|
$(for i in ${!tuning[@]} ; do echo "$i";echo "$i";done) --stdout)
|
2018-07-27 14:06:59 -04:00
|
|
|
[[ -z $1 ]] && exit 0
|
2018-07-27 13:58:20 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
[ $# -gt 1 ] && show_help
|
2017-09-13 19:30:52 -04:00
|
|
|
[ -z "${tuning[$1]}" ] && show_help
|
2017-09-13 19:40:22 -04:00
|
|
|
[ "$1" == "-h" ] && show_help
|
|
|
|
[ "$1" == "--help" ] && show_help
|
|
|
|
|
2017-09-13 19:30:52 -04:00
|
|
|
# Continuously play the notes until a key is press.
|
|
|
|
# This will adjust how long each note plays.
|
|
|
|
timeout=2
|
|
|
|
for i in ${tuning[$1]} ; do
|
|
|
|
unset continue
|
2017-09-13 20:02:05 -04:00
|
|
|
ifs="$IFS"
|
|
|
|
IFS=""
|
2017-09-13 19:30:52 -04:00
|
|
|
while [[ -z "$continue" ]]; do
|
|
|
|
ps $notePID &> /dev/null && kill $notePID &> /dev/null
|
|
|
|
play -qnV0 synth $timeout pl $i &
|
|
|
|
notePID="$!"
|
2017-09-13 20:02:05 -04:00
|
|
|
read -sN1 -t $timeout continue
|
2018-07-28 10:39:19 -04:00
|
|
|
flush_keys
|
2018-12-01 12:33:05 -05:00
|
|
|
done | dialog --progressbox "${i//[[:digit:]]/}" 0 0
|
2017-09-13 20:02:05 -04:00
|
|
|
IFS="$ifs"
|
2017-09-13 19:30:52 -04:00
|
|
|
done
|
2017-09-13 21:02:23 -04:00
|
|
|
# Kill the final process when the program exits.
|
|
|
|
ps $notePID &> /dev/null && kill $notePID &> /dev/null
|
|
|
|
exit 0
|