Table of Contents

Class MidiFileSequence

Namespace
NAudio.Midi
Assembly
NAudio.Midi.dll

A MIDI file loaded into the sequencing core: its channel events placed on an EventTimeline<T> at the canonical PPQ (CanonicalPpq), and its tempo changes built into an ITempoMap. Feed it through a SequencedMidiPlayer (or OfflineMidiRenderer) to play it on any IMidiInstrument — the NAudio.Sampler engine, a synthesiser, a hosted VST instrument.

Note/CC/pitch-bend/aftertouch/program and sysex events are kept; other meta events are dropped except SetTempo, which builds the tempo map.

public sealed class MidiFileSequence
Inheritance
MidiFileSequence
Inherited Members

Properties

EndTick

The canonical tick of the last event (0 if empty).

public long EndTick { get; }

Property Value

long

TempoMap

The tempo map built from the file's SetTempo events.

public ITempoMap TempoMap { get; }

Property Value

ITempoMap

TimeSignatureMap

The time-signature map built from the file's time-signature meta events (4/4 from tick 0 when the file specifies none). Always non-null.

public TimeSignatureMap TimeSignatureMap { get; }

Property Value

TimeSignatureMap

Timeline

The channel events at canonical PPQ.

public EventTimeline<MidiEvent> Timeline { get; }

Property Value

EventTimeline<MidiEvent>

Methods

DurationFrames(int, double)

The number of audio frames needed to render the whole sequence plus a release tail, at the given sample rate.

public long DurationFrames(int sampleRate, double tailSeconds)

Parameters

sampleRate int
tailSeconds double

Returns

long

FromFile(string)

Loads and parses a MIDI file.

public static MidiFileSequence FromFile(string path)

Parameters

path string

Returns

MidiFileSequence

FromMidiFile(MidiFile)

Builds a sequence from an already-parsed MidiFile.

public static MidiFileSequence FromMidiFile(MidiFile midiFile)

Parameters

midiFile MidiFile

Returns

MidiFileSequence