Clip Fix plugin- way to fix clipping, do a subtler effect?

The Clip Fix plugin seems to do a reasonably good job of helping with a speaker who was considerably louder and closer to the microphone than people who set up the recording stuff had figured on; the interpolation manages to take much of the “boom/buzz” out of the voice. However, it causes clipping. After reducing the recording’s levels by the suggested 10dB to give headroom and then applying the plugin, there are a lot of places where it clips- the signal hits ~+4dB occasionally during the speech and tops out at +22 dB for mic handling noise. Simply reducing levels by 22dB is not an option; nothing will be audible except those momentary bits of noise. Hitting it with a compressor seems kind of funny, esp. if I have to first lower levels by 22dB and then use -22dB as the threshhold for the compressor- the result isn’t awful but I think it probably causes some distortions and higher noise levels.

Anybody have an idea where the 10dB suggestion for headroom comes from, why the Clip Fix plugin generates some excessively loud (32dB above signal) interpolations, and what could be done about this?

I know that one [raising hand].

If you set the US ANSI C16.5 VU meter…

… to “zero” tone and put show through it, the readings, given natural sounds (and not special effects) were almost always about 10dB or so louder than the meter reading. This gave you a good idea how to set the electronics, clipping, and noise floor for the rest of the system.

It was sloppy, and we’re the only ones using this system. Other countries went with variations on the peak-reading meter such as the British PPM that didn’t have this difference, but the idea stuck, mostly because of the need to exchange shows between countries. As is pointed out frequently, you can produce a very nice show using either one given that you’re paying attention.

Also…

If you’re producing live work, the number goes up. Most musicians or voice performers can blow right past 10dB headroom without breathing hard, so they take higher numbers like 15 or 20.

Broadcast video “tone” level is -20 in the US. 20dB of increased level before you have to worry about overloading the channel. In Europe, it’s -18.

Clip Fix, like Noise Removal should not be taken literally. Each one only works well on a very strict, tiny subset of problems. Most of what you would naturally consider noise and clipping is far outside the abilities of either of these tools.

As a result, you can’t actually recover from most noise and clipping. Clipping in particular is one of the four deadly horsemen. Few people recover shows with severe clipping or peak distortion.

the Clip Fix plugin generates some excessively loud (32dB above signal) interpolations

The tool isn’t actually fixing clipping. It’s guessing that any signal close to or actually at 0 is probably damage and it tries to guess what the peak signal probably should have been given the work, frequencies and rise and fall times before and after. What people really want is a tool that intelligently analyses the instruments and singing and generates a whole new voice or trumpet or bass guitar to fill in the hole left by the overload.

I’m not shocked that this simple tool doesn’t work like that. Like most Audacity tools, this one is a math function, not a musical one.

Koz

Convert your track to 32 bit float before doing any processing. 32 bit can handle a huge dynamic range. It may appear clipped in the waveform display but the above-zero values are really there, which you can see by amplifying by a negative amount.

Apply the Clip Fix effect as suggested. Amplify by -6 dB to get most of the audio below zero. Then deal with the huge pops from mic handling noise. There are a number of ways to deal with that, but selecting them and then amplifying by an appropriate amount to get them down to the level of the rest of the audio would work, but might be time consuming.

You could try Steve’s Pop Mute Nyquist effect on the handling noise: https://forum.audacityteam.org/t/new-plug-in-effect-popmute/17499/1

– Bill

kozikowski, I really doubt that the plugin author’s recommendation about how much to reduce levels before using the plugin was based on old VU meters.

The tool isn’t actually fixing clipping. It’s guessing that any signal close to or actually at 0 is probably damage and it tries to guess what the peak signal probably should have been given the work, frequencies, rise and fall times before and after. What people really want is a tool that intelligently analyses the instruments and singing and generates a whole new voice or trumpet or bass guitar to fill in the hole left by the overload.

