Class MidiEvents
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
trackTrackChunkThe track the event is inserted into, in time order.
offsetRationalWhere the change takes effect, in whole-note units.
beatsPerMinuteintThe new tempo. A SetTempo event holds 24 bits, so roughly 4 is the floor.
ticksPerQuarterNoteintThe 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
trackTrackChunkThe track the event is inserted into, in time order.
offsetRationalWhere the change takes effect, in whole-note units.
numeratorintBeats per measure, in [1..255].
denominatorintThe beat unit as it is written — 4, 8, 16 — a power of two in [1..128].
ticksPerQuarterNoteintThe 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
pathstring
Returns
GetTimeSignatureChanges(string)
Extract all time signature changes from a MIDI file.
public static List<TimeSignatureChange> GetTimeSignatureChanges(string path)
Parameters
pathstring