# timing

## Event timing with transport

This patch shows a simple use of a transport-governed metronome to trigger events at a constant rate. The metro object that has the argument '4n' will be governed by the transport because its interval is specified in a tempo-relative, music-based "note values" format. (Just for the sake of comparison, the patch includes another metro that is unaffected by the transport because its interval is specified in milliseconds.) The transport-governed metro will only run when the transport is on.

## Try the timedbangs abstraction

This patch demonstrates the use of the abstraction presented in the example "Abstraction to trigger a timed series of bangs".

If you click on the button immediately, the typed-in arguments will be used: 9 bangs 125 milliseconds apart. You can enter different numbers in the second and third inlets, or you can trigger a set of bangs immediately with a list in the first inlet.

## Abstraction to trigger a timed series of bangs

A common need in computer music is to schedule events to occur at regular intervals of time. This patch can be used as an abstraction for easily scheduling a specific number of events to occur at regular intervals.

## Transport-controlled phasor~

A phasor~ object, like other MSP objects such as cycle~ that use a rate for their timing, can have its repetition rate specified as a transport-related tempo-relative time value (note values, ticks, etc.). So if you want a phasor~ to work at a rate that is related to the transport's tempo, you can type in a tempo-relative time as an argument to specify its period of repetition instead of typing in a frequency.

## Triggering events with each cycle of a phasor~

How do we detect, with sample-accurate precision, the precise moment when phasor~ begins a new cycle from 0 to 1? We need to detect the sample on which it leaps from 1 back to 0. However, because phasor~ is constantly interpolating between 0 and 1, it might not leap down to exactly 0. So we can't just use a ==~ object to see when its value is 0.

## The translate object updates its output when the tempo changes

The translate object converts a message from one type of time unit to another. It uses the tempo and the time signature of the transport to do that calculation. If the tempo or the time signature changes, the result of the calculation would be different, so translate always resends its output whenever the transport receives a change to one of those values.

## Other basic functionality of the transport object

This patch does some of the same things as the "GlobalTransport" patch in the Extras menu, and shows what is likely going on behind the scenes in that patch. The toggle labeled "Start/Stop" starts the transport and immediately turns on the metro to begin triggering time reports. The button labeled "Rewind" sends a time position of bar 1, beat 1, 0 ticks to the transport to reset its time.

## Simple demonstration of the transport object

Timing objects such as metro normally operate with their time interval specified in milliseconds, and they are controlled by the Max scheduler, which is always running.