• 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
Play multiples AUFilePlayers in sync
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Play multiples AUFilePlayers in sync


  • Subject: Play multiples AUFilePlayers in sync
  • From: Laurent Noudohounsi <email@hidden>
  • Date: Wed, 9 Aug 2017 16:41:38 +0200

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: How to output program audio to specific AirPlay device
  • Next by Date: AUv3 sample code and GarageBand for macOS.
  • Previous by thread: How to output program audio to specific AirPlay device
  • Next by thread: AUv3 sample code and GarageBand for macOS.
  • Index(es):
    • Date
    • Thread