| Summary: | Loop points (start/end) for music | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Vitaly Novichkov <admin> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | enhancement | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Add support for Vorbis comments based loop tags in OGG files
Demo file which contains looped fragment in middle |
||
|
Description
Vitaly Novichkov
2015-01-19 07:55:59 UTC
Okay, I Already implemented that myself. So, every OGG file can have vorbis tags: LOOPSTART, LOOPEND or LOOPLENGTH. There are contains PCM sample positions. Those points are remembering into special values. If loop is configured to infinite loop, every sample fetch check for loop end escaping. If loop end detected, crop unneeded sample data after loop end, and jump to loopStart. Security notes: to avoid infinite loops and other similar bugs, before init loop points check that there are must be: - Loop end must be always after loop start - If loop start less or equal to loop end, mark them as invalid loop points and think like is no loop points. My code of OGG processing is here: https://github.com/Wohlhabend-Networks/PGE-Project/blob/master/_Libs/SDL2_mixer_modified/music_ogg.c#L70 Note: you also will see custom resampler implementation which I made because buggy resampler implementation at SDL side. This seems really useful. Your link gives a 404 though. Can you attach a patch based on the latest (highly modified) code in Mercurial? http://hg.libsdl.org/SDL_mixer Thanks! Hello! Sorry, I wrote this long time ago and I also did a lot of modifications, even I have moved my SDL Mixer fork into own repository away from the repository of my game engine project. The file I wanted to show: https://github.com/WohlSoft/SDL-Mixer-X/blob/master/src/codecs/music_ogg.c Yes, I'll create a patch for you based on top of your official repo and I'll attach it to here. P.S. Before you rewrote music.c I did that by myself in my form where I have implemented similar to "Mix_MusicInterface" thing and I have fixed some of the bugs you have been fixed recently: https://github.com/WohlSoft/SDL-Mixer-X I'll need to synchronize changes with you since our sources are becoming very different now Thanks! Your fork looks great! :) Created attachment 3008 [details]
Add support for Vorbis comments based loop tags in OGG files
LOOPSTART - loop start PCM sample position
LOOPEND - loop end PCM sample position
LOOPLENGTH - loop length PCM sample position (alternative to LOOPEND, added for compatibility with RPG Maker targeted OGG files)
Created attachment 3009 [details] Demo file which contains looped fragment in middle Try to play this short fragment in a regular player and then play same through SDL Mixer. A short fragment in middle must be looped forever. Note: in my fork, I have the ability to pass loops limit: https://github.com/WohlSoft/SDL-Mixer-X/blob/master/src/audio_codec.h#L89 https://github.com/WohlSoft/SDL-Mixer-X/blob/master/src/codecs/music_ogg.c#L175 which is not implemented here. Because of implementation specifics, I will need to modify all other codecs modules to add one small function into this interface. I highly recommend you to have a function similar to this: https://github.com/WohlSoft/SDL-Mixer-X/blob/master/src/audio_codec.h#L112 to initialize all interface structure fields with default (dummy or NULL) values instead of doing that in each codec module. That will give the ability to add more functions into the same interface without touching of other modules ;-) Added, thanks! https://hg.libsdl.org/SDL_mixer/rev/bd5fa0d4f34a I'll leave this bug open for a bit in case you want to refine it. I just looked over the code and it looks good, thanks! The one con of this: when you ran music playing with disabled loop (limited count of loops or playing once), the loop will work infinite. To fix this I must to expand your Music Interface class (I gonna to optimize it a bit, if you don't object). I'll create another discussion for merge of our forks |