adrianstevens / Xamarin-Plugins

Cross-platform Plugins for Xamarin, Xamarin.Forms and Windows
https://www.nuget.org/packages/Xam.Plugin.SimpleAudioPlayer/
MIT License
132 stars 53 forks source link

Offset when playing loop sound #29

Closed Vikypster closed 5 years ago

Vikypster commented 6 years ago

Hello,

I've been trying to play a sound with the Loop field set to true. My loop is about 8 seconds long.

It seems that when the loop ends, it takes a couple milliseconds (maybe something like 100ms) to start again. I was playing my 8 sec loop with a metronome starting at the same time. After 2 or 3 times playing, the loop cleary goes out of sync with the metronome.

I think that there is some synchronous code running when a playback ends that creates this shift.

I've tried on WPF and Android 7.0

Would you have any idea to help?

Also, thanks for supporting this plugin, that's very helpful.

Thanks,

Victor

adrianstevens commented 6 years ago

Hi Victor - I'll be honest, that doesn't surprise me :)

For metronome acurate playback, my usual technique is to build an in memory audio buffer and use lower level audio APIs to continuously stream audio data.

SimpleAudioPlayer is built for ease of use and isn't designed for low latency, high performance audio.

You might have some luck looking at cross-platform gaming engines, they often use the low level APIs for music and sound effects.

adrianstevens commented 5 years ago

closing issue