RE: AudioFileGetProperty values, reading an MP3
RE: AudioFileGetProperty values, reading an MP3
- Subject: RE: AudioFileGetProperty values, reading an MP3
- From: "Edwards, Waverly" <email@hidden>
- Date: Tue, 10 Aug 2010 10:44:08 -0500
- Acceptlanguage: en-US
- Thread-topic: AudioFileGetProperty values, reading an MP3
I just might have it. According to TN2097, it is using kAudioFilePropertyAudioDataByteCount to determine the size of the buffer and using the number of packets returned by kAudioFilePropertyAudioDataPacketCount for use in AudioFileReadPackets(...)
http://developer.apple.com/mac/library/technotes/tn2004/tn2097.html
I *think* I understand now and that how I was using the properties from AudioFileGetProperty to read the audio data may have worked but was not entirely correct.
Thanks,
W.
-----Original Message-----
From: coreaudio-api-bounces+waverly.edwards=email@hidden [mailto:coreaudio-api-bounces+waverly.edwards=email@hidden] On Behalf Of Edwards, Waverly
Sent: Monday, August 09, 2010 10:12 PM
To: William Stewart
Cc: 'email@hidden'
Subject: RE: AudioFileGetProperty values, reading an MP3
Just to get further clarification, in what instance would I use kAudioFilePropertyAudioDataByteCount?
kAudioFilePropertyAudioDataByteCount indicates the number of bytes of audio data in the designated file. Since I'm reading in packets I thought it would be best to use the packet count. Now, I dont know what is the correct means of determining how large the buffer should be to hold the entire sound file.
Thank you,
W.
________________________________________
From: William Stewart [email@hidden]
Sent: Monday, August 09, 2010 8:41 PM
To: Edwards, Waverly
Cc: 'email@hidden'
Subject: Re: AudioFileGetProperty values, reading an MP3
max packet size is the MAX size of any of the packets in the file. This is a conservative estimate, so the multiplication should always provide you a larger number than the actual number of bytes in the file for a format that is variable bit rate (that is, different packets of audio can be different sizes).
In the WAV case, the data is probably linear pcm. This is a CBR format (constant bit rate), so the packets of audio data will all be the same size. You can tell the difference by looking at the value for mBytesPerPacket in the file's data format. If this is !0, then you can calculate the size of the audio data without getting max packet size, as each packet is the same size. If this is 0, then max packet size is a conservative estimate (in cases where this is not completely knowable without scanning the entire file) of the largest packet size in the file.
Bill
On Aug 9, 2010, at 1:34 PM, Edwards, Waverly wrote:
>
> I am reading an MP3 using AudioFileReadPackets and I've come across something strange. After reading the documentation and looking at some examples I am unable to reconcile why the calculated buffer size does not match the byte count I get from AudioFileGetProperty.
>
> err = AudioFileGetProperty(audioFile, kAudioFilePropertyAudioDataPacketCount, &dataSize, &packetCount);
>
> err = AudioFileGetProperty(audioFile, kAudioFilePropertyMaximumPacketSize, &dataSize, &maxPacketSize);
>
> err = AudioFileGetProperty(audioFile, kAudioFilePropertyAudioDataByteCount, &dataSize, &byteCount);
>
> I create a buffer based on the number of packets multiplied by the packet count. The byte count does not match when opening mp3's
>
> buffer = calloc( 1, packetCount * maxPacketSize );
>
> mp3: packetCount * maxPacketSize > byteCount
> wave: packetCount * maxPacketSize == byteCount
>
> I thought the multiplication method would be correct however when I inspect the buffer, there is no sound data in the difference between the two sizes.
>
> Should I always use kAudioFilePropertyAudioDataByteCount to determine my buffer size? Shouldn't these methods always match perfectly?
>
>
> Thanks,
>
>
> W.
> _______________________________________________
> 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
_______________________________________________
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
_______________________________________________
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