Class Transport
- Namespace
- NAudio.Sequencing
- Assembly
- NAudio.Core.dll
Tracks playback position for the sequencing layer. Position is held in both audio frames (the master, since the audio device pulls a frame count) and canonical ticks (derived from the tempo map). Position-mutating methods (AdvanceByFrames(int), SeekTicks(long), SeekFrames(long)) serialise on an internal lock so a UI-thread seek can't race with the audio-thread advance. Position reads (CurrentFrames, CurrentTicks) remain lock-free.
public sealed class Transport
- Inheritance
-
Transport
- Inherited Members
Constructors
Transport(ITempoMap, int)
Creates a new transport at position 0, not playing.
public Transport(ITempoMap tempoMap, int sampleRate)
Parameters
Properties
CurrentFrames
The current playhead position in audio frames since the transport was last seeked or constructed.
public long CurrentFrames { get; }
Property Value
CurrentTicks
The current playhead position in canonical ticks.
public long CurrentTicks { get; }
Property Value
IsPlaying
Whether the transport is currently playing. Used by consumers to gate event dispatch.
public bool IsPlaying { get; }
Property Value
Loop
An optional loop region. When set, CurrentTicks is unbounded but consumers (e.g. SequencedSampleProvider<T>) wrap timeline queries through this region.
public LoopRegion? Loop { get; set; }
Property Value
SampleRate
The sample rate, in frames per second.
public int SampleRate { get; }
Property Value
TempoMap
The tempo map driving real-time → tick conversion.
public ITempoMap TempoMap { get; }
Property Value
Methods
AdvanceByFrames(int)
Advances the playhead by the given number of frames. Called by the consumer after rendering (and dispatching events for) a buffer. The tick position is recomputed from the cumulative frame count via the tempo map so it cannot drift.
public void AdvanceByFrames(int frames)
Parameters
framesint
Play()
Begins playback. Subsequent calls to AdvanceByFrames(int) will advance the playhead.
public void Play()
SeekFrames(long)
Seeks the playhead to the given frame.
public void SeekFrames(long frames)
Parameters
frameslong
SeekTicks(long)
Seeks the playhead to the given tick.
public void SeekTicks(long ticks)
Parameters
tickslong
Stop()
Stops playback. Position is preserved.
public void Stop()