Method for determining dynamic gain values to be applied on a digital input audio signal, the digital input audio signal arranged in signal blocks, the dynamic gain values for attenuating input signal values exceeding a clipping threshold, the method comprising, for each signal block: - passing backwards over the next signal block and the current signal block to produce a preliminary gain contour from the input audio signal, wherein the preliminary gain contour is produced by applying in reverse an instant gain ascent and a smooth gain decay to the input audio signal by starting with the last signal sample of the next signal block and moving towards the first signal sample of the current signal block; and - passing forwards over the current signal block to produce a final gain contour for the current signal block based on the preliminary gain contour, wherein the final gain contour is produced by applying forwards an instant gain ascent and a smooth gain decay to the preliminary gain contour by starting from the first signal sample of the current signal block and working towards the last signal sample of the current signal block, wherein: if the next input signal sample in the backwards pass exceeds the clipping threshold and is larger than the current input signal sample, the preliminary gain value for the next sample is set so as to attenuate the next sample in accordance with the clipping threshold, if the next input signal sample in the backwards pass exceeds the clipping threshold and is smaller than the current one, the preliminary gain value for the next sample is set so as to smoothly decay from the gain value of the current input signal sample, and in the forwards pass, if the next preliminary gain value is larger than the current one, the next final gain value is set to the next preliminary gain value, otherwise the next final gain value is set so as to smoothly decay from the current final gain value. - passing backwards over the next signal block and the current signal block to produce a preliminary gain contour from the input audio signal, wherein the preliminary gain contour is produced by applying in reverse an instant gain ascent and a smooth gain decay to the input audio signal by starting with the last signal sample of the next signal block and moving towards the first signal sample of the current signal block; and - passing forwards over the current signal block to produce a final gain contour for the current signal block based on the preliminary gain contour, wherein the final gain contour is produced by applying forwards an instant gain ascent and a smooth gain decay to the preliminary gain contour by starting from the first signal sample of the current signal block and working towards the last signal sample of the current signal block, wherein: if the next input signal sample in the backwards pass exceeds the clipping threshold and is larger than the current input signal sample, the preliminary gain value for the next sample is set so as to attenuate the next sample in accordance with the clipping threshold, if the next input signal sample in the backwards pass exceeds the clipping threshold and is smaller than the current one, the preliminary gain value for the next sample is set so as to smoothly decay from the gain value of the current input signal sample, and in the forwards pass, if the next preliminary gain value is larger than the current one, the next final gain value is set to the next preliminary gain value, otherwise the next final gain value is set so as to smoothly decay from the current final gain value. if the next input signal sample in the backwards pass exceeds the clipping threshold and is larger than the current input signal sample, the preliminary gain value for the next sample is set so as to attenuate the next sample in accordance with the clipping threshold, if the next input signal sample in the backwards pass exceeds the clipping threshold and is smaller than the current one, the preliminary gain value for the next sample is set so as to smoothly decay from the gain value of the current input signal sample, and in the forwards pass, if the next preliminary gain value is larger than the current one, the next final gain value is set to the next preliminary gain value, otherwise the next final gain value is set so as to smoothly decay from the current final gain value. if the next preliminary gain value is larger than the current one, the next final gain value is set to the next preliminary gain value, otherwise the next final gain value is set so as to smoothly decay from the current final gain value.