I’m currently in the process of integrating SDL_AudioStream into FACT, a reimplementation of XACT that I’ve been working on, and it’s been incredibly nice to work with! I was dreading having to deal with resampling and it’s worked incredibly well with some of the bizarre sample rates that XACT likes to spit out.
It works so well, in fact, that I’ve been toying with the idea of using it as a pitch shifting tool as well… it’s mostly there already; just set the source sample rate to the adjusted rate based on the requested pitch, and the output data is both resampled and pitch shifted in one pass!
The problem is that for my scenario I would be adjusting the source sample rate a LOT, not just once at load time. To explain a little better, here’s where we currently use SDL_AudioStream in FACT:
So what I’d like to do is add something like…
void SDL_SetStreamSampleRate( const SDL_AudioStream *stream, const int src_rate, const int dst_rate );
By just tweaking a couple numbers I could get real-time pitch shifting without having to do a whole extra pass just for this one effect. The reason I set both src and dst despite only caring about src is because, looking internally, it seems these two actually do quite a lot with one another when calling SDL_NewAudioStream:
My concern is that there’s no cheap way to actually adjust the rate of the stream after it’s been made, which would be a shame since freeing/reallocating an entire stream for every wave pitch adjustment sounds awful enough on paper…
Any thoughts on this? I’d be more than happy to implement and test ideas, I just wanted to see if there was any interest in something like this before I started hacking up audiocvt.c to bits.