# `Mx.Tempo`
[🔗](https://github.com/mx-music/mx/blob/main/lib/mx/tempo.ex#L1)

The tempo over a song's beats: the timeline the band plays against, and the tempo changes a song's music writes in its sections.

A timeline is a list of entries, the latest first, each `{beat, microseconds, tempo}`.
The tempo is the beats per minute held from that beat, or `{:ramp, from, to, beats}`, which moves evenly in beats per minute from `from` to `to` over that many beats, and is followed by `to` held where it ends.
A change put on the timeline replaces whatever it held from the change's beat on, so the latest change wins.

A song's changes are `%{sections: sections, lengths: lengths, forever: forever}`: each section's changes as `{beat, bpm, over}`, each section's length in beats, and whether the music repeats until mx stops.
Pass `n` plays section `n`, going round again in music that repeats, and a section that plays until mx stops writes its changes in its first pass only.

# `beat_at`

The beat at a real time, in microseconds, on the timeline.

# `changes`

The tempo changes a song writes in a pass, as `{beat, bpm, over}` with beats from the start of the pass.

# `describe`

The tempos the timeline plays at from beat `from` until beat `until`, as text with beats counted from `from`, such as "100 bpm, rising to 130 bpm from beat 0 to 16".

# `new`

A timeline holding one tempo from beat 0, which plays at a real time in microseconds.

# `put`

The timeline with the tempo changed at a beat to `bpm`, at once when `over` is 0, or else evenly over `over` beats.

# `tempo_at`

The tempo in beats per minute at a beat on the timeline.

# `through`

The timeline over beats from 0, at 0 microseconds, with the changes of every pass up to `pass` put on it, and the beat `pass` starts on; `window` is the length of each pass of a section that plays until mx stops.

# `time_at`

The real time, in microseconds, of a beat on the timeline.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
