On Timeline

<< Click to Display Table of Contents >>

Navigation:  Callbacks > Playhead Events >

On Timeline

Usage:

On Timeline([barNumber : Integer, beatNumber : Integer]) [EveryBeat]

   [Prolog statements]

    BarBeat Entries // (see below)

   [Epilog statements]

end

 

This callback should generally be used instead of the On BeatChanged callback, particularly if you want to construct a long timeline as, rather than having to use IF THEN tests to determine the current bar (and actions), this callback is optimized so that the appropriate actions will be called in constant time without the need for user tests.

Example 1:

On Timeline

   1:1

      Print("Playhead just started")

 

   2:2

      Print("We are at bar 2 beat 2")

      SetWidgetValue(SomeWidget, 0.5)

 

   84:3

      Print("OK -- we are a long way into the timeline now")

End

 

The example above is very simple --- you define some bar:beat values and a sequence of GPScript statements to execute when the playhead reaches that point

Example 2:

On Timeline

   Prolog

      Print("This optional code gets executed before the code for the specific beat is triggered")

   End 

   1:1

      Print("Playhead just started")

 

   2:2

      Print("We are at bar 2 beat 2")

      SetWidgetValue(SomeWidget, 0.5)

 

   84:3

      Print("OK -- we are a long way into the timeline now")

 

   Epilog

      Print("This optional code gets executed after the code for the specific beat is triggered")

                      End

End

 

As shown in example 2, you can define a prolog and/or an epilog that will be triggered before or after respectively the time entry statements are triggered. This is useful if you want to do something before or after every time entry.

However, be careful. By default, the On Timeline callback is triggered only when there a matching time specified.As a case in point,  in the example above, the prolog and epilog will only be executed when the playhead is at 1:1, 2:2 or 84:3

Example 3:

On Timeline EveryBeat

   Prolog

      Print("This optional code gets executed at every beat")

   End

 

   1:1

      Print("Playhead just started")

 

   2:2

      Print("We are at bar 2 beat 2")

      SetWidgetValue(SomeWidget, 0.5)

 

   84:3

      Print("OK -- we are a long way into the timeline now")

 

   Epilog

      Print("This optional code gets executed at every beat")

                       End

End

 

In this example, the keyword EveryBeat following the callback name indicates that this callback should occur on every beat regardless whether there is a matching time entry. In this mode, the On Timeline replicates the On BeatChanged callback