Table of Contents

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

initialBpm double

Properties

CurrentBpm

The current (most recently set) tempo in BPM.

public double CurrentBpm { get; }

Property Value

double

Methods

BpmAtTicks(long)

The tempo in BPM in force at the given tick.

public double BpmAtTicks(long ticks)

Parameters

ticks long

Returns

double

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

tick long

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

ticks long

Returns

double

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

bpm double
effectiveAtTicks long

TicksFromSeconds(double)

The tick at which the given real time falls.

public long TicksFromSeconds(double seconds)

Parameters

seconds double

Returns

long