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.
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: <@Emmanuel_Gil_Peyrot>
OpenPGP: 24B1D609
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130510/8a84becb/attachment.pgp
Hi,
New version of that patch at the same URL, rebased on the latest commit
and with the end loop point now supported in the Vorbis backend.
It would be great for it to get included for the final release of
SDL2_mixer since looping is a feature needed by a lot of games out
there.
I?m welcome to any improvement suggestion. :)On Fri, May 10, 2013 at 04:39:23PM +0200, Emmanuel Gil Peyrot wrote:
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.
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: <@Emmanuel_Gil_Peyrot>
OpenPGP: 24B1D609
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130618/e218cbae/attachment.pgp
Is there any way to add support for the other music backends? I’m trying
not to add features that just won’t work with a number of music formats.
Cheers!On Tue, Jun 18, 2013 at 12:12 AM, Emmanuel Gil Peyrot < linkmauve at linkmauve.fr> wrote:
On Fri, May 10, 2013 at 04:39:23PM +0200, Emmanuel Gil Peyrot wrote:
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.
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
Hi,
New version of that patch at the same URL, rebased on the latest commit
and with the end loop point now supported in the Vorbis backend.
It would be great for it to get included for the final release of
SDL2_mixer since looping is a feature needed by a lot of games out
there.
I?m welcome to any improvement suggestion.
–
Emmanuel Gil Peyrot
XMPP:
OpenPGP: 24B1D609
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
For the CMD backend there is obviously no way to implement those
without diving into command-specific arguments.
The modules and MIDI ones already have their own internal loop feature,
so I don?t think they are that relevant for that patch.
I tried to add it to the FLAC one, but didn?t find any function I could
use to calculate the end sample.
As for the two MP3 backends, I didn?t look at all yet, since I read
there was license issues some time ago. Also, I don?t intend to support
that codec in my game, but I can look at them nonetheless.On Tue, Jun 18, 2013 at 12:28:02AM -0700, Sam Lantinga wrote:
Is there any way to add support for the other music backends? I’m trying
not to add features that just won’t work with a number of music formats.
Cheers!
–
Emmanuel Gil Peyrot
XMPP: <@Emmanuel_Gil_Peyrot>
OpenPGP: 24B1D609
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130618/51283cbc/attachment.pgp
The CMD back end doesn’t support any of the more complex functionality, and
I think it’s basically deprecated at this point.
For FLAC, there’s a value in music_flac.c that might be helpful:
data->flac_data.total_samples
For MP3, it would be nice if it were supported using SMPEG, but it’s not
required.
Thanks!On Tue, Jun 18, 2013 at 12:48 AM, Emmanuel Gil Peyrot < linkmauve at linkmauve.fr> wrote:
On Tue, Jun 18, 2013 at 12:28:02AM -0700, Sam Lantinga wrote:
Is there any way to add support for the other music backends? I’m trying
not to add features that just won’t work with a number of music formats.
Cheers!
For the CMD backend there is obviously no way to implement those
without diving into command-specific arguments.
The modules and MIDI ones already have their own internal loop feature,
so I don?t think they are that relevant for that patch.
I tried to add it to the FLAC one, but didn?t find any function I could
use to calculate the end sample.
As for the two MP3 backends, I didn?t look at all yet, since I read
there was license issues some time ago. Also, I don?t intend to support
that codec in my game, but I can look at them nonetheless.
–
Emmanuel Gil Peyrot
XMPP:
OpenPGP: 24B1D609
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org