Tagged: Sleep stop the macro, waitduration
- This topic has 3 replies, 2 voices, and was last updated 9 months, 3 weeks ago by Philippe.
-
AuthorPosts
-
31 January 2024 at 10 h 03 min #6269DanielAkerbergMember
Hello!
In a matrix I have the following code:
—
CaseBranch 1
Set $rndSliceActivated$ = false // User Variable that correctly stops a Slicer related While loop in another Matrix
MidiSend “Launchpad MK2” 150 106 5
Sleep 500
TrackLoopReset trk_all
InsertSendMessage fx1 1 <>
BreakCaseBranch
—
Whatever I do I cannot get the “TrackLoopReset trk_all” or “InsertSendMessage fx1 1 <>” to fire, or at least to correctly reset the Main Looper or the Insert Looper. When I trigger the exact same code in a “normal” macro (non-matrix related) I correctly resets.Thanks!
31 January 2024 at 11 h 55 min #6276PhilippeKeymasterPlease, send the entire macro code.
Thanks,
Philippe31 January 2024 at 15 h 39 min #6277DanielAkerbergMemberSure. Below is the full Matrix Macro:
—Start—
Declare Local Once boolean $firstTime$ = true
Declare Local int $itemID$ = 0
Declare Local int $itemSize$ = 56
Declare Local int $verticalPosition$ = 1Declare Once boolean $rndSliceActivated$ = false
If { $firstTime$ }
$firstTime$ = false//Sleep 300
SendData thispatcher itemamount 2Sleep 200
SendData mainWindow setsize 463 {30 + ($itemSize$ * 1)}
SendData item 0 fontface regular
//SendData button 0 fontsize 40
SendData item 0 bgcolor 0. 0. 0. 1.;
SendData item 0 bgoncolor 0.773 0.145 0.196 1.;
SendData item 0 bordercolor 0.2 0.2 0.2 1.;
SendData item 0 borderoncolor 0.2 0.2 0.2 1.;
SendData item 0 textcolor 0.827 0.827 0.824 1.
SendData item 0 textoncolor 0.827 0.827 0.824 1.;SendData thispatcher basicdisposition
SendData MacroInitialized
MacroStop
EndIf// Which Case is it ?
Message { “Button, Dial or SVG number ” + currentCaseValueString() + ” : ” + currentCaseOptionValueFloat(0)}CaseBranch 1
Set $rndSliceActivated$ = false
MidiSend “Launchpad MK2” 150 106 5
Sleep 500
TrackLoopReset trk_all
InsertSendMessage fx1 1 <>
BreakCaseBranchCaseBranch 2
MacroStartIfNeededOnSlot 49
MidiSend “Launchpad MK2” 150 99 16
BreakCaseBranchEndCaseBranches
Sleep 500MidiSend “Launchpad MK2” 150 106 0
MidiSend “Launchpad MK2” 150 99 0
—End—31 January 2024 at 17 h 02 min #6279PhilippeKeymasterThank you.
So I could make some investigation…
And it appears that Sleep is the culprit !In the Sleep documentation it is written “Important difference with WaitDuration: A Sleep action will be interrupted if the macro receives a User Action. No option can change this behaviour. If you want to wait a duration without the risk to interrupt it, use WaitDuration action.”
And in a Matrix, the macro will receive many user actions like button down, button up, button long press, etc. So, if the macro is Sleeping and receives a new action, it will stop immediately. That will not be the case with all Wait… actions. So you should use WaitDuration in place of all Sleep.
I recommend using WaitDuration in every situation as it is more robust. Sleep was an old action, we keep it for legacy compatibility.
We will see if that’s possible to produce an error when a Sleep appears in a matrix macro.
Best,
Philippe -
AuthorPosts
- You must be logged in to reply to this topic.