Hi. I’m trying to program a simple sampler using Rubberband to pitch shift the voices. I got it working but it can really only handle 1 voice before latency becomes an issue. I don’t think there’s any substantial improvements to be made in my code so I’m thinking of preprocessing the sounds and caching Rubberband’s results for different notes. Could I do this processing in a separate thread so that the user can still play notes while it’s happening?
What kind of data is played? Is that a file containing the audio data? In that case I’d let the background thread loading the file for the audio thread do the time stretching.
If the data is entirely in RAM, I’d also precalculate maybe the first 2000 samples for every possible note and let the background thread kick in, when a full sample is needed.