Re: AudioFileGetProperty values, reading an MP3
Re: AudioFileGetProperty values, reading an MP3
- Subject: Re: AudioFileGetProperty values, reading an MP3
- From: William Stewart <email@hidden>
- Date: Mon, 9 Aug 2010 17:41:35 -0700
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