2

I am working on a project including sound stretching using SoundTouch and C#.

As an effect when stopping the music playback, I want to implement a stretch algorithm like when the DJs turn the Vinyl off but it takes some seconds for the Vinyl to stop rotating and meanwhile the music is still being played and the sound stretches to lower tempos until it goes to zero.

My problem is that I don't really know where I should start from. I thought of using some sort of iterations with ease-out decreasing the tempo for chunks of music samples, but it seems a little complicated to me and I have problem figuring the algorithm out.

Any kind of suggestion, starting point, example or help is really appreciated.

Thanks.

Rojan Gh.
  • 1,062
  • 1
  • 9
  • 32
  • 1
    The effect of a record slowing down requires no time-stretching, because you don't want the tempo and the pitch to change independently. You just need to slow down playback by resampling the audio; you can do that with linear interpolation, or with a mathematically more precise method for improved audio quality – m69's been on strike for years Aug 26 '15 at 03:39
  • That's interesting, can you be more specific please @m69 ? I have just seen the linear interpolation thing name among soundtouch classes but I am not really aware what it does! – Rojan Gh. Aug 26 '15 at 03:42
  • 1
    I don't know much about DSP coding, I just use a lot of audio software :-) But basically, you want to gradually change the ratio of input/output samples; in order to do that, you need to calculate what the values inbetween the input sample points are; easiest method is linear: if the playback sample point is two thirds between the input sample points a and b, use the sample value that is two thirds between the value of a and b. – m69's been on strike for years Aug 26 '15 at 03:49
  • That's a very good starting point, thanks. I will try to get it working based on what you explained and let you know if it works. :) Thanks @m69 – Rojan Gh. Aug 26 '15 at 04:10
  • That worked perfectly @m69 please consider putting your comment as an answer to the question so I can mark it as answer. :) – Rojan Gh. Aug 26 '15 at 13:06

1 Answers1

1

The effect of a record player slowing down requires no time-stretching, because you're not changing the tempo and the pitch independently. You just need to slow down the playback rate by resampling the audio.

In the illustration below, the green dots represent the input audio samples, the grid is the output sample clock, and the orange dots are the resulting output audio samples.

resampling audio with linear interpolation

In order to generate the output audio samples, you need to interpolate between the input sample values. In the graph I've used linear interpolation, which is the simplest way. To increase audio quality, you could use a mathematically more precise interpolation method, like differential interpolation (search for spline drawing techniques for more info), but for your particular case of a rapid slow-down effect, linear interpolation may be good enough.