Michel schrieb:
> Hi all,
>
> 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 ?
>
> Michel
GNMIDI (demo at
http://www.gnmidi.com) has a function for calculating
maximum note polyphony:
http://www.gnmidi.com/handbook/english/midipoly.htm
you need to consider piano pedal controllers and controllers like "all
notes off", they influence the polyphony too.
The real behavior is depending on the selected sound and device (so
could be less than calculated notes if sound turns off automatically
before note off).
The actual number of sound generators used are usually higher than note
polyphony (complex sounds use more generators than simple sounds).
Guenter