I am reading a midi file with this parser. But I cannot read the real time.
MidiFile midiFile = new MidiFile("/Jenkins.mid");
var ticksPerQuarterNote = _midiFile.TicksPerQuarterNote;
foreach (MidiTrack track in midiFile.Tracks)
{
foreach (MidiEvent midiEvent in track.MidiEvents)
{
if (midiEvent.MidiEventType != MidiEventType.NoteOn)
continue;
int note = midiEvent.Note;
int time = midiEvent.Time;
}
}
All the formulas I have seen on the internet use the tempo, but I can't find it.
You can use my DryWetMIDI library which does all these calculations for you:
Here we get metric time (hours/minutes/seconds/ms), but the library provides several other formats you can convert MIDI time to. Please read the article of the library docs to learn more: Time and length.
More than that if you actually want to get notes instead of events, it's super easy with DryWetMIDI:
You can also use
TimeAsmethod on notes.