bdk/bdk.sh

137 lines
2.4 KiB
Bash
Raw Normal View History

2017-02-01 06:25:33 -07:00
#!/bin/bash
# Directory containing sounds and config file
KIT_DIR="kits"
2017-02-02 09:55:41 -07:00
# Colors
RED='\033[0;31m'
LRED="\033[1;31m"
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
GREEN="\033[0;32m"
LGREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[0;36m"
LCYAN="\033[1;36m"
PURPLE="\033[0;35m"
LPURPLE="\033[1;35m"
BWHITE="\e[1m"
NC='\033[0m' # No Color
2017-02-01 06:25:33 -07:00
#Check for kits and load the config
#load default kit if specified kit not found
defaultKit(){
2017-02-02 09:55:41 -07:00
echo
printf "${LRED}The kit: '${1}' was not found${NC}\n"
2017-02-01 06:25:33 -07:00
echo "Loading default kit.."
echo
KIT="${KIT_DIR}/default"
cd ${KIT}
if [ -f config ];then
. config
else
echo "Could not load config"
exit 0
fi
}
checkKits(){
if [ -d kits/${1} ];then
KIT="${KIT_DIR}/${1}"
cd ${KIT}
if [ -f config ];then
. config
else
echo "Could not load config"
cd .. && cd ..
defaultKit
fi
else
2017-02-02 09:55:41 -07:00
defaultKit ${1}
2017-02-01 06:25:33 -07:00
fi
}
help(){
printf """
BDK - BASH DRUM KIT
${0} [options] [kit-name]
[options] [Description]
-k Load drum kit
-l List available kits
"""
}
case $1 in
-k | --kit)
checkKits ${2}
;;
-l | --list)
2017-02-02 09:55:41 -07:00
printf "\n"
2017-02-01 06:25:33 -07:00
printf "[ Installed Kits]\n"
if [[ $(ls -A $DIR) ]];then
ls ${KIT_DIR}
exit 0
else
printf "There are no kits currently installed...\n"
exit 0
fi
;;
*)
help
exit 0
;;
esac
2017-02-02 09:55:41 -07:00
printf "${LPURPLE}\(*)/ BDK - Bash Drum Kit${NC}\n"
2017-02-01 06:25:33 -07:00
key(){
echo
2017-02-02 09:55:41 -07:00
printf "${LCYAN}[${KP}] = Kick${NC} | ${LGREEN}[${HHC}] = Hi-Hat Closed${NC} | ${YELLOW}[enter] = Snare${NC} | ${LPURPLE}[h] help${NC} |${LRED} [q] Quit${NC}\n"
2017-02-01 06:25:33 -07:00
}
key
echo
while true;do
2017-02-02 09:55:41 -07:00
printf "${YELLOW}(*)>${NC} "
2017-02-01 06:25:33 -07:00
read -s -n 1 key
# -s: do not echo input character. -n 1: read only 1 character (separate with space)
2017-02-02 09:55:41 -07:00
if [[ $key = "${KP}" ]]; then
2020-06-09 02:09:52 -04:00
${PLAYER} ${KICK} >/dev/null 2>/dev/null &
2017-02-02 09:55:41 -07:00
printf "${LCYAN}[${KP}] Kick${NC}\n"
elif [[ $key == ${SD} ]];then
2020-06-09 02:09:52 -04:00
${PLAYER} ${SNARE} >/dev/null 2>/dev/null &
2017-02-02 09:55:41 -07:00
printf "${YELLOW}[${SD}] Snare Drum${NC}\n"
elif [[ $key == "${HHC}" ]];then
2020-06-09 02:09:52 -04:00
${PLAYER} ${HIHAT} >/dev/null 2>/dev/null &
2017-02-02 09:55:41 -07:00
printf "${LGREEN}[${HHC}] Hi-Hat Closed${NC}\n"
2017-02-01 06:25:33 -07:00
elif [[ $key == "h" ]];then
key
elif [[ $key == "q" ]];then
exit 0;
else
2017-02-02 09:55:41 -07:00
printf "${LRED}'${key}' does nothing!${NC}\n"
2017-02-01 06:25:33 -07:00
fi
done