WohlSoft / SDL-Mixer-X

SDL Mixer X (Or "MixerX" shortly) - An audio mixer library based on the SDL library, a fork of SDL_mixer
https://wohlsoft.github.io/SDL-Mixer-X/
Other
103 stars 26 forks source link

Effect handler which changes buffer length #78

Open mbpictures opened 5 months ago

mbpictures commented 5 months ago

Hi again!

I want to implement an effect callback for the Mix_RegisterEffect function, which changes the playback speed of a track (e.g. using this lib). Doing something like this would cause the output buffer of the buffer to increase or decrease in length. I saw some implementations for the "normal" SDL Mixer lib using Mix_Chunk and storing the complete buffer (so it's possible to access data outside of the current buffer of the effect callback). Do you have an idea how to implement something like that using music streams?

Thanks already very much!

Wohlstand commented 5 months ago

Hello! The public API of effects doesn't allows to apply effects with the buffer length change at least for now. But, internally it's possible to add any kind of effect (i.e. filter) that can change the length of the buffer (right now these are used to convert sample format, channels count and perform resampling). I had thinks to implement use of such library too, but there was a discussion between me and some other folks that complains the quality of slowdowned results and suggested me to try better algorithms. Right now I do have the simple speed implementation through the sample rate change hack at the stb-vorbis module, and that's not ideal as clicks were made during the sliding of the speed factor.