Mixer: Speeding/slowing audio

I’ve been learning SDL 1.2, and I just recently started learning the sdl_mixer functions, so I’ve been adding music and sounds to my games. I’m working on this game where I need to play a sound at different sample rates, so the speed and pitch of the sound are altered. I was planning to just use ProTools to create several versions of the same sound, played at different speeds, but then it occurred to me that my game would maybe use less ram if I could just change the speed of the audio file on the fly. Is there a function in the mixer that would let me do that?

I don’t need to do anything fancy, like time-shifting without changing the pitch, or ramping up the speed as the audio plays. I just want to take a 22.05kHz wav file and play it at maybe 28kHz or so. As some of you already know, I’m very new to programming, so if this is something that would be very complicated, I’ll probably just make some new versions of the wav file instead. But I figured there might be a simple way to do it.

Thanks.

From the document I think at the time the sample file is loaded, the samples are already converted to the target sampling rate/sampling data. So I think it’s not possible with the SDL_mixer.

You may have to use the audio api in SDL directly instead to archive what you want. However it’s probably better to do the preprocessing off-line and just load them as different samples, just my 2 cents.

From the document I think at the time the sample file is loaded, the
samples are already converted to the target sampling rate/sampling data.
So I think it’s not possible with the SDL_mixer.

You may have to use the audio api in SDL directly instead to archive what
you want. However it’s probably better to do the preprocessing off-line
and just load them as different samples, just my 2 cents.

Here’s a ‘audio library’ that I had booked marked for one of my projects
(though haven’t actually used yet).

http://sol.gfxile.net/soloud/

It contains code for speeding/slowing audio clips on the fly,
Simon