After much searching on the internet (more than 10 hours sitting in front of
google results) I continue to be stumped by the problem of efficient audio
What is needed: to play audio that comes at a sample rate of 44100Hz on
hardware that seems locked at 48000Hz, as fast as possible.
The rough measurements I made are as follows:
My linux system uses alsa.
Any application I use, including my own, to play 44100 audio will sound
fine, but use 4-9% CPU power at all times. Some dedicated audio player
applications use even more.
Mplayer, playing the same audio, reports that the audio is at 44100Hz, but
that alsa is operating at 48000Hz, and uses <0-3% CPU power at all times.
When running with this performance, Mplayer seems to be using alsa and
If I make my application play the audio at 48000Hz (argument audio_rate
passed to Mix_OpenAudio), then it runs not quite as fast as Mplayer, but
definitely faster than when playing at 44100Hz, as much as 5% less CPU power
If I tell Mplayer to use SDL for audio output, then its performance is
almost exactly the same as my application’s, when playing 44100Hz audio.
It seems like it is related to rate conversion methods. Unfortunately, after
much searching, I have no idea how to get SDL to use the fastest rate
conversion method (linear interpolation vs. others), or even if such control
Any comments or suggestions would be welcome. I hope to avoid configuration
of sound drivers because no such thing is needed by mplayer, so I’m
optimistic in thinking that my app should be able to pull some of the same
If someone is going to suggest that I replace SDL’s decoding or audio code
with something else, while retaining the ability to use Mix_PlayMusic, then
this is fine if I can make it easily portable to windows (bundling dll’s or