Pregunta

I'm currently building a software for displaying music notes from MIDI file. I can get every letter of tones from NoteOn and NoteOff events but I don`t know how I get or how calculate types of notes (whole, half, eigth..) and other time signatures. How I can get it? I looked for some example but without success.

¿Fue útil?

Solución

MIDI doesn't represent notes in absolute quantities, like in classical music. Instead, the length of the note continues until a corresponding note off event is parsed (also it's quite common that MIDI files use a note on event with 0 velocity as a note off, just keep this in mind). So basically you will need to translate the time in ticks between the two events to musical time to know whether use a whole, half, quarter note, etc.

This translation obviously depends on knowing the tempo and time signature, which are MIDI meta events. More information about parsing those can be found here:

http://www.sonicspot.com/guide/midifiles.html

Basically you take the PPQ to find the number of milliseconds per tick, then use the time signature and tempo to find the length of a quarter note in milliseconds. There are some answers on StackOverflow with this conversion, but I'm writing this post on my phone and can't be bothered to look them up right now. :-)

Hope this points you in the right direction!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top