Question

I'm doodling about with the Minim library of Processing, manipulating audio buffers myself to playback sounds, play in reverseetc.

But I wonder - how does one play a sound at twice speed or half speed, without manipulating the sampling rate? Do they "double buff" the buffer with the same sound twice to slow it down? How about speeding up?

Was it helpful?

Solution

There are many algorithms of varying degrees of sophistication to perform audio resampling (what you're trying to do here). If you have access to a raw buffer of audio samples, here are some naïve ways to manipulate them as you described:

  • To do 2X playback, iterate over the sample of buffers and average (arithmetic mean) each successive pair of samples, placing the results into a new buffer. The resampled buffer should be half as long as the original buffer.
  • To do 0.5X playback, compute the averages of successive sample pairs but insert the average between the 2 samples. This resampled buffer should be twice as long as the original buffer.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top