Yesterday I was fighting with my computer because Cubase opened with playback activated instead of opening with the transport stopped, as it should be.
Finally I found the solution, which is to initialize the local variables of the play button.
Although I found the solution, I don’t understand why play is triggered when I don’t initialize the local variables.
I had assumed that local variables have the value #none# or zero if they are not initialized, but maybe I have misunderstood.
Anyway, below I explain how to replicate it. Logs ID are after the codes.
Steps to reproduce this issue:
- Quit Cubase
- Copy the Background Script Code and paste it into a blank background script
- Copy the Play Button Code and paste it into a blank scripted button
- Both codes: Edit/change the global ports 5 and 6 for setting them to connect to Cubase (make sure you don’t use these ports in other background scripts)
- BG Script Code: Edit/change/set the note on/off midi messages for receiving STOP and REC messages from Cubase
- Play Button Code: Edit/change/set the cc message of the scripted button to send the order to play/pause the project of Cubase
- Play Button Code: set a midi message for triggering “play from last stop” command in Cubase instead of launching “Cubase_PlayFromLastStop.app“ (or remove this action to “noaction”)
- Restart the Stream Deck Software
- Launch Cubase
- When Cubase launches, it starts playing. The play button code triggers “play” even though it is not being pressed. This is the unexpected behaviour. It is important to note that the play is triggered without the need to open any project.
- Quit Cubase
- Quit the Stream Deck Software
- Play Button Code: Uncomment the code of “INIT LOCAL VARS“
- Launch the Stream Deck Software
- Launch Cubase
- Cubase launches as expected, stopped
BACKGROUND SCRIPT CODE:
PORTS
[(init) {outputport:GP5} {inputport:GP6}]
REC
[(noteon:1,95,0-127) {@Recording:1}]--------> Rec ON
[(noteoff:1,95,0-127) {@Recording:0}]--------> Rec OFF
STOP
[(noteoff:1,93,0-127) {@Playing:1}]----------> Playing
[(noteon:1,93,0-127) {@Playing:0}]----------> Stopped
DISPLAY PLAY BUTTON
[(@Playing:1) (@Recording:1) {@DisplayPlayButton:3}]-----------------> Playing and Recording -----------------> DISPLAY STOP REC
[(@Playing:1) (@Recording:0) {@DisplayPlayButton:2}]-----------------> Playing and Not Recording -------------> DISPLAY PLAYING
[(@Playing:0) (@Recording:0) {@DisplayPlayButton:1}]-----------------> Stopped and Not Recording -------------> DISPLAY READY TO PLAY
[(@Playing:0) (@Recording:1) {@DisplayPlayButton:4}]-----------------> Stopped and Recording -----------------> DISPLAY NOTHING
PLAY BUTTON CODE:
PORTS
[(init) {outputport:GP5} {inputport:GP6}]
/*
INIT LOCAL VARS
[(init) {@l_triggerAction:nothing} {@lt_localTimer:reset} {@l_pressedButton:0}]
*/
DISPLAY PLAY BUTTON
[(init+) (@DisplayPlayButton:1) {state:1} {text:▷}]-------> STOPPED & READY TO PLAY
[(init+) (@DisplayPlayButton:2) {state:1} {text:▶︎}]-------> PLAYING
[(init+) (@DisplayPlayButton:3) {state:1} {text:✔︎🟥 }]----> STOP REC
[(init+) (@DisplayPlayButton:4) {state:1} {text:#none#}]--> NOTHING
PRESS & RELEASE LOGIC
[(press) {@l_triggerAction:nothing} {@lt_localTimer:restart} {@l_pressedButton:1}]
[(release) (@l_pressedButton:1) {@l_pressedButton:0} {@lt_localTimer:reset} {@l_triggerAction:playPauseRecstop}]
[(@lt_localTimer:450) (@l_pressedButton:1) {@l_pressedButton:0} {@lt_localTimer:reset} {@l_triggerAction:playFromLastStop}]
PRESS & RELEASE ACTIONS
[(@l_triggerAction:playPauseRecstop) (@Recording:0) {@l_triggerAction:nothing} {cc:1,31,127}]--------------------------> PLAY PAUSE
[(@l_triggerAction:playPauseRecstop) (@Recording:1) {@l_triggerAction:nothing} {cc:1,31,127}]----------------------------> STOP REC
[(@l_triggerAction:playFromLastStop) (@Recording:0) {@l_triggerAction:nothing} {launch:"Cubase_PlayFromLastStop.app"}]
[(@l_triggerAction:playFromLastStop) (@Recording:1) {@l_triggerAction:nothing} {cc:1,31,127}]----------------------------> STOP REC
Log ID when local vars are not initialized (Cubase launches playing):
f5c41eb3-b8b2-4aa6-b917-71d8c0cbaa66
Log ID when local vars are initialized (Cubase launches stopped, as expected):
5131fa4f-070b-46dd-8cd4-15617fc52234