Good grief. It was clear from my previous post that I know the plugin is simply interpolating and that I’m finding its results to be mostly satisfactory. It was even more clear that I’m not expecting any miracles or production of information ex nihilo here. It’s rude and condescending of you to act like I am. Your reply on my other topic was similarly unhelpful-- assuming that I’m a moron who has to be told what a mic jack is.

Please, if you don’t have anything helpful to say, don’t just waste people’s time being insulting.

billw58- good point. The original input was 16-bit and the final output will be as well, but I’ve been working in 32-bit all along; I hadn’t really thought about about it, but that gives me enough room that even the naive compressor solution may be OK. I’ll take a look at the Pop Mute plugin as well. Hopefully I can avoid having to take the manual intervention route- I’m looking at dozens of hours of speech here, and manually selecting and attenuating every excessively loud interpolation could get to be very problematic.

However, I do still wonder about options to either restrict the range of values the Clip Fix plugin can use in its interpolation or introduce some kind of amplitude weighting in the process of choosing an “optimal” interpolation. If I weren’t already so behind in stuff I need to get done I’d pull out my Lisp book and a Nyquist tutorial and see if I couldn’t do something about that. The source of the Clip Fix plugin says it uses simple cubic spline interpolation, apparently based just on simply-approximated derivatives immediately prior to and after the clipped region. The amplitude of the resulting spline and the frequency content introduced aren’t really taken into account. I imagine that it’d be simple to add the ability to trade off a small amount of precision in matching the derivatives for keeping the amplitude within reason, but making that fast enough could be a challenge (I haven’t looked closely at the code but I imagine it solves a simple linear system to find the spline right now, and off the top of my head I’m not thinking of any way to take amplitude into account that doesn’t involve solving a more complex optimization problem for each clipped segment). Taking the introduced frequencies into account would be more work; Adobe Audition and several other pieces of software apparently rely somewhat on the FFTs of the surrounding data points in their “declippers.”

How good are you with mathematics?

Clipfix.ny processes the audio on a sample by sample basis (which is why this effect is so slow).
First it looks for clipped regions and marks them.
Then it calculates the slope at the start and end of these marked regions.
Finally it calculates the curves for the “repaired” samples (based, as you say, on cubic spline interpolation).

The spline interpolation produces a curve with relatively little “distortion” effects (it mostly doesn’t sound too bad when repairing audio that is not clipped too badly) and the “join” between the repair and the original audio is smooth.

The code that accomplishes the interpolation is:

(let* ((t1 (car exithigh))  ;;exit time
       (t2 (car returnhigh)) ;;return time
       (d1 (max 0 (/ (- (aref r t1) (aref r (- t1 (1- drange)))) (1- drange)))) ;;slope at exit
       (d2 (min 0 (/ (- (aref r (+ t2 (1- drange))) (aref r t2)) (1- drange)))) ;;slope at return
       (m (/ (+ d2 d1) (* (- t2 t1) (- t2 t1)))) ;;interpolation is by (t-t1)(t-t2)(mx+b)
       (b (- (/ d2 (- t2 t1)) (* m t2))) ;;These values of m and b make the cubic seamless
       (j (1+ t1))) ;; j is the index

(while (< j t2)
  (setf (aref r j) 
    (+ (aref r t1)
       (* (- j t1) (- j t2) (+ (* m j) b))))
  (setf (aref r j)
    (+ (* (- t2 j) (/ (aref r t1) (- t2 t1)))
       (* (- j t1) (/ (aref r t2) (- t2 t1)))
       (* (- j t1) (- j t2) (+ (* m j) b))))
  (setq j (1+ j))))

I understand the code well enough to modify it, but I don’t understand the mathematics well enough to know how to “improve” the formula. (I’m primarily a musician rather than a mathematician :wink: )

If you think that you can modify the formula so that it produces a better curve for the purpose, then I could help with the coding to implement it (does not need to be now, I mean if/when you have time to work on this).

Perhaps a more simple approach would be for the effect to apply “progressive compression” of the repaired audio with a “wave-shaper” so as to prevent it from going excessively high.