Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
527ad3734This file is pinned to the selected release. Download the original to open it in your design tool.
#!/bin/bash
#
# Tests functionality of Launchpad mode
# test sequence:
# 1. send flash and pulse led commands to all side buttons
# 2. send whole palette of colors to grid buttons
# 3. send "clear all buttons" SysEx
# 4. send few "simulate button press" SysEx messages
# 5. receive and check notes for every press
# 6. send some message, which would trigger SysEx transmission from the device
# 7. switch applications, when it becomes possible
readonly device_name='midi-grid'
readonly tempfile='/tmp/launchpad_test.txt'
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[0;33m'
readonly NC='\033[0m' # No Color
init ()
{
echo "Setting the device to Launchpad mode"
sendmidi dev ${device_name} on 88 101 # first midi message might be ignored
if [[ $? -ne 0 ]]; then
return 1
fi
}
pulse_leds ()
{
echo "Setting LEDs to pulse"
for note in {19..89..10}
do
sendmidi dev ${device_name} ch 3 on ${note} 53
if [[ $? -ne 0 ]]; then
return 1
fi
done
}
flash_leds ()
{
echo "Setting LEDs to flash"
for control in {104..111}
do
sendmidi dev ${device_name} ch 2 cc ${control} 9
if [[ $? -ne 0 ]]; then
return 1
fi
done
}
light_palette ()
{
echo "Testing color palette"
color=0
for i in {1..2}
do
note=11
while [[ ${note} -lt 89 ]]
do
sendmidi dev ${device_name} on ${note} ${color}
if [[ $? -ne 0 ]]; then
return 1
fi
((color++))
((note++))
if [[ $((note % 10)) -eq 9 ]]
then
((note+=2))
fi
done
done
sleep 1 # wait to see if LEDs are pulsing
}
sysex_leds_off ()
{
echo "Turning LEDs off through SysEx command"
sendmidi dev ${device_name} syx 00h 20h 29h 02h 18h 0Eh 00h
if [[ $? -ne 0 ]]; then
return 1
fi
}
receive_notes ()
{
echo "Requesting device to send notes"
for x in {0..7}
do
y=3
sendmidi dev ${device_name} syx 00h 20h 29h 02h 07h 00h ${x} ${y}
if [[ $? -ne 0 ]]; then
return 1
fi
receivemidi dev ${device_name} ch 1 nn on > ${tempfile} &
pid=$!
sleep 0.1
kill ${pid}
((note=10*y+x+11))
if [[ "$(<${tempfile})" != *"${note} 127"* ]]; then
return 1
fi
sendmidi dev ${device_name} on ${note} 5
if [[ $? -ne 0 ]]; then
return 1
fi
((note+=10))
sendmidi dev ${device_name} on ${note} 5
if [[ $? -ne 0 ]]; then
return 1
fi
done
}
receive_sysex ()
{
echo "Requesting a SysEx challenge message from the device"
receivemidi dev midi-grid syx > ${tempfile} &
pid=$!
sendmidi dev ${device_name} syx 00h 20h 29h 02h 18h 40h 00h 00h 00h 00h
if [[ $? -ne 0 ]]; then
kill ${pid}
return 1
fi
sleep 0.5
kill ${pid}
if [[ "$(<${tempfile})" != *"00 20 29 02 18 40 00 00"* ]]; then
return 1
fi
}
step=(
"init"
"pulse_leds"
"flash_leds"
"light_palette"
"sysex_leds_off"
"receive_notes"
"receive_sysex"
)
step_index=0
for current_step in "${step[@]}"
do
((step_index++))
printf "${YELLOW}[${step_index}/${#step[@]}]${NC} "
$current_step
if [[ $? -ne 0 ]]; then
echo -e "${RED}Test failed on step ${step_index}${NC}"
exit 1
fi
done
echo -e "${GREEN}Test completed successfully${NC}"