From 5354f40f4a97ba3b64280085cc7e035e8f55fafe Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 29 Mar 2022 15:16:05 +0200 Subject: [PATCH] added script to send midi messages --- send-midi.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 send-midi.sh diff --git a/send-midi.sh b/send-midi.sh new file mode 100755 index 0000000..25fc8c8 --- /dev/null +++ b/send-midi.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# 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" \ No newline at end of file