File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,15 @@ public function Analyze() {
330330 }
331331 }
332332
333+ // Fallback: If playtime_seconds is still empty/zero, estimate using default tempo
334+ // 120 BPM = 0.5 per quarter note = 480 quarternote ticks
335+ if (empty ($ info ['playtime_seconds ' ]) && !empty ($ thisfile_midi ['totalticks ' ])) {
336+ $ ticksPerQuarterNote = isset ($ thisfile_midi_raw ['ticksperqnote ' ]) ? $ thisfile_midi_raw ['ticksperqnote ' ] : 480 ;
337+ if ($ ticksPerQuarterNote > 0 ) {
338+ $ totalQuarterNotes = $ thisfile_midi ['totalticks ' ] / $ ticksPerQuarterNote ;
339+ $ info ['playtime_seconds ' ] = $ totalQuarterNotes * 0.5 ;
340+ }
341+ }
333342
334343 if (!empty ($ info ['playtime_seconds ' ])) {
335344 $ info ['bitrate ' ] = (($ info ['avdataend ' ] - $ info ['avdataoffset ' ]) * 8 ) / $ info ['playtime_seconds ' ];
You can’t perform that action at this time.
0 commit comments