Well, I am looking for a way to calculate polyphony within MIDI
files. The aim would be to feed an indicator showing the current
number of notes which are played simutaneously, and to evaluate
the maximum polyphony reached within a MIDI file.
A basic method would be to add +1 at every new NoteOn
event, and to substract -1 when the same note is switched
off through a NoteOff event. This way, I always get the
(theoretical) number of notes being played simultaneously
at the current time.
But, doing so with some midi files, I will get a wrong indication
of what can be heard, as some MIDI instruments do stop
automatically after a while (case with notes played on piano,
drums, ...) even if no NoteOff event is sent (at least with
the default controls), while with other instruments, notes will
be played and heard forever if we don't stop them by sending
an explicit NoteOff.
Is there any practical way to know when (let's say the number
of milliseconds after NoteOn) a note really stops playing (if it
does), depending on the current instrument, controls, and
MIDI implementation ?
Any tips ?