I am amplifying an audio file frame-by-frame via the following algorithm:

  1. Find maximum value among all the samples in a frame
  2. Find the amplification factor to make the maximum value equal to 0 dB
  3. Multiply the entire frame by the above amplification factor

The above algorithm makes many samples close to 0 dB in the signal (as expected). However, when played, those samples which are close to 0 dB create a very sharp tick or click. The signal is full of such sharp ticks/clicks drastically deteriorating the listening experience.

How to avoid generating such ticks/clicks?

Edit: Tetsujin's method given in the 1st comment (to change the amplitude from 0 dB to -0.3 dB) seems to have reduced some of the clicks. But there are abundant clicks remaining at frame boundaries. I changed the amplitude from 0 dB to -0.3 dB to -1 dB to -3 dB to -10 dB but the clicks do not seem to go away. What should I do now? I have tried to read and look up what all of you were discussing but due to my limited knowledge, I couldn't see how should I go about implementing those things in my code. Could you please help me with what exactly should I do to reduce the "intersample/interframe clipping"?

  • 1
    Don't normalise to 0dB, normalise to -0.3
    – Tetsujin
    Feb 21 '17 at 13:22
  • 1
    Also, amplifying by frame leaves you with an issue at frame borders - your process adds in high freq, potentially high amplitude signals...
    – Rory Alsop
    Feb 21 '17 at 13:47
  • @Tetsujin Thanks a lot, it worked. Could you please explain why it works? Also, I would be grateful if you could add your comment as an Answer so that I can accept it. Feb 21 '17 at 14:00
  • @RoryAlsop Thanks for your expert comments, I am new to Audio Processing. Could you please help me with what I should do instead? I want as high amplification as possible and the different parts of the signal have different amplitudes. Feb 21 '17 at 14:01
  • 1
    Clicks occur whenever a sudden, extreme change in amplitude occurs over a one or a few samples. To avoid clicking, you need to make your volume changes gradual by, say, having all your frames overlap by 100 samples and crossfading them. Still, I'll repeat what everyone else is saying: use a compressor. Even if you manage to eliminate the clicking, this method will still produce (sonically) bad results.
    – Linuxios
    Feb 23 '17 at 17:03

firstly your normalization factor will be different frame to frame. I cannot think of the application you will be using this for as it will create discontinuities across frame boundaries and introduce artifacts.

Additionally, your method doesn't take into account inter-sample peaks. You are normalizing only the visible peaks but in reality - once the audio has been converted back to analogue - you may experience clipping in the audio waveform between the samples. You need to up-sample your audio to at least 4x the original sampling rate in order to cover for inter-sample peaks.

You should not change the normalization factor on a frame-by-frame basis but you should scan all the audio and then apply a gross normalization factor across the whole file.

In my honest opinion your efforts are pointless. There is no reason to do what you are doing. You should not be normalizing audio to the highest possible level as all you are doing is increasing overall loudness and increasing the noise floor along with the signal.

A more useful exercise would be to normalize to a known loudness (LKFS) factor.

  • 1
    Plus, if you really want to adjust the dynamic range, use a dynamic range compressor. Much easier.
    – Marc W
    Feb 23 '17 at 15:00

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.