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
Loop points support for SDL_mixer
Emmanuel Gil Peyrot
Guest

Hi,

I have written a patch to add loop points support to SDL_mixer[1] with
that function:
int Mix_SetLoopPoints(Mix_Music *music, double start, double end);

Currently I’ve only added support of the loop end to the WAVStream
backend, but it should be fairly straightforward for the other
backends. I also needed a way to seek in the WAVStream backend so I’ve
implemented WAVStream_jump_to_time.

At first I wanted to store the exact offset in bytes or samples, but a
double is better to the compatibility with multiple backends, with
enough precision to address unique samples up to a song of a few
hundreds years. :D

I also chose to store the loop_start in the Mix_Music struct and the
loop_end in the backend-specific struct, it makes more sense with the
current architecture. I had to add two more fields to the WAVStream
struct, samplesize and byterate, because I needed them to calculate the
correct position in samples.

I’ve tested it with playmus and a game I’m working on, didn’t find
any issue, but comments welcome. :)

[1] http://linkmauve.fr/files/loop-points.patch

--
Emmanuel Gil Peyrot
XMPP:
OpenPGP: 24B1D609

_______________________________________________
SDL mailing list

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