Class StaticTempoMap
- Namespace
- NAudio.Sequencing
- Assembly
- NAudio.Core.dll
An immutable piecewise-constant tempo curve, intended for content with a fully-known tempo map (a MIDI file, an edited DAW project). Lookups are O(log n) over the segment list.
public sealed class StaticTempoMap : ITempoMap
- Inheritance
-
StaticTempoMap
- Implements
- Inherited Members
Remarks
Only stepped tempo changes are supported in v1. Real-world MIDI files almost always represent continuous ramps (accelerando / ritardando) as many small stepped changes, which this handles directly. First-class linear ramps can be added later as a non-breaking extension.
Constructors
StaticTempoMap(IEnumerable<(long StartTick, double Bpm)>)
Creates a tempo map from an ordered set of (tick, BPM) entries. The first entry must start at tick 0. Tick values must be strictly increasing.
public StaticTempoMap(IEnumerable<(long StartTick, double Bpm)> entries)
Parameters
entriesIEnumerable<(long StartTick, double Bpm)>
StaticTempoMap(double)
Convenience overload for a single-tempo map.
public StaticTempoMap(double bpm)
Parameters
bpmdouble
Methods
BpmAtTicks(long)
The tempo in BPM in force at the given tick.
public double BpmAtTicks(long ticks)
Parameters
tickslong
Returns
NextChangeAfter(long)
The tick at which the next tempo change occurs after tick, or null
if no further change is recorded (for a live map, no further change has been scheduled yet).
public long? NextChangeAfter(long tick)
Parameters
ticklong
Returns
- long?
Remarks
Consumers that need a single tempo per process block (e.g. a VST3 host populating
ProcessContext.tempo) use this to decide whether to split a block at the
tempo-change boundary or to use the start-of-block tempo and accept the inaccuracy.
SecondsFromTicks(long)
The real time in seconds at which the given tick falls.
public double SecondsFromTicks(long ticks)
Parameters
tickslong
Returns
TicksFromSeconds(double)
The tick at which the given real time falls.
public long TicksFromSeconds(double seconds)
Parameters
secondsdouble