shellscript execution: bash-script only partially executed!

The issues found when using the Function Manager panel
Post Reply
shivahoj
Posts: 27
Joined: Mon Sep 23, 2019 5:26 am
Location: Hildesheim, Germany
Real Name: Dirk Engelmann

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
Fixture: GLP Impression Spot one w/ Artnet/DMX (2x)
Macbook pro, OSX 10.13.4, QLC+ 4.12.2
Generic touch screen PC, with debian 10 linux, QLC+ 4.12.2
MIDI: AKAI APC40, Doepfer pocket fader, Radium 49 Keyboard
DMX: enttec USB pro
mlohrey
Posts: 243
Joined: Mon Apr 20, 2015 5:07 am
Real Name: Mark Lohrey

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
shivahoj
Posts: 27
Joined: Mon Sep 23, 2019 5:26 am
Location: Hildesheim, Germany
Real Name: Dirk Engelmann

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.
Fixture: GLP Impression Spot one w/ Artnet/DMX (2x)
Macbook pro, OSX 10.13.4, QLC+ 4.12.2
Generic touch screen PC, with debian 10 linux, QLC+ 4.12.2
MIDI: AKAI APC40, Doepfer pocket fader, Radium 49 Keyboard
DMX: enttec USB pro
User avatar
sbenejam
Posts: 550
Joined: Sun Apr 12, 2015 6:28 pm
Real Name: Santiago Benejam Torres
Contact:

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
Post Reply