Hi,

I've been struggling playing multiple AUFilePlayers at the same time.

I use an AUGraph and setup all my AUFilePlayer regions like this:

memset(&audio_file_region_.mTimeStamp, 0,
sizeof(audio_file_region_.mTimeStamp));
audio_file_region_.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
audio_file_region_.mTimeStamp.mSampleTime = 0;
audio_file_region_.mCompletionProc = NULL;
audio_file_region_.mCompletionProcUserData = NULL;
audio_file_region_.mAudioFile = audio_file_ID;
audio_file_region_.mLoopCount = 0;
audio_file_region_.mStartFrame = 0;
audio_file_region_.mFramesToPlay = 0;

Notice that the `mFramesToPlay = 0` because I Play/Pause/Stop from the
AUFilePlayers and not the AUGraph.

This way I start the graph but I start the playback when I want by using
AUFilPlayer->Play(). Inside the Play() method I set the right number of
frames for `mFramesToPlay` and the playback start.

Everything works well this way.

But now let's say I've 2 different AUFilePlayer called file_player_1 and
file_player_2 which will play the same audio file.

When I do something like this:

// Do all the setup things
file_player_1->Play();
file_player_2->Play();

I can hear the mix of my AUFilePlayer but I hear that the playbacks are
phase shifted.
I think it's because of the delay caused by `file_player_1->Play();` so
before `file_player_2->Play();` is done the file_player_1 playback has
already started…


I looked at how to fix it and the workaround I found is to change the
`kAudioUnitProperty_ScheduleStartTimeStamp` property.
Instead of using `time_stamp_.mSampleTime = -1;` i.e start at the next
render cycle I used `time_stamp_.mSampleTime = 0;` and it seems to work.

But honestly I don't really know what
"kAudioUnitProperty_ScheduleStartTimeStamp" do, and if it's the good way to
play multiple AUFilePlayer playback in a sync since everybody uses
`time_stamp_.mSampleTime = -1`.

What would be your recommandation for this kind of behaviour?


Thank you
Laurent Noudohounsi.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (Coreaudio-api@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to