Table of Contents

Class MidiEvents

Namespace
Celeritas.Core.Midi
Assembly
Celeritas.dll

Extensions for working with MIDI tempo and time signature events.

public static class MidiEvents
Inheritance
MidiEvents
Inherited Members

Methods

AddTempoChange(TrackChunk, Rational, int, int)

Add a tempo change event to a MIDI track chunk.

public static void AddTempoChange(TrackChunk track, Rational offset, int beatsPerMinute, int ticksPerQuarterNote)

Parameters

track TrackChunk

The track the event is inserted into, in time order.

offset Rational

Where the change takes effect, in whole-note units.

beatsPerMinute int

The new tempo. A SetTempo event holds 24 bits, so roughly 4 is the floor.

ticksPerQuarterNote int

The time division of the file this track belongs to — read it from Melanchall.DryWetMidi.Core.MidiFile.TimeDivision, not from MidiExportOptions, whose default is 480 while a new MidiFile() uses 96. Nothing here can check it: a track does not know its file. Pass the wrong one and the event lands at the wrong time, by exactly the ratio of the two.

AddTimeSignatureChange(TrackChunk, Rational, int, int, int)

Add a time signature change event to a MIDI track chunk.

public static void AddTimeSignatureChange(TrackChunk track, Rational offset, int numerator, int denominator, int ticksPerQuarterNote)

Parameters

track TrackChunk

The track the event is inserted into, in time order.

offset Rational

Where the change takes effect, in whole-note units.

numerator int

Beats per measure, in [1..255].

denominator int

The beat unit as it is written — 4, 8, 16 — a power of two in [1..128].

ticksPerQuarterNote int

The time division of the file this track belongs to, exactly as for AddTempoChange(TrackChunk, Rational, int, int): read it from Melanchall.DryWetMidi.Core.MidiFile.TimeDivision rather than from MidiExportOptions.

GetTempoChanges(string)

Extract all tempo changes from a MIDI file.

public static List<TempoChange> GetTempoChanges(string path)

Parameters

path string

Returns

List<TempoChange>

GetTimeSignatureChanges(string)

Extract all time signature changes from a MIDI file.

public static List<TimeSignatureChange> GetTimeSignatureChanges(string path)

Parameters

path string

Returns

List<TimeSignatureChange>