Home Forums Macros Loopers will not reset In and Out selection within Matrix Macro

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6269

    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!

    #6276
    Philippe OllivierPhilippe
    Keymaster

    Please, send the entire macro code.
    Thanks,
    Philippe

    #6277

    Sure. 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$ = 1

    Declare Once boolean $rndSliceActivated$ = false

    If { $firstTime$ }
    $firstTime$ = false

    //Sleep 300
    SendData thispatcher itemamount 2

    Sleep 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 <>
    BreakCaseBranch

    CaseBranch 2
    MacroStartIfNeededOnSlot 49
    MidiSend “Launchpad MK2” 150 99 16
    BreakCaseBranch

    EndCaseBranches
    Sleep 500

    MidiSend “Launchpad MK2” 150 106 0
    MidiSend “Launchpad MK2” 150 99 0
    —End—

    #6279
    Philippe OllivierPhilippe
    Keymaster

    Thank 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.