Re: How to find loop length of MP3
Re: How to find loop length of MP3
- Subject: Re: How to find loop length of MP3
- From: Kevin Boyce <email@hidden>
- Date: Fri, 12 Nov 2010 21:52:01 -0500
To follow up on this, I found a strange solution, possibly a bug in
AudioFile.
I was getting integer numbers of seconds for
kAudioFilePropertyEstimatedDuration which seemed rather odd. Turns
out I get a much more accurate number after reading the ExtAudioFile
property kExtAudioFileProperty_FileLengthFrames. Perhaps that forces
a scan of the file? If so, it would be nice if that were added to the
documentation. If not, it should be a bug.
So now I read kExtAudioFileProperty_FileLengthFrames and discard it,
since it seems to include priming and/or trailing frames, and then use
kAudioFilePropertyEstimatedDuration to get the maximum loop length.
As near as I can tell, that works. Pure luck I stumbled across it
though.
-Kevin
On Nov 9, 2010, at 8:17 AM, Kevin Boyce wrote:
Thanks, I may end up using that. I guess what I really want is to
know how long the AudioFile Player thinks a file is, so I can be
sure to set a loop length equal to or less than that limit. If I
have to scan the entire file, so be it.
Thanks,
Kevin
On Nov 8, 2010, at 11:04 PM, Stephen F. Booth wrote:
Hi Kevin,
You may or not may be able to accurately determine how many audio
frames are in an MP3. If the encoder wrote a proper Xing/Info/LAME
header you're in luck. If it didn't, well, you would have to
guesstimate.
The definition of the Info header is on http://gabriel.mp3-tech.org/mp3infotag.html
I've written code using MAD to decode MP3s, including parsing the
Xing/Info header: https://github.com/sbooth/SFBAudioEngine/blob/master/Decoders/MPEGDecoder.cpp
I assume you could use AudioFile to read a single MPEG frame
(packet) and pull the Info header from that, but I've never tried.
Stephen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden