It is possible to make repeated actions in Macros.
This is two manners :
DoRepeat
// Everything here is repeated indefinitely
While true
or :
RepeatWhile true
// Everything here is repeated indefinitely.
EndRepeat
If you want you can add a break in this repeated action.
DoRepeat
// Everything here is repeated indefinitely.
Sleep 10
// Sleep 10 will stop the loop for 10 milliseconds
While true
The macro can also wait a user action to repeat the action :
DoRepeat
// Everything here is repeated indefinitely.
WaitUserAction
// The action will be repeated when the user call the macro again
While true
The loop can also happen on a metronome beat :
// Don’t forget to start the Metro events
MetroActivateEvents true
DoRepeat
// Everything here is repeated indefinitely.
WaitMetroSomeBeats 1
//at each next beat, the action is repeated
While true
A counter can stop the repeated actions:
Set $my_personnal_counter$ = 0
</ br>
<br />
DoRepeat
Set $my_personnal_counter$ = {$my_personnal_counter$ + 1}
// Each time the action is repeated, the count is incremented
Message $my_personnal_counter$
Sleep 10
While { $my_personnal_counter$ < 40 }
// The repeat will occurs until $my_personnal_counter$ reach 40
A macro can contain more than one loop:
Set $my_personnal_counter$ = 0
DoRepeat
Set $my_personnal_counter$ = {$my_personnal_counter$ + 1}
// Each time the action is repeated, the count is incremented
Message $my_personnal_counter$
//This macro change the volume of track 1 (Up)
TrackVolume trk1 = {$my_personnal_counter$ – 76}
Sleep 10
While { $my_personnal_counter$ < 76 }
// The repeat will occurs until $my_personnal_counter$ reach 76
DoRepeat Set $my_personnal_counter$ = {$my_personnal_counter$ – 1}
// Each time the action is repeated, the count is incremented
Message $my_personnal_counter$
//This macro change the volume of track 1 (Down)
TrackVolume trk1 = {$my_personnal_counter$ – 76}
Sleep 10
While { $my_personnal_counter$ > 0 }
// The repeat will occurs until $my_personnal_counter$ reach 0
Eventually, this macro can be finished by RestartMacro and then, the macro will only stop when the user stop it.
It is possible to integrate a loop in another loop :
//Counter init
Set $my_track$ = 0
// Set each track volume at -76
DoRepeat
Set $my_track$ = {$my_track$ + 1}
//VarLoopTrack set trk_x at the value of $my_track$
VarLoopTrack trk_x $my_track$
TrackVolume trk_x = -76
// action repeated until the counter reach 10
While { $my_track$ < 10}
//Set the track counter at 0
Set $my_track$ = 0
//Begin of the Volume increasing for each track
//RepeatWhile will change the selected track
RepeatWhile {$my_track$ < 10}
Set $my_track$ = {$my_track$ + 1}
VarLoopTrack trk_x $my_track$
Message $my_track$
//Set Volume value to 0
Set $my_personnal_counter$ = 0
//DoRepeat will calculate the volume value
DoRepeat
Set $my_personnal_counter$ = {$my_personnal_counter$ + 1}
// Each time the action is repeated, the count is incremented
// Change the volume of track 1 (UP)
TrackVolume trk_x = {$my_personnal_counter$ – 76}
Sleep 10
//While stop the loop who begin by DoRepeat
While { $my_personnal_counter$ < 76 }
// Dorepeat will be repeated until $my_personnal_counter$ reach 76
//EndRepeat close a RepeatWhile loop
EndRepeat
A break can occurs when the user call the macro again. This permit to a have an infinite loop and stop it to make something else, maybe, another loop!.
//This macro can be used by SFX Distortion inserted in slot 1
//This variable will choose the track in which insert the distortion effect
Set $selected_track_for_distortion$ = 0
//Distortion duration by track
Set $distortion_lenght$ = 100
//This is a Chaser with the distortion
//This variable will be used to know if the break can occurs or not
Redeclare boolean $user_action_catched$ = false
//BeginSignalCatchBlock start the break listener (somehow like WaitUserAction, but non-blocking)
BeginSignalCatchBlock
//Begin of the loop
DoRepeat
Set $selected_track_for_distortion$ = {$selected_track_for_distortion$ + 1}
//The IfThen condition permits to insert the Distortion only on tracks where there is some audio content
//This variable $current_full_tracks_count$ tell us how many track contains audio content
IfThen { $selected_track_for_distortion$ > $current_full_tracks_count$ } Do Set $selected_track_for_distortion$ = 1
//insert the distortion on this track and wait the $distortion_lenght$ lenght to stop the disto again
SFXSendMessage 1 $selected_track_for_distortion$ ON
Sleep $distortion_lenght$
SFXSendMessage 1 $selected_track_for_distortion$ OFF
Sleep $distortion_lenght$
//! mean inverse, then !false = true
//If the user do nothing, $user_action_catched$ is false, a the !$user_action_catched$ condition is true
While { !$user_action_catched$ }
//If the user call the macro, $user_action_catched$ is true
//If the case, the loop is breaked and the macro go to next step
EndSignalCatchBlock OnSignalCatched Do Set $user_action_catched$ = true
//When quitting the look, there is another loop who put every inserted disto to OFF
// When the macro is stopped, there is no more distortion
Set $init_de_coda$ = 0
DoRepeat
Set $init_de_coda$ = {$init_de_coda$ + 1}
SFXSendMessage 1 $init_de_coda$ OFF
While {$init_de_coda$ < 10 }