Re: Get number of frames for CAF LPCM for AudioFilePlayer unit
Re: Get number of frames for CAF LPCM for AudioFilePlayer unit
- Subject: Re: Get number of frames for CAF LPCM for AudioFilePlayer unit
- From: Dave Fernandes <email@hidden>
- Date: Sat, 08 Dec 2012 22:34:45 -0500
This works:
SInt64 nFrames;
UInt32 paramSize = sizeof(SInt64);
err = ExtAudioFileGetProperty(audioFile,
kExtAudioFileProperty_FileLengthFrames,
¶mSize, &nFrames);
On 2012-12-08, at 9:30 PM, Tim Kemp <email@hidden> wrote:
> I have some stereo audio in lpcm written to a CAF file. I want to play it back using an AUFilePlayer. I set up a region like this:
>
> // Get file length
> UInt64 nPackets;
> UInt32 nPacketsSize = sizeof(nPackets);
> checkError(AudioFileGetProperty(audioFile,
> kAudioFilePropertyAudioDataByteCount,
> &nPacketsSize,
> &nPackets),
> "ExtAudioFileGetProperty failed: obtaining length of playback file", false);
>
> // Setup the region
> ScheduledAudioFileRegion rgn;
> memset(&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));
> rgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
> rgn.mTimeStamp.mSampleTime = 0;
> rgn.mCompletionProc = NULL;
> rgn.mCompletionProcUserData = NULL;
> rgn.mAudioFile = audioFile;
> rgn.mLoopCount = 1;
> rgn.mStartFrame = 0;
> rgn.mFramesToPlay = nPackets * fileDesc.mFramesPerPacket;
>
> But it crashes during playback. I think this is because nPackets is always zero (checked right after the AudioFileGetProperty call.) Is there a better way to obtain the number of frames to play? Also, why is nPackets zero here? What should I be looking to check?
>
> Thanks
>
>
> _______________________________________________
> 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