HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: tapedeck on 2019-09-25 17:29:33

Title: Hard Limiting with SOX
Post by: tapedeck on 2019-09-25 17:29:33
Howdy
Does anyone have any tips on achieving a hard limiter type effect with sox and the compand effect?

I have a recording from vinyl that generally peaks at -6db, but occasionally a click or pop will show up all the way up to 0db. All I want to do is tame these stray clicks so that they don't screw with normalisation later.

In audacity, I do this using the hard limiter effect, set to -6db.

I've come up with compand 0.1,0.1 -6,-6,0,-6 0 -90 0.1 which to me says

put one point of the transfer function at -6,-6 (so everything below this remains unchanged), and put another point at 0 (x-axis) and -6 (y-axis) so that anything above -6 would be limited to -6db.

I'm unclear what to put for 'initial level' so I used the suggested -90, and I set the delay to match the attack exactly 0.1 so it would be a lookahead limiter. I would think however that I would want an attack closer to 0, but wasnt sure if that was supported in sox.

I am attaching a short sample that includes one 'pop' I would like to limit to -6db.

Any tips?

Thanks yall
Title: Re: Hard Limiting with SOX
Post by: DVDdoug on 2019-09-25 18:20:21
I've never used SoX but there are specailized applications (http://www.delback.co.uk/lp-cdr.htm#clean_pops) for "cleaning up" digitized vinyl.    These tools will probably work better if you don't first limit the click.

Wave Corrector (https://www.wavecor.co.uk/) (fully automatic) is now FREE!   I've used Wave Repair (http://www.delback.co.uk/wavrep/) ($30 USD) for a long time.   It's manual, so it only "touches" the audio where you identify a defect and it offers several repair methods/algorithms, but it's VERY time consuming.     It does an audibly perfect job removing most (but not all) clicks & pops.   It's often easier to remove the really bad clicks & pops, probably because they are easiest to "find".

Or, Audacity has an automatic Click Removal effect, a manual Repair effect, or as a last resort you can zoom-in and re-draw the waveform.   Audacity also has a good limiter.

O, if you simply want to clip the waveform, you can amplify (by +6dB in your case) with SoX, or Audacity, or whatever, and export as a regular (integer) WAV file.   That will normalize your file at the same time.
Title: Re: Hard Limiting with SOX
Post by: tapedeck on 2019-09-25 18:26:38
Thanks for the tips.
I am specifically trying to do this with sox and I'm not really trying to necessarily remove the clicks automatically, I just want to limit them so that I can run normalisation and get a better result.
(side note: I have tried this with an audacity macro and that appears to be broken, 'this operation cannot be done until importation of FILE1.wav completes').

Its not a terrible idea to just boost the signal, but I'm afraid that might make the click worse by clipping it so harshly. Still, its a good idea and I'm going to try just boosting and see how that works.

But really, I'm curious how to set the compand up in sox for hard limiting.

Thanks again
Title: Re: Hard Limiting with SOX
Post by: DVDdoug on 2019-09-25 19:17:21
Quote
and I set the delay to match the attack exactly 0.1 so it would be a lookahead limiter. I would think however that I would want an attack closer to 0, but wasnt sure if that was supported in sox.
The documentation is confusing (to me) but I think you've got it right.  (I guess you can't enter a negative attack time so you have to use the delay.) 

"The proof is in the pudding"...   Is it working for you as-expected?  

Quote
side note: I have tried this with an audacity macro and that appears to be broken, 'this operation cannot be done until importation of FILE1.wav completes').
Did you try it without a macro?  

I've done a couple of quick experiments with the Audacity limiter and it seems to look-ahead slightly when set to "hard limit"...  The wave shape didn't seem to change...   I couldn't see any distortion when I zoomed-in.    (There were older versions of Audacity that would simply clip when set to 'hard limit" but the current version is much nicer.)
Title: Re: Hard Limiting with SOX
Post by: tapedeck on 2019-09-25 19:27:55
"The proof is in the pudding"...   Is it working for you as-expected?
Ha no, absolutely not - that's why I'm asking for advice on what I'm doing wrong. It appears that nothing is happening.

Did you try it without a macro?
Yes - I can achieve the effect I want in Audacity using the hard limiter set to -6db. However doing it via macro appears to be broken - audacity apparently doesn't want to process a file until the full waveform is drawn, but it tries (and fails) anyway. This looks like a bug to me.

So if anyone knows how I can achieve a hard-limiter effect in sox, I'm all ears!

Thanks!