stephentoub / MidiSharp

C# library for reading, writing, and manipulating MIDI (*.mid) files.
MIT License
96 stars 23 forks source link

Implement timing conversion #4

Open f3flight opened 6 years ago

f3flight commented 6 years ago

Hi Stephen! I'm embedding this lib into my midi-related project, and I came up with the need to render a timeline of events from a midi file. This is easy if the midi file is timestamp-based, but for bpm-based timing it gets tricky, especially if tempo changes throughout the file. I think it would be great if a function is added to convert MidiSequence timing format from ticks to absolute timestamps. I understand this is a lossy operation, but still a great feature is some cases. If I happen to do this myself I will submit a review, though I'm not sure I'll be able to make this in a robust fashion. At least sharing the idea is already a good step :)

f3flight commented 6 years ago

I've made an implementation of this (at least for Type.One midi), will send a pull request.

f3flight commented 6 years ago

Created https://github.com/stephentoub/MidiSharp/pull/5, please have a look @stephentoub