Class LiveTempoMap
- Namespace
- NAudio.Sequencing
- Assembly
- NAudio.Core.dll
A tempo map with a single mutable "current" tempo, intended for live consumers (the drum-machine tempo knob, a real-time-input keyboard performance). Past tempo segments are frozen as they are observed; SetTempo(double, long) only changes the future. Writers serialise on an internal lock; readers are lock-free (segment array is swapped atomically).
public sealed class LiveTempoMap : ITempoMap
- Inheritance
-
LiveTempoMap
- Implements
- Inherited Members
Constructors
LiveTempoMap(double)
Creates a tempo map starting at the given BPM from tick 0.
public LiveTempoMap(double initialBpm)
Parameters
initialBpmdouble
Properties
CurrentBpm
The current (most recently set) tempo in BPM.
public double CurrentBpm { get; }
Property Value
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
SetTempo(double, long)
Sets the tempo from effectiveAtTicks onward. The tick must be at or
after the last segment's start. If it equals the last segment's start (no progress observed yet),
the last segment is replaced rather than appended.
public void SetTempo(double bpm, long effectiveAtTicks)
Parameters
TicksFromSeconds(double)
The tick at which the given real time falls.
public long TicksFromSeconds(double seconds)
Parameters
secondsdouble