MusicTheory Docs API Toolbox GitHub NuGet
Contents

API / MusicTheory

TempoMap record

An immutable list of step tempo changes, converting score positions (in whole notes) to seconds and back.

Constructors

TempoMap(double initialBpm, Duration? beatUnit = null)
Initializes a map with one tempo from position 0.
initialBpm
The tempo in beats per minute.
beatUnit
The duration that counts as one beat; a quarter note when null.

Throws ArgumentOutOfRangeException initialBpm is not a positive finite number.

Properties

IReadOnlyList<TempoChange> Changes { get; }
Gets the tempo changes in position order; the first one is at position 0.

Methods

double BpmAt(Rational position)
Gets the tempo in force at a position.
position
The position in whole notes.

Returns The beats per minute.

Throws ArgumentOutOfRangeException A negative position.

bool Equals(TempoMap? other)
Two maps are equal when they hold the same changes in the same order.
int GetHashCode()
double PositionAt(double seconds)
Gets the score position sounding at a time; the inverse of TempoMap.SecondsAt.
seconds
The time in seconds.

Returns The position in whole notes, as a double (a time is not generally an exact position).

Throws ArgumentOutOfRangeException A negative or non-finite time.

double SecondsAt(Rational position)
Gets the time at which a score position sounds. Segment lengths are exact Rationals, converted to seconds one segment at a time, so rounding does not accumulate with the bar count.
position
The position in whole notes.

Returns The time in seconds.

Throws ArgumentOutOfRangeException A negative position.

TempoMap WithChange(Rational position, double bpm, Duration? beatUnit = null)
Returns a map with a tempo change at the position, replacing any change already there.
position
The position in whole notes.
bpm
The tempo in beats per minute.
beatUnit
The duration that counts as one beat; a quarter note when null.

Returns A new map.

Throws ArgumentOutOfRangeException A negative position, or a tempo that is not positive and finite.