Playing several audio files at precise same time
What is the best way yo play several AEAudioFilePlayer players simultaneously - at precise same time? Something like AVAudioPlayer playAtTime method.
Thank you very much.
Regards, Grega
What is the best way yo play several AEAudioFilePlayer players simultaneously - at precise same time? Something like AVAudioPlayer playAtTime method.
Thank you very much.
Regards, Grega
Comments
Atomic updates like that is still a work in progress, I'm afraid, Grega. If you're not doing anything else with the engine at the time of playback, you could stop the engine, add each of the players, then start it to have everything come in at the same time.
Scratch that - I've just implemented playAtTime
http://theamazingaudioengine.com/doc/interface_a_e_audio_file_player.html#aefb37d50966ea101e5bc3d2010022f41
Hi,
sorry for late reply. Wow that is great, thanks!
Regards,
Grega
I have just tested this and it does not work as expected. For example i am playing 10 audio files at the same time. Sometimes it works, sometimes it does not and you can here a little delay (like a chorus effect). Maybe i am doing something wrong: i am using Apple's AVAudioPlayer deviceCurrentTime property to get the audio system time,then i add 0.2 seconds to that time and use it with AEAudioPlayer playAtTime method.
Regards,
Grega
The delay you mention, is that a delay between files all played with AEAudioFilePlayer, or between AEAudioFilePlayer and AVAudioPlayer/etc?
Between files all played with AEAudioFilePlayer. Once you move to TAAE you don't need AVAudioPlayer anymore.
))
Hmm, I see! Would you share some code? I'm trying to reproduce this on my end with the following:
<
pre lang="objc">
uint64_t startTime = AECurrentTimeInHostTicks() + AEHostTicksFromSeconds(2.0);
for ( int i=0; i<10; i++ ) {
AEAudioFilePlayer * loop = [AEAudioFilePlayer audioFilePlayerWithURL:[[NSBundle mainBundle] URLForResource:@Southern Rock Drums withExtension:@m4a] error:NULL];
loop.loop = YES;
[loop playAtTime:startTime];
[_audioController addChannels:@[loop]];
}
It seems to sound fine to me (just like one really loud loop)
I do it like this:
Is it wrong to add channels to audio controller before play or playAtTime?
Regards,
Grega
Ah, yes, that might be it: once you add the channels, unless you set channelIsPlaying to NO first, they'll begin playing. You want to change the order there.
Tried that and got the same result. Still not precise enough. Any other ideas? Thanks.
Having trouble reproducing this on my end; can you modify the TAAE sample app to reproduce and send me a diff?
OK, thank you. Will send you when ready.
Hi again,
i have managed to make it work. I have changed sync time from AVAudioPlayer deviceCurrentTime to match your example: uint64_t startTime = AECurrentTimeInHostTicks() + AEHostTicksFromSeconds(2.0); and after that channels are synced ok. Thank you for your time.
Regards,
Grega
Okay, cool