• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AudioQueue basics - elapsed time and seeking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioQueue basics - elapsed time and seeking


  • Subject: Re: AudioQueue basics - elapsed time and seeking
  • From: Alex Kac <email@hidden>
  • Date: Wed, 24 Sep 2008 10:08:29 -0500

So I see that my math was wrong in one area (funny in my tests I was doing it right, but in code I did it wrong) and I also found out what I was doing wrong elsewhere. I realized I was seeking wrong. It now works (I think - need more testing on different audio files).

On Sep 23, 2008, at 12:02 PM, Alex Kac wrote:

So I thought I understood everything and I thought I got it all working perfectly. Only to find out I must not know anything and everything I've done was an accident :(

I am using AudioQueue to play files in PCM and IMA4 format. These sound files show up in the UI with elapsed time and a scrubbing slider.

Now there are some methods in my player class that I have written that work perfectly in PCM format, but not IMA4. I don't understand AudioQueue timelines yet, but the docs are so sparse I'm not even sure they would help.

My methods:
- (Float64) duration
{
	Float64 duration = 0;
	UInt32 sizeOfCount = sizeof (duration);
	AudioFileGetProperty (
						  [self audioFileID],
						  kAudioFilePropertyEstimatedDuration,
						  &sizeOfCount,
						  &duration
						  );

	return duration;
}


- (Float64) secondsElapsed
{
Float64 numPacketsForTime = self.startingPacketNumber / (audioFormat.mSampleRate * audioFormat.mFramesPerPacket);
return numPacketsForTime;
}


- (void) seekToTimeSeconds:(Float64)timeSeconds;
{
seeking = YES;

Float64 numPacketsForTime = audioFormat.mSampleRate / audioFormat.mFramesPerPacket * timeSeconds;
self.startingPacketNumber = numPacketsForTime;
}


So we call the "secondsElapsed" method and get a time and that works for PCM. For IMA4 I get such small numbers that it reads 0 seconds at all times in my elapsed time string. I tried using
- (Float64) secondsElapsed
{
AudioTimeStamp t = {0};
OSStatus err = AudioQueueGetCurrentTime(self.queueObject,NULL,&t,NULL);
if (err == noErr)
return t.mSampleTime / audioFormat.mSampleRate;

return 0;
}


but that only returned the total playing time - not the elapsed time from the position in the scrubber.

So I'm sitting here scratching my head, trying to read through the docs and figure out what I'm missing. It all works well enough for PCM, but not for IMA4 or anything else. I'd like to not only get help for this, but also simply understand why.

Thanks.

--
Alex Kac

Alex Kac - President and Founder Web Information Solutions, Inc.

"In the Country of the Blind, the one-eyed man is king."
--Desiderius Erasmus





_______________________________________________
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


References: 
 >AudioQueue basics - elapsed time and seeking (From: Alex Kac <email@hidden>)

  • Prev by Date: Re: opening a quicktime file with AAC audio via AudioFileOpenURL
  • Next by Date: Re: "ERROR: View Component specified, but can't be found"
  • Previous by thread: AudioQueue basics - elapsed time and seeking
  • Next by thread: Setparameter problem
  • Index(es):
    • Date
    • Thread