• 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
AudioQueue basics - elapsed time and seeking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AudioQueue basics - elapsed time and seeking


  • Subject: AudioQueue basics - elapsed time and seeking
  • From: Alex Kac <email@hidden>
  • Date: Tue, 23 Sep 2008 12:02:53 -0500

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
_______________________________________________
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


  • Follow-Ups:
    • Re: AudioQueue basics - elapsed time and seeking
      • From: Alex Kac <email@hidden>
  • Prev by Date: Re: Logic and AU instruments with side-chain
  • Next by Date: Re: output to aiff
  • Previous by thread: Re: support for two's complement 24 bit audio
  • Next by thread: Re: AudioQueue basics - elapsed time and seeking
  • Index(es):
    • Date
    • Thread