Don’t know about SimpleMIDIFile, but I seem to recall that determining the duration of pattern came up a while ago and there was no definitive answer/it was deemed to complex.
Hi, here is how to find out the duration of a SimpleMIDIFile:
m.timeMode = \seconds;
m.length; // returns the duration in seconds
If timeMode is not ‘seconds’ it defaults to ‘ticks’, and then the .length returns the duration in ticks. Note that in some cases the endOfTrack message in MIDIFiles can be incorrect, which will also cause .length to give an incorrect result. In such cases it can help to call: