Fitzy
Fitzy

Reputation: 1889

Quicker alternative to AVAudioPlayer?

I have an app in which the frame rate slows down dramatically when a sound is played. I am using AVAudioPlayer to play these sounds, and there are many sounds being played within short spaces of time. These sounds are only a matter of kilobytes. Is there an alternative way to play these sounds with much lower performance costs?

Upvotes: 0

Views: 847

Answers (1)

hotpaw2
hotpaw2

Reputation: 70693

Yes. Read the audio files into raw PCM arrays during while the app is starting up, and asynchronously. Then use the Audio Unit API, and copy the samples to RemoteIO Audio Unit buffer callbacks, directly, or via an audio mixer. Extremely low performance overhead for pre-mixed and/or non-overlapped audio. A tiny amount more overhead for some small amount of audio mixing.

Upvotes: 1

Related Questions