The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Mixer: Speeding/slowing audio
Explodey


Joined: 18 Nov 2013
Posts: 31
Location: United States
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.
mr_tawan


Joined: 13 Jan 2014
Posts: 161
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.
Mixer: Speeding/slowing audio
mungewell


Joined: 17 Nov 2011
Posts: 40
Quote:
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

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Explodey


Joined: 18 Nov 2013
Posts: 31
Location: United States
Thanks for the help guys. I went ahead and just made some different versions of my wav files, but I think I will check out SoLoud for future projects. Thanks for the link.