Page 1 of 1

shellscript execution: bash-script only partially executed!

Posted: Thu Feb 18, 2021 7:47 pm
by shivahoj
Hello,
QLC4.12.3 on OSX catalina here.
i need to send MIDI Program change _AND_ MIDI CC Messages from QLC, and since i found no way to do that,
i made a bash script, that upon every invocation outputs a new set of Bank select and Program change MIDI commands to a MIDI-connected Laser Synthesizer( Radiator , https://www.neoncaptain.com/#/).
The script reads two values from another file(called "scene.txt"), sends them via sendmidi (https://github.com/gbevin/SendMIDI) and increments a counter in a third file("pointer.txt").
For testing purposes, i send MIDI data to the free PROTOKOL MIDI Monitor.
This script takes no arguments and works well, when i start it on the command line.
But when i start it from within QLC via the Script editor function"systemcommand" with no arguments, the computer says "test", but no MIDI data are written.
Assigning MIDI output to any universe does not make a difference.
Anyway, QLC should be unaware of any MIDI Data, since its not sending or receiving them.

how do i get my script to perform as intended?

this is the script:

Code: Select all

#!/bin/bash
# reads next position from $Pointer, 
# then outputs the 2 values of that postion in 
# $scene
say "test"                                                   # <-------THIS WORKS , but not the rest !
workdir="/Users/dirk/"
# file holding pointer to next line to read:
pointer="pointer.txt"

# file holding banks and programs:
scene="./scene.txt"

# output device:
dev="Protokol"
#dev="USB2.0-MIDI Anschluss 2"
#dev="Unitor8/AMT8 Port 1"

read -r linecnt < $pointer
read -r max_count < <(sed "1!d; q" $scene)
echo " max_count: $max_count  linecnt: $linecnt "
read -r bank_change program_change < <(sed "$linecnt!d; q" $scene)
echo "bank_change: $bank_change program_change: $program_change"
/usr/local/bin/sendmidi dev $dev cc 32 "$bank_change" PC "$program_change"
if [ $linecnt -gt $max_count ] 
then 
let linecnt=1
fi
echo $((linecnt + 1)) > $pointer
the file scene.txt

Code: Select all

521
0	00
0	01
0	02
0	03
0	04
0	05
0	06
0	07
0	08
0	09
0	10
0	11
0	64
0	65
0	66
9	99

Re: shellscript execution: bash-script only partially executed!

Posted: Fri Feb 19, 2021 2:59 am
by mlohrey
I could be completely wrong here as I have never used external functions, but have found that if you want something to persist in a script in QLC+ then you need to add a wait time for as long as you want the script to be active.

I might be way off the mark but try adding a wait command in your script after the excuse command and see what happens.

Cheers
Mark

Re: shellscript execution: bash-script only partially executed!

Posted: Fri Feb 19, 2021 8:50 pm
by shivahoj
Unfortunately, that did not help.
I will try the same thing on a linux virtual machine with a VM Protocol app and Virtual MIDI Ports.
That will steer clear of the paranoid Catalina security settings.

Re: shellscript execution: bash-script only partially executed!

Posted: Sun Feb 21, 2021 6:23 am
by sbenejam
I tested on Ubuntu and after some changes it works from command line and from QLC+ via script function.

Code: Select all

#!/bin/bash
# reads next position from $Pointer, 
# then outputs the 2 values of that postion in 
# $scene
say "test"                                                   # <-------THIS WORKS , but not the rest !
workdir="/Users/dirk/"
sendmidi="/usr/local/bin/sendmidi"          # sendmidi path
# file holding pointer to next line to read:
pointer=$workdir"pointer.txt"			# path to file pointer.txt  in workdir

# file holding banks and programs:
scene=$workdir"scene.txt"			# path to file scene.txt in workdir

# output device:
dev="Protokol"
#dev="USB2.0-MIDI Anschluss 2"
#dev="Unitor8/AMT8 Port 1"

read -r linecnt < $pointer
read -r max_count < <(sed "1!d; q" $scene)
echo " max_count: $max_count  linecnt: $linecnt "
read -r bank_change program_change < <(sed "$linecnt!d; q" $scene)
echo "bank_change: $bank_change program_change: $program_change"
$sendmidi dev $dev cc 32 "$bank_change" PC "$program_change"     # use sendmidi variable to execute /usr/local/bin/sendmmidi
if [ $linecnt -gt $max_count ] 
then 
let linecnt=1
fi
echo $((linecnt + 1)) > $pointer