Re: AUAudioFilePlayer silent after setting playback position
Re: AUAudioFilePlayer silent after setting playback position
- Subject: Re: AUAudioFilePlayer silent after setting playback position
- From: Doug Wyatt <email@hidden>
- Date: Mon, 2 Jan 2006 15:13:20 -0800
On Dec 31, 2005, at 15:09, Felipe Baytelman wrote:
Hi everyone, and Happy new year (here we still have a couple of
hours before parties start):
I have a problem with AUAudioFilePlayer: I have managed to change
the playback position. If I change the "rewind" the payer, I get a
silent Generator (even when the playback position shows it's moving
through the file) until it reaches the previous playback position.
This is what I'm doing:
// set start time (on next render cycle)
AudioTimeStamp startTime;
startTime.mFlags = kAudioTimeStampSampleTimeValid;
startTime.mSampleTime = -1;
AudioUnitSetProperty(fileAU,
kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global,
0, &startTime, sizeof(startTime));
There is no need to Stop/Start the graph (I have checked every
combination of AU functions available). It moves the playback
position... But is there any way of getting the audio again, like
the AUAudioFilePlayer included in AULab?
(In there, you can move the playback position with no problem)
What are you doing to "change the playback position"?
Adding to my Dec 1 "cheat sheet" post ...
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.
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
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