[an error occurred while processing this directive]
|
The first (1 to 4) byte(s) in an MTrk will be the first event's delta-time as a variable length quantity. The next data byte is actually the first byte of that event itself. I'll refer to this as the event's Status. For MIDI events, this will be the actual MIDI Status byte (or the first midi data byte if running status). For example, if the byte is hex 90, then this event is a Note-On upon midi channel 0. If for example, the byte was hex 23, you'd have to recall the previous event's status (ie, midi running status). Obviously, the first MIDI event in the MTrk must have a status byte. After a midi status byte comes its 1 or 2 data bytes (depending upon the status - some MIDI messages only have 1 subsequent data byte). After that you'll find the next event's delta time (as a variable quantity), etc.
Это из "midi file format". Тут Вас должно интересовать только "delta time". Просуммируйте эти дельты по всем трекам в отдельности - и найдите максимум - получите время проигрывания файла. Но парсер придется писать полный - чтобы все эвенты и мессаги оно пропускало корректно. Да, и время это в условных попугаях - а величина попугая вычисляется исходя из параметров времянки из хидера (который MThd, там TimeBase) и из meta-eventa #51 (Tempo).
Ну не буду я за Вас все в подробностях вспоминать. Если захотите - разберетесь.
E-mail: info@telesys.ru