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: Tim Kemp <email@hidden>
- Date: Sat, 08 Dec 2012 22:46:04 -0500
Hi Dave,
Hmm, doesn't appear to here: ExtAudioFileGetProperty expects an ExtAudioFileRef, whereas AudioFileGetProperty deals with AudioFileIDs which are different opaque types. Casting or ignoring crashes. Is there a way to convert between the types?
Thanks
On 8 Dec 2012, at 22:34, Dave Fernandes wrote:
> 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