Re: Calculating duration of an AIF file
Re: Calculating duration of an AIF file
- Subject: Re: Calculating duration of an AIF file
- From: tahome izwah <email@hidden>
- Date: Sat, 5 Dec 2009 13:44:26 +0100
Looks like you're passing the wrong variable type (should be a Float64
not a UInt64).
AudioFile.h states:
@constant kAudioFilePropertyEstimatedDuration
The value is a Float64 representing an estimated duration in
seconds. If duration can be calculated without scanning the entire
file,
or all the audio data packets have been scanned, the value will
accurately reflect the duration of the audio data.
HTH
--th
2009/12/5 Harry G <email@hidden>:
> Hi there I'm trying to calculate the duration of an AIF file, could you have
> a quick look at this code please and tell me where im going wrong. I'm
> developing this on the iPhone. The result is always 0. Thanks in advance.
>
> + (UInt64)getAudioFileDuration:(NSString*)soundPath {
> NSURL *afUrl = [NSURL fileURLWithPath:soundPath];
> AudioFileID fileID;
> OSStatus result = AudioFileOpenURL((CFURLRef)afUrl,
> kAudioFileReadPermission, 0, &fileID);
> UInt64 outDataSize = 0;
> UInt32 thePropSize = sizeof(UInt64);
> result = AudioFileGetProperty(fileID, kAudioFilePropertyEstimatedDuration,
> &thePropSize, &outDataSize);
> AudioFileClose(fileID);
> return outDataSize;
> }
>
> ....
> NSLog(@"why is this always 0? %qu", [MySoundClass
> getAudioFileDuration:@"openPage.aif"]);
>
_______________________________________________
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