-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·44 lines (37 loc) · 967 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -euo pipefail
VIRTUAL_NAME="Virtual Raw"
SYNTH_NAME="Waldorf Kyra"
ADAPTER_NAME="UM-1"
ADAPTER2_NAME="KeyStep"
sudo modprobe snd_virmidi
get_midi_port() {
aconnect -l | grep "$1" -m 1 | sed -e 's/^client \([0-9]*\).*/\1/'
}
connect_midi() {
virtual=$(get_midi_port "${VIRTUAL_NAME}")
synth=$(get_midi_port "${SYNTH_NAME}")
adapter=$(get_midi_port "${ADAPTER_NAME}")
adapter2=$(get_midi_port "${ADAPTER2_NAME}")
if [ -n "$virtual" ] && [ -n "$synth" ]; then
aconnect -x
aconnect ${virtual} ${synth}
aconnect ${adapter} $((${virtual} + 1)) || true # don't fail
aconnect ${adapter2} $((${virtual} + 1)) || true # don't fail
return 0
else
return -1
fi
}
mkdir -p record
while true; do
if connect_midi; then
make
./midipush 0 5 && true
if [ $? == 40 ]; then
sleep 15
sudo poweroff
fi
fi
sleep 5
done