[SDL] Creating audio samples via code

Simon simon.xhz at gmail.com
Mon May 21 12:28:52 PDT 2007


Stretching the sound wave will change its pitch, and will sound differently.
You might want to make the sound longer in time, but probably the
same, then you'll need high-tech algorythms to reconstruct the right
pitch.

This type of algorythm is used to strech the audio part of a movie to
help synchronise the movie with the sound without loosing any frames.
(And in fact i heard there was a patent on it, for movie playback that
is!).

If you wish to learn about this type of calculation, give a visit to
http://csounds.com/ a nice place to learn about audio theories.

Good luck,
  Simon

On 5/21/07, Gabriel Gambetta <mystml at adinet.com.uy> wrote:
> Hi guys,
>
> We're making a game where we need to time-stretch some audio samples. My
> idea is to load the samples normally and then create the stretched
> samples on the fly.
>
> The thing is, I can't find anything in SDL_mixer.h to create and
> manipulate samples, except for the Mix_Chunk itself.
>
> So two questions. First, if I just allocate a Mix_Chunk and its abuf
> field and put stuff there, assuming the stuff is in the correct format,
> should it work?
>
> Second, would you be interested in a patch to add some functions to do
> that? Say, Mix_CreateChunk(), Mix_GetSample() and Mix_PutSample()?
>
> BTW, if someone has SDL_Mixer code to do time-stretching, you'll save me
> a lot of work ;)
>
> Thanks,
>
>         --Gabriel
>
> ________________________________________________________________________
> Gabriel Gambetta
> Mystery Studio - http://www.mysterystudio.com
> Gabriel's Stuff - http://www.mysterystudio.com/gabriel
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>


More information about the SDL mailing list