## Temporal Variables

Starting version \(0.8\), Antescofo provides a feature to track the progression of any kind of performance P through the updates to a variable. The variable is used to infer the tempo of P and any sequence of actions can be synchronized with it, the same way a sequence of actions can be synchronized with the musician.

Such variables are called temporal variables. They abstract the “position” and the “speed” of P: each time P progress, it updates the associated variable, which corresponds to a predefined progression in the position of P. The “tempo of the variable” is computed using the same algorithm used by the listening machine to track the tempo of the musician.

Temporal variables are declared using the `@tempovar` declaration:

              @tempovar $v(60, 1/2),  $w(45, 1)

defines two variables `$v` and `$w`. Variable `$v` has an initial tempo of \(60\) BPM and periodic updates of \(1/2\) beats, whereas `$w` has an initial tempo of \(45\) BPM and expected periodic updates of \(1.0\) beat.

Temporal variables are regular variables that can be used in expressions. The value of a temporal variable is the last assigned value or undefined (as for an ordinary variable). In addition, a temporal variable stores the following internal information that can be accessed at any time:

- `$v.tempo` represents the internal tempo of `$v` as tracked by Large's algorithm. This attribute is initialized by the first parameter of the `@tempovar` declaration.

- `$v.position` represents current beat position of `$v`. This attribute is initialized to 0.

- `$v.frequency` represents frequency (period) of `$v`. This attribute is initialized by the inverse of the second parameter of the `@tempovar` declaration.

- `$v.rnow` represents relative time of `$v`

Such internal attributes can be changed at any time like regular variables. For example:

                let $v.tempo := 55  // change the current tempo of $v

### The `@sync` synchronization attribute

Using temporal variables, it is possible to define synchronization strategies of groups, loops, proc, etc., based on the progression recorded by a temporal variable, using the attribute `@sync` as below:

            group
            @sync $v
            @target[5s]
            {
                    ; actions...
            }

Temporal variables can be set by the environment, cf. setvar, allowing for easy tracking any kind of external processes and the synchronization on it. Temporal variables can also be used to set synchronization coordination schemes different than that of the human musician it follows.

### Comparing score following and temporal variables

The table below compares the features offered by the score following (listening machine) and temporal variables:

features | score following | temporal variable `$v`
--- | --- | ---
event | musical event detected by the listening machine | update of `$v`
elementary progression | an amount corresponding to the duration of the detected event | a fixed amount specified in the `@tempovar` declaration
position of last event | `$BEAT_POS` | `$v.position`
current position | `$RNOW` | `$v.RNOW`
progression speed | `$RT_TEMPO` | `$v.tempo`
progression speed estimation by | Large's algorithm | Large's algorithm
position is updatable | NO | YES
progression speed is updatable | NO | YES

Nota Bene:

- The value assigned to a temporal variable does not matter in the synchronization mechanism, nor in the position and progression speed tracking.

- Unlike a score, each event (update) of a temporal variable corresponds to a progression of the same quantity.

- Contrary to score following, the tracking parameter can be updated directly, directly impacting the progression of the sequence of actions synchronized with it.

#### Search

From here you can search these documents. Enter your search terms below.