Spline audio interpolation

Saturday, 11/21/2009

For my a 3d audio software renderer, access to the audio data in a non sample based mode is needed. In order to achieve this goal, I've implemented a custom cubic spline interpolation well suited for audio data. To test how good it is, I've done a little test:
I've created a wave file containing a sine at 440Hz. With my interpolator I played it back with a speed factor of 0.2 and 1.2. After doing this, I did a frequency analysis of the resulting audio data and compared the results to a simple linear interpolation. Here are the results:

Original sine
The original sine frequency analysis.


Sine linear 0.2
Played back with a playback factor of 0.2 and linear interpolation. At the end of the spectrum you can see two peaks.


Sine spline 0.2
Played back with a playback factor of 0.2 and my cubic spline interpolation. No peaks are visible.


Sine line 1.2
Played back with a playback factor of 1.2 and linear interpolation. Again there are peaks at the end of the spectrum.


Sine cubic spline 1.2
Played back with a playback factor of 1.2 and my spline interpolation. No peaks are visible

All in all my interpolation does a pretty good job and is also very fast. It can be used to change the pitch of music, to add doppler effects, phase shift and many more.