First off, there seems to be a sparse number of low level audio programming tutorials out there so if anyone knows of some good resources I would be very appreciative. Now on to the topic at hand!

I am using WASAPI for the audio engine that I am trying to develop and I am having difficulties reformatting read audio file data into a format that the audio device is prepared to receive. Specifically I am wondering how to on the fly convert the sampling rate and bit depth of a read audio file into the requested format of the device. I saw an example where linear interpolation was used but read elsewhere that such a filter introduces too many artifacts such as aliasing, so again I'm wondering what practical algorithms would be for reformatting audio data in a real time application.


Sinc interpolation introduces no aliasing artifacts to data that was originally properly bandlimited before sampling. (But needs to be slightly modified, as a Sinc or Dirichlet kernel has an infinite duration.)

One canonical reference on why reconstruction works and how to interpolate is here: https://ccrma.stanford.edu/~jos/resample/

I have a simple implementation in Basic here: http://www.nicholson.com/rhn/dsp.html#3

The other common method is low-pass filtered integer ratio upsampling followed by low-pass filtered integer ratio downsampling by the appropriate two ratios. Another common method is to generate a polyphase FIR filter bank (of multiple phases of windowed Sinc (or otherwise optimized FIR filters) interpolation kernels. Another common method is to use polynomial interpolaters of each of the Sinc kernel's humps, resulting in a Farrow filter bank.

You need to carry enough bits of arithmetic intermediate values in order to keep your quantization noise floor below whatever your spec might be.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.