Low pass filtering on short int (16 bit PCM) samples I am writing software for processing audio given as 16-bit PCM samples. The first stage of the processing involves calculating the energy (or total variation) in a certain frequency range (above a certain cut-off frequency). 

What I am currently doing is subtracting the energy of the low-pass filtered signal from the energy of the original signal. I found out that a lot of the processing is dedicated to converting the integer sampels to a floating point representation. 

So my question is, is there a technnique for filtering the integer samples without converting them to floating point?
Yes of course, you can apply the filter directly to the integer samples, using fixed point arithmetic.

For example, if you use a FIR filter with coefficients [1 / 3, 1, 1 / 2], and an 8-bit resolution for coefficients, your output will be:

out[n] = (85 * sample[n] + 256 * sample[n - 1] + 128 * sample[n - 2]) &gt;&gt; 8


Two things to take be careful about:


Coefficients quantization might cause at best slight changes of filter responses, at worst cause filter instabilities. What is your filter type and the value of its coefficients?
Overflow / Data types / Truncation problems. In the example above, out can exceed the range of a 16-bit integer, so you will have to do some clipping.