breakfastquay / rubberband

Official mirror of Rubber Band Library, an audio time-stretching and pitch-shifting library.
http://breakfastquay.com/rubberband/
GNU General Public License v2.0
561 stars 89 forks source link

Proccessing multiple stereo channels at once? #89

Open JoergAtGithub opened 1 year ago

JoergAtGithub commented 1 year ago

I wonder if it's possible benefit from SIMD commands like SSE/AVX in a typical DJ application with 4 stereo channels, where all 4 stereo channels should be shifted in real-time. Every stereo channel would be processed with the same parameters (buffer size, samplerate) except PitchRate and TimeRatio.

cannam commented 11 months ago

I don't think there is enough available in common between channels for this to work readily. Most of the bits of processing that are identical across channels (e.g. analysis FFT) are already candidates for SIMD optimisation in the other axis, so there would be nothing to gain. Other processes will differ significantly depending on the content analysis so would not be candidates for shared calculation.

It's possible for other reasons that a set of e.g. 4x stereo inputs could be processed faster by a single 8-channel stretcher than by 4x 2-channel stretchers. For example, a resampler can sometimes be faster when applied to multiple channels simultaneously than separately. The problem is that there's no way to tell an 8-channel stretcher that its inputs form a set of stereo pairs, so they won't get the benefit of proper stereo mode handling - the stretcher will instead stretch them individually. It might be interesting to run some quick performance tests for 8-channel input vs 4x 2-channel inputs and see if that's worth pursuing. I'm guessing probably not, if only because the latter can be distributed by the client application across CPUs more easily.

JoergAtGithub commented 11 months ago

Thanks for your insight! In Mixxx we consider using https://github.com/kokkos/mdspan for audio signals with more than two channels per deck (for a future stem separation feature). But I'm not familar enough with the internals of audio strechers, to rate if this is also usable here.