current play position
current play position
- Subject: current play position
- From: Robert Carroll <email@hidden>
- Date: Tue, 24 Jul 2012 15:56:37 -0400
I'm doing pretty much the same thing as in the code below.
However, the mSampleTime does not increase continuously. This is while the audiograph is running and several fileplayer units are playing back.
I have a time loop that checks the sampletime while the audiograph is running and logs any result where the value decreases.
> if (currentPlayTime < lastPlayTime) {
> NSLog(@"Sampletime reset at %qu",currentPlayTime); //sampletime is reset with fileplayer reset
> }
> if (currentPlayTime ==0) {
> NSLog(@"CurrentPlayTime is zero at %qu",lastPlayTime);
> }
> lastPlayTime = currentPlayTime;
With 3 fileplayers playing identical fileregions with start times of -1, 22050, 44100 (in samples) I consistently get "Sampletime reset at 3516".
This appears to be before the last scheduled region should play, but it already has played.
Is there a way to get a consistent timeline from an audiograph?
thanks
rob
On Jul 23, 2012, at 3:00 PM, email@hidden wrote:
> From: Robert Martin <email@hidden>
> To: Aran Mulholland <email@hidden>
> Cc: Beleg Da'Bear <email@hidden>; "email@hidden" <email@hidden>
> Sent: Thursday, July 19, 2012 1:13 AM
> Subject: Re: How do you pause, stop and reset an AUFilePlayer in IOS5?
>
> It's a bit more complicated than that.
>
> What you'll get from 'getting' kAudioUnitProperty_CurrentPlayTime is the -offset- time from when you last set kAudioUnitProperty_ScheduledFileRegion.
>
> If you schedule a new region with that time, you won't resume at the correct place if you pause/resume more than once.
>
> Here is a copy of Doug Wyatt's note on this from 2006, since I no longer have the link:
>
> "To change the play position:
>
> [1] obtain the current play position:
> AudioTimeStamp ts;
> UInt32 size = sizeof(ts);
> AudioUnitGetProperty(mFilePlayerAU,
> kAudioUnitProperty_CurrentPlayTime, kAudioUnitScope_Global, 0, &ts,
> &size);
> Float64 sampleFrame = ts.mSampleTime;
>
> Now you know where playback is, relative to the beginning of the
> event timeline that you scheduled. If you scheduled the beginning of
> a file to play at the beginning of the timeline, then the
> play
> position is the same as the position in the file (except in the case
> of sample rate conversion, which is another wrinkle.....)
>
> [2] stop:
>
> AudioUnitReset(mFilePlayerAU, kAudioUnitScope_Global, 0);
>
> [3] start again. Here you can specify the starting sample offset in
> the file.
>
> For example, to implement pause/resume, you'd obtain the play
> position before pausing, and add that to the position in the file
> where you last started. That would be the playRegion.mStartFrame when
> scheduling the first event when you resume."
>
> Rob
_______________________________________________
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