Sync issue with AUScheduledSoundPlayer
Sync issue with AUScheduledSoundPlayer
- Subject: Sync issue with AUScheduledSoundPlayer
- From: thomas rettich <email@hidden>
- Date: Wed, 8 Oct 2008 11:07:55 +0200
- Importance: Normal
Hi,
I have 2 AUScheduledSound players.
Both play back the exact same audio file.
I need to synchronize the two so they are sample accurately in sync.
The common case is that one player is already playing and upon a certain event the second one comes in.
I have tried doing it the following way which turns out to be too inaccurate:
// get the current time from the player 1 (which is currently playing) -> is this value sample accurate at all when I query AUScheduledSoundPlayer ?
// set the current time value on the File reader of player 2
// Have player 2 start playing immediately beginning on that time
// Result: the 2 players are out of sync usually by around 1/10 second.
Does anyone a better approach to the problem ?
I'd very much appreciate any hints on this.
Here is the code snippet I use for syncing the 2 players.
// Get the current time of player 1
AudioTimeStamp timeStamp= {0};
UInt32 size= sizeof(AudioTimeStamp);
err= AudioUnitGetProperty(m_AU,kAudioUnitProperty_CurrentPlayTime,kAudioUnitScope_Global,0,&timeStamp, &size);
float currentSampleTime= timeStamp.mSampleTime;
// Based on that I set the reader of the other player to start reading at offset currentSampleTime
// Then I tell my second player to start playing immediately (which means the next render cycle I guess)
AudioTimeStamp theTimeStamp = {0};
theTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
theTimeStamp.mSampleTime = -1; // start now
err = AudioUnitSetProperty(au,
kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global, 0,
&theTimeStamp, sizeof(theTimeStamp));
Thanks,
Thomas
_________________________________________________________________
Messenger to go! Hol' Dir Messenger aufs Handy!
http://windowslivemobile.msn.com/BrowserServiceMessenger.aspx?lang=DE-DE _______________________________________________
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