Author Topic: Delay an action and all following actions by time  (Read 363 times)

Offline amigabird

  • Newbie
  • *
  • Posts: 3
Delay an action and all following actions by time
« on: September 09, 2019, 07:23:48 AM »
Hey all, this is Andy.

I am currently in the process to bring life to my two controllers (CME UF-6 and M-Audio Trigger Finger) via AZ Controller. I was able to setup a bus with VST effects and can control all aspects via the knobs for both controllers.

With the Trigger Finger I also want to jump to markers in my song during playback and set a loop on the fly for that marker with a press of a button. However, my problem is, that the search marker command takes too much time, meaning that the following commands are executed too early. I have not understood, how I can delay these commands by let's say a second.

Here is an example of the actions behind a button:

- Track 1 All (Strip / Track / First / add Set based shift / +1 / All)
    > Marks the second track
- Select Strip (Function / Select Strip)
    > Executes the selection
- Search marker "Part 2" (Marker / GoTo / From the beginning / +0 / "Markers" / "Part 2")
    > Jumps to Marker 2
- TIMER?
    > The execution of the marker search takes time, so I would need to wait now....
- Select Clip (Function Select Clip)
    > Selects a clip at track 2 (clip length equals marker length)
- Command "Set loop times to match selection" (Command / Set loop times....)
    > Sets a loop in the length of the selected strip

Since positioning the cursor to the marker beginning after searching it costs time, my problem is that the clip selection fails (a wrong clip is selected depending on song position). The loops are pretty long, so there's lots of time before the loop has to be set. I am looking for a way to delay the last two commands for let's say a second to be sure that the correct clip is selected. Is this possible, and how?

Your help would be much appreciated!

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1240
Re: Delay an action and all following actions by time
« Reply #1 on: September 09, 2019, 09:39:04 AM »
Have a look at this thread (and an example preset at the end): http://www.azslow.com/index.php/topic,484.0.html

Please let me know if that is not sufficient, I can make another example for your action list.

Offline amigabird

  • Newbie
  • *
  • Posts: 3
Re: Delay an action and all following actions by time
« Reply #2 on: September 10, 2019, 06:34:40 AM »
@azslow3 Thank you so much for taking the time to respond! :)

Your link to the other thread has inspired me, and I think I understood the timer a little bit better now. However, my new approach has a problem which I don't understand.

I have attached 2 screenshots to show the logic behind the button event, and the feedback for the timer.
My new logic uses recursion to go through the same code 3 times. I also defined a software state used to remember in which state of recursion the execution of the logic is.


Here is a recap of what should happen in short words:

1st Loop (Button Press)
The software state is not yet initialized, therefore the script only sets focus to track 2, then sets the software state to "1st Loop", calls the timer which sets the software state to "2nd Loop" and calls the logic in recursion.

2nd Loop
The logic sets focus again, then searches and jumps to marker "Part 2". With help of the timer the software state is changed to "3rd Loop", and the logic is called in recursion.

3rd Loop
The logic sets focus again, then selects the clip and sets the loop, which also ends the execution of the logic. This is the jump out of the recursion.


1st Loop and 2nd Loop work exactly as expected. The 3rd Loop however seems not to be executed at all. The clip is not selected, and the loop is not set. Nothing else seems to happen. I feel like the approach has brought me close, but I don't really understand why the 3rd cycle isn't executed. Maybe I misunderstood how the timer works?

If I may ask, would you have an idea what I overlooked here?


*I forgot to mention that the feedback commands visible in the second screenshot are currently identical between both timers.
« Last Edit: September 10, 2019, 06:51:49 AM by amigabird »

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1240
Re: Delay an action and all following actions by time
« Reply #3 on: September 10, 2019, 10:20:40 AM »
You can attach preset files (spp), that is better then screenshot since I can see and modify it.

In general, you need just one timer. But it has to "send MIDI" to trigger execution in the Logic context.
Timers are working in Feedback context, even in case you call a "function". And most actions are void in that context (only Actions selectable in Feedback lists can
work in Feedback context). Also normally you ask to trigger Timer after some delay, Cakewalk normally needs significant time to move time, select clips, etc.

All that is a bit tricky, I know  ;)   

Offline amigabird

  • Newbie
  • *
  • Posts: 3
Re: Delay an action and all following actions by time
« Reply #4 on: September 11, 2019, 07:37:04 AM »
Cakewalk just became a live controlled DAW!

Thank you so much @azslow3 for guiding me into the right direction.
I was able to fix all problems regarding jumping to and looping markers via pads.

Attached I share my example preset file in case someone else is interested on how to do it.

This is what you need to prepare
- Set a marker with the name "Part 2"
- Make a clip on track 2 that starts at the same position as the marker and has the desired length of the marker area
- Assign a pad button of your controller to Hardware Control "Example Pad"
- Press play...

Here is a quick walk-through:

After pressing the pad the logic "Example Pad" is executed. This turns any loop off, searches for the marker, and sets a timer which gets executed after 2 seconds.

The timer (see Feedback) sends a MIDI CC 112 message. This results in executing the logic "CC112 (Set a Loop)". This selects track 2, selects the clip at the current position, and sets the loop. Since the clip determines the length, your marker can have any length you desire. :)

This is very cool. Can't wait to play with this new tools on stream!
Thanks again so much @azslow3. Cheers!  8)