Home Forums Macros ExecuteCaseBranch [value] (feature request)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7155
    Patrick KiznyPacocreative
    Participant

    Hey Philippe,

    I inquired about the equivalent of defining functions in macros to tighten the code, avoid redundancies and facilitate maintenance.
    Haven’t got a reply or workaround, but this feature would make a huge difference to me.

    Perhaps you could add a “ExecuteCaseBranch” command, accepting a single or multiple parameters?
    That would allow to use casebranches as functions, at least within a single macro.
    If this can be made to talk across 2 different matrix macros – even better.

    My macros are currently ~2500 lines each and I have several of them.
    Often times, I need to repeat code unnecessarily – like stopping metronome and similar things…
    I also recently programmed LaunchpadX and Launch Control XL controls for 8 modular loopers on FX tracks, each of tracks being essentially the same page of code, except for the track number. My programmer heart cries doing so 🙂

    If you can suggest any other workarounds – please do.

    Thank you!

    #7167
    Philippe OllivierPhilippe
    Keymaster

    Hi,
    I think you can do it with the SetCurrentCaseValue functionnality.
    Please look at the script below where I use SetCurrentCaseValue to redirect to a specific caseBranch.
    Is that ok in your situation ?
    Philippe

    CaseBranch "My song one"
    	Post "My song one..."
    EndCaseBranches
    
    CaseBranch "My song four"
    	Post "My song four..."
    
    	SetCurrentCaseValue "My song one"
    	WaitDuration 10
    	MacroRestart
    EndCaseBranches
    #7174
    Patrick KiznyPacocreative
    Participant

    I was going through the docs, but I wasn’t able to figure out this could do the job. Now this makes sense and could work.

    How can I pass the last value coming from a midi trigger (like a CC value)?
    I’m using it in the context of Matrix, and all cases are triggered with midi.
    Many make use of the value provided from midi.
    I mean I could use another variable to store that, but maybe I don’t have to?

    Thanks

    #7177
    Patrick KiznyPacocreative
    Participant

    One thing I’m seeing already is that I can use it only once from a case branch.
    So, unless you suggest another workaround I can’t achieve something like this:

    CaseBranch "Do this"
    	ExecuteCase "DoThat1"
    	ExecuteCase "DoThat2"
    	ExecuteCase "DoThat3"
    EndCaseBranch
    #7179
    Philippe OllivierPhilippe
    Keymaster

    OK, there is another way to do this and this is the way I do it ! -)

    Inside the matrix, you put this :

    
    // You need to declare the variable in every macro you use it
    Declare Once int $externalActionCount$ = 10
    
    // Here is the macro initialization
    
    // Here is a case branch
    CaseBranch "My song two"
    	Post "Begin of the second song"
    
            // inside the casebranch, you can set a global variable that will be used in another macro
    	$externalActionCount$ = 5
    
            // Here you start the second macro which is loaded in a standart macro slot
    	MacroStartIfNeededByName "External Action"
    
            // With WaitSignalNotification, the matrix macro will wait the signal from the other macro saying the action is finished
            // WaitSignalNotification is optional
    
    	WaitSignalNotification ExternalActionIsFinished
    
    	Post "Back to Case Branch 2"
    
    EndCaseBranches

    In the external macro called “External Action”, you put this code :

    
    // You need to declare the variable in every macro you use it
    Declare Once int $externalActionCount$ = 10
    Declare int $currentCount$ = 0
    
    // This macro execute an external action and send a signal when it is finnished.
    
    Post "This macro is doing an external action"
    
    DoRepeat
    	$currentCount$ = {$currentCount$ + 1}
    	Post {"count " + $currentCount$}
    
    	Sleep 30
    While {$currentCount$ < $externalActionCount$}
    
    // When the doRepeat loop is finished, the macro send the notification with NotifySignal
    // NotifySignal is optionnal
    
    NotifySignal ExternalActionIsFinished
    #7183
    Patrick KiznyPacocreative
    Participant

    That makes sense.
    Or similarly, I could restrict myself to using a single CaseBranch extension, but put a lot of features there and use flags to execute them selectively.
    Thanks!

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