pedalboard-scripts/send-midi.sh

22 lines
750 B
Bash
Raw Permalink Normal View History

2022-03-29 15:16:05 +02:00
#!/usr/bin/env bash
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
dir="$(dirname $(realpath "$0"))"
. "$dir/config.env"
function checkVariable() {
[[ -z "$1" ]] && printf "${FONT_BOLD}error: ${FONT_NORMAL}no $2 given\n" && exit 1
! [ "$1" -eq "$1" ] 2> /dev/null && printf "${FONT_BOLD}error: ${FONT_NORMAL}given $2 \'$1\' is not a number\n" && exit 1
}
checkVariable "$1" "midi channel"
checkVariable "$2" "midi controller"
checkVariable "$3" "value"
url="$(""$dir"/url.sh" "/midi")"
printf "> sending POST request to \'$url\'...${FONT_BOLD}"
[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" -d "channel=$1" -d "controller=$2" -d "value=$3" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n"