commit 7dafdfef40c993b42f7d87da3eda2c173a149309 Author: velvettear Date: Fri Mar 25 15:16:17 2022 +0100 initial commit diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d342365 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +# MIT License +**Copyright (c) 2022 Daniel Sommer \** + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.** \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae207ff --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# pedalboard-scripts + +scripts to control [MODEP](https://blokas.io/modep/docs/) on a raspberry pi 4 with [pisound](https://blokas.io/pisound/) via [pbc](https://git.velvettear.de/velvettear/pbc.git) diff --git a/bypass.sh b/bypass.sh new file mode 100644 index 0000000..e68093c --- /dev/null +++ b/bypass.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# license: MIT + +[[ ! -f "./config.env" ]] && printf "error: file \'config.env\' does not exist\n" && exit 1 +source "./config.env" + +url="/bypass" +index="$1" +if [[ "$index" ]] && [ "$index" -eq "$index" ] 2> /dev/null; then + if [ "$index" -lt 0 ]; then + index=0 + elif [ "$index" -gt 7 ]; then + index=7 + fi + url="$url/$index" +fi + +function checkVariable() { + [[ "$1" ]] && return 0 + printf "error: variable" + [[ "$2" ]] && printf " \'$2\'" + printf " is not set\n" + exit 1 +} + +checkVariable "$PBC_PROTOCOL" "PBC_PROTOCOL" +checkVariable "$PBC_HOST" "PBC_HOST" +checkVariable "$PBC_PORT" "PBC_PORT" + +url="$PBC_PROTOCOL://$PBC_HOST:$PBC_PORT$url" + +printf "sending POST request: \'$url\'...${FONT_BOLD}" +[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n" \ No newline at end of file diff --git a/config.env b/config.env new file mode 100644 index 0000000..360384b --- /dev/null +++ b/config.env @@ -0,0 +1,6 @@ +FONT_BOLD=$(tput bold) +FONT_NORMAL=$(tput sgr0) + +PBC_PROTOCOL="http" +PBC_HOST="192.168.1.24" +PBC_PORT="3000" \ No newline at end of file diff --git a/pedalboard.sh b/pedalboard.sh new file mode 100644 index 0000000..c86b51e --- /dev/null +++ b/pedalboard.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# license: MIT + +[[ ! -f "./config.env" ]] && printf "error: file \'config.env\' does not exist\n" && exit 1 +source "./config.env" + diff --git a/start-pedalboard.sh b/start-pedalboard.sh new file mode 100644 index 0000000..a60d6d3 --- /dev/null +++ b/start-pedalboard.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer >> +# license: MIT + +set -e + +[[ "$EUID" != "0" ]] && printf "error: permission denied\n" && exit 1 + +source "./config.env" + +printf "${FONT_BOLD}> starting pedalboard...${FONT_NORMAL}\n" + +source "/usr/local/pisound/scripts/common/common.sh" + +flash_leds 10 +sleep 0.25 +flash_leds 10 + +printf ">>> " && "/etc/velvettear/scripts/cpu-governor.sh" "performance" + +printf ">>> starting MODEP..." +patchbox module activate modep &>>> /dev/null +printf " done!\n" + +up="$(journalctl -u modep-touchosc2midi | tail -n1)" +while [[ "$up" != *"Waiting for first package from touchOSC"* ]]; do + printf ">>> waiting for touchosc2midi to come up...\n" + sleep 0.1 + up="$(journalctl -u modep-touchosc2midi | tail -n1)" +done +printf ">>> sending message to touchosc2midi to wake it up...\n" +oscsend localhost 12101 / m 000000b0 + +if [[ ! -e "/etc/systemd/system/pbc.service" ]]; then + printf ">>> symlinking \'pbc.service\' to \'/etc/systemd/system\'..." + ln -s "/opt/pbc/pbc.service" "/etc/systemd/system/pbc.service" &>>> /dev/null + printf " done!\n" + printf ">>> reloading systemd services..." + systemctl daemon-reload &>>> /dev/null + printf " done!\n" +fi + +printf ">>> starting pbc..." +systemctl start pbc &>>> /dev/null +printf " done!\n" + +flash_leds 100 + +printf "${FONT_BOLD}> started pedalboard after "$SECONDS" seconds${FONT_NORMAL}\n" \ No newline at end of file diff --git a/stop-pedalboard.sh b/stop-pedalboard.sh new file mode 100644 index 0000000..e372c29 --- /dev/null +++ b/stop-pedalboard.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# license: MIT + +set -e + +[[ "$EUID" != "0" ]] && printf "error: permission denied\n" && exit 1 + +source "./config.env" + +printf "${FONT_BOLD}> stopping pedalboard...${FONT_NORMAL}\n" + +source "/usr/local/pisound/scripts/common/common.sh" + +flash_leds 10 +sleep 0.25 +flash_leds 10 + +printf "> stopping pbc..." +systemctl stop pbc &> /dev/null +printf " done!\n" + +printf "> stopping MODEP..." +patchbox module deactivate &> /dev/null +printf " done!\n" + +printf "> stopping jack..." +systemctl stop jack &> /dev/null +printf " done!\n" + +printf "> " && "/etc/velvettear/scripts/cpu-governor.sh" "powersave" + +flash_leds 100 + +printf "${FONT_BOLD}> stopped pedalboard after "$SECONDS" seconds${FONT_NORMAL}\n" \ No newline at end of file