[Freeswitch-dev] Audio hard-limiting vs. switch_normalize_to_16bit (was: Re: Codes I don't understand)

Nic Bellamy nicb-lists at vadacom.co.nz
Mon Apr 6 21:15:04 PDT 2009

Anthony Minessale wrote:
> 2) the macro is designed to fight clipping:
>     When a sample exceeds the max size of the datatype we set it to 
> the max value then cut the volume in half of that sample so it does 
> not make too much noise.  if we divide everything by 2 then all the 
> volume would be reduced even on samples that fell inside the proper range.
Hi Anthony, all,
    this is, in my opinion, actually going to give you far far uglier 
audio artefacts than simply hard limiting the samples. Rather than try 
and describe the resulting distortion, it's easier to just listen to it 
in action...

Each of the following files is about 100kb.

Original file (extracted from 

After 30dB gain and hard limiting samples to between -32768 and 32767:

After 30dB gain and switch_normalize_to_16bit():


Nic Bellamy,
Head Of Engineering, Vadacom Ltd - http://www.vadacom.co.nz/

More information about the Freeswitch-dev mailing list