Problem retrieving MIDI length

Locked
CamperDude3000
User
Posts:2
Joined:Fri Jun 10, 2011 11:26 am
Are you a spambot?:no
Problem retrieving MIDI length

Post by CamperDude3000 » Fri Jun 10, 2011 11:32 am

Hello! I'm making a site with MIDIs and MP3s I've done.

I can retrieve the length of most the MIDIs. But there are two that won't display it. I don't know much about how the MIDI format works internally, so anyone who has any idea what might be different with those two MIDIs?

James Heinrich
getID3() v1 developer
Posts:1477
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada
Contact:

Re: Problem retrieving MIDI length

Post by James Heinrich » Fri Jun 10, 2011 4:15 pm

Most audio (and video) files are a recording of something, that is they captured and play back an exact representation of a certain amount of time. MIDI files (and also MOD files are conceptually similar) are more a description of how to create the music, very similar to sheet music. They may also contain looping sections (go back to X and play to Y again, or play X-Y 3 times, or repeat this section indefinitely) so the playtime is a less strict concept than, for example, MP3 or WAV.

Nevertheless, if you like you can send me those two MIDI files (PM or email) and I'll make sure that getID3 is reading them properly.

James Heinrich
getID3() v1 developer
Posts:1477
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada
Contact:

Re: Problem retrieving MIDI length

Post by James Heinrich » Fri Jun 10, 2011 11:25 pm

It was a bug in getID3(). Basically it wasn't reading enough of the file into the buffer, then aborting when it didn't find what it was expecting. A one-word fix on line 50 of module.audio.midi.php:

Code: Select all

			//if ((strlen($MIDIdata) - $offset) < 8) {
			while ((strlen($MIDIdata) - $offset) < 8) {
				$MIDIdata .= fread($fd, GETID3_FREAD_BUFFER_SIZE);
			}
Patched version for v1.8.5 is attached, fix will be included in v1.9.0 when released.
Attachments
module.audio.midi.php
patched file for v1.8.5
(17.96KiB)Downloaded 714 times

CamperDude3000
User
Posts:2
Joined:Fri Jun 10, 2011 11:26 am
Are you a spambot?:no

Re: Problem retrieving MIDI length

Post by CamperDude3000 » Sat Jun 11, 2011 9:51 pm

Ah, thanx a lot, that fixed it! :D

Locked