Total length of MIDI file
See original GitHub issueHey @melanchall,
Thanks for providing this library!
How would you go about getting the total length of a MIDI file? I’ve looked at the example you’ve provided in the README, but this gives you the timing of the last note-off event:
TempoMap tempoMap = midiFile.GetTempoMap();
TimeSpan midiFileDuration = midiFile.GetTimedEvents().LastOrDefault(e => e.Event is NoteOffEvent)?.TimeAs<MetricTimeSpan>(tempoMap) ?? new MetricTimeSpan();
I need the length of the file including any “unused space”.
In the scenario above, what I’m looking for is the value 768 ticks (96 ticks * 8 beats), but if I use the provided code, I get 696 (96 ticks * 7,25 beats (the position of the cursor)).
I’ve tried to look through the wiki, but I can’t seem to figure it out.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
How to determine the length of a Standard Midi File
That equates to 1 hr 6 minutes and 40 seconds. As for when that was added, the MIDI Time Code document section carried...
Read more >Standard MIDI-File Format Spec. 1.1, updated
MIDI Files are made up of -chunks-. Each chunk has a 4-character type and a 32-bit length, which is the number of bytes...
Read more >How to calculate the time-length of a midi-file
I am trying to figure out a simple way to calculate the whole duration of the midi file (for example - total time...
Read more >Standard MIDI File Structure
A standard MIDI file is composed of "chunks". It starts with a header chunk and is followed by one or more track chunks....
Read more >Thread: Get Length of MIDI File
True, in a SMF (Standard Midi File) the length (duration in seconds) is not written anywhere. If you were to parse the file,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@rn1d Version 5.2.1-prerelease8 is published, you can install it via NuGet. Thank you!
🚀 5.2.1 version is released now!
Prerelease NuGet packages will be unlisted soon, so please update the package references to the new version.
Thanks for using the library!