DSPRelated.com
Forums

Data types in Audio Signal Processing

Started by akin...@hotmail.com April 20, 2008
Hello

I want to implement my own audio equalizer.

First of all I create FIR& IIR bandpass filters but they process"doubl" or "float" samples. But I get sound samples as shorts ( 16bit) from both Directshow and Waveout API. How can I handle data type conversion between floaats and shorts ?

They say that i must divide shorts by 32768 to get floats. But how should I put my processed floats back ?

Best Regards,
Akın Öcal
On Sat, 19 Apr 2008, a...@hotmail.com wrote:

> They say that i must divide shorts by 32768 to get floats.

That's true. Just remember to convert to floats before division. In C it
looks like:

float_sample = (float)short_sample * 3.05175781e-05;

I've used multiplying by (1/32768) instead of division, as most processors
are faster at multiplication than division.

> But how should I put my processed floats back ?

Just multiply them by 32768 and then cast to shorts. Assuming your filter
never produces samples out of <-1.0; +32767/32768> range. It is easily
achieved with normalized FIR.

--
Grzegorz Kraszewski
http://teleinfo.pb.edu.pl/~krashan