Improving a voice recording with heavy clipping

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
kozikowski
Forum Staff
Posts: 68902
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: Improving a voice recording with heavy clipping

Post by kozikowski » Sun Oct 05, 2014 3:25 pm

Bumper sticker version
So the original has very little energy over about 4KHz and and we are talking about a performance similar to an airplane pilot's voice. Most of the intelligence is conveyed through psycho-acoustic recognition rather than plain good quality. Also see: bad cellphone call with pieces missing and somehow a message manages to squeak through.

There is no rescue. All we can do is turn the damage into other damage.

Koz

Trebor
Posts: 9847
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: Improving a voice recording with heavy clipping

Post by Trebor » Sun Oct 05, 2014 3:50 pm

kozikowski wrote:What's the bumper-sticker explanation of that? ...
Here's the visual equivalent of before-after median filter ...
Image
http://en.wikipedia.org/wiki/Median_filter

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Improving a voice recording with heavy clipping

Post by Robert J. H. » Sun Oct 05, 2014 5:22 pm

I've come up with something similar to Trebor's plug-in.
It uses linear prediction coding instead of de-whitening in the fourier domain ( ;O, what's this guy talking about?).
In other words, all streets lead to Rome.
Original-distorted-ba.wav
(133.55 KiB) Downloaded 59 times
The original is actually a bit more clipped. I've exported it to wave with a gain of 22 dB (!).
The filter has been applied after re-importing.

The code is:

Code: Select all

(defun pre-emphase (s) (snd-biquad s 1 -0.96 0 0 0 0 0))
(defun de-emphase (s) (snd-biquad s 1 0 0 0.96 0 0 0))
;; voice model extraction
(setf lpanal-class (send class :new '(sound framesize skipsize npoles)))
(send lpanal-class :answer :isnew '(snd frame-sz skip-sz np) '(
  (setf sound (snd-copy snd))
  (setf framesize frame-sz)
  (setf skipsize skip-sz)
  (setf npoles np)))
(send lpanal-class :answer :next '() '(
  (let ((samps (snd-fetch-array sound framesize skipsize)))
    (cond ((null samps) nil)
          (t 
           (snd-lpanal samps npoles))))))
(defun make-lpanal-iterator (sound framedur skiptime npoles)
  (send lpanal-class :new sound 
     framedur skiptime npoles))
(psetq blocksize 200; in samples
       advance-by 50; in samples
       order 10); modify at will
;; analyze:
(setf obj (make-lpanal-iterator (pre-emphase s) 
   blocksize advance-by order))
;; apply filter to original:
(de-emphase (scale-db -35 
   (snd-lpreson s obj (/ advance-by  *sound-srate*))))
The values after "psetq" can all be changed.
(note that the code is only for mono files)

kozikowski
Forum Staff
Posts: 68902
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: Improving a voice recording with heavy clipping

Post by kozikowski » Sun Oct 05, 2014 6:29 pm

Here's the visual equivalent of before-after median filter ...
I agree you can do wonders with pictures whose information doesn't change that much pixel by pixel, but a greater similarity to this problem is motion video.

People have made "de-noisers" that trade off motion for the idea of averaging (or processing) successive frames whose information doesn't change that much. The result is gooie, swimmy, slippery motion that's completely noise free, or gritty, noisy perfect motion.

Free lunch being just out of grasp. The product never made the big time.

So we're trying to identify the damaged portion of the wave and reconstruct the missing bits by guessing what would have been there had the wave been allowed to continue on its journey? Given massive clipping, I'm not shocked that he reconstructed wave is 20dB higher than anyone is expecting. Also given massive clipping, the slope before and after the damage is less and less representative of the original voice. Also given this was an admittedly "seat of the pants" recording, the system/microphone analog noise will make this an interesting academic exercise with little or no practical value.

Koz

Trebor
Posts: 9847
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: Improving a voice recording with heavy clipping

Post by Trebor » Sun Oct 05, 2014 9:08 pm

kozikowski wrote: ... All we can do is turn the damage into other damage.
Yes but sometimes less psycho-acoustically offensive "other damage" is possible.

Trebor
Posts: 9847
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: Improving a voice recording with heavy clipping

Post by Trebor » Sun Oct 05, 2014 9:19 pm

Robert J. H. wrote:I've come up with something similar to Trebor's plug-in.
"Darrel Tam" created that plugin, not me, ... www.kvraudio.com/product/dtblkfx_by_darrell_tam
Robert J. H. wrote:... all streets lead to Rome ...
What you've achieved with that code sounds (and looks) just like increasing-contrast using the "DtBlkFx" plugin (which is Windows & Mac only). It's effectively like increasing contrast on the spectrogram.

[ NB: that "contrast" code can't cope with silence , if the audio you select includes proper flat-line silence the effect won't work and Audacity may crash ]
Robert J. H. wrote:...modify at will ...
IMO setting blocksize to 1000 (rather than 200) with a sample-rate of 16kHz, ( maybe just me though ).
before-after spectrogram showing increased ''contrast''achived using Robert-J-H code.gif
before-after spectrogram showing increased ''contrast''achived using Robert-J-H code.gif (118.19 KiB) Viewed 1329 times
Last edited by Trebor on Sun Oct 05, 2014 10:17 pm, edited 2 times in total.

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Improving a voice recording with heavy clipping

Post by Robert J. H. » Sun Oct 05, 2014 10:01 pm

Trebor wrote:
Robert J. H. wrote:I've come up with something similar to Trebor's plug-in.
"Darrel Tam" created that plugin, not me, ... www.kvraudio.com/product/dtblkfx_by_darrell_tam
Robert J. H. wrote:... all streets lead to Rome ...
What you've achieved with that code sounds (and looks) just like increasing-contrast using the "DtBlkFx" plugin (which is Windows & Mac only). It's effectively like increasing contrast on the spectrogram.

[ NB: that "contrast" code can't cope with silence , if the audio you select includes proper flat-line silence the effect won't work and Audacity may crash ]
(you mean my code?
Yes, it is a known bug, lpanal returns NAN values (division by zero) for all coefficients.

I forgot to mention that mixing in white noise helps a lot (amp. 0.001).
One can actually use white noise alone instead of the original.
A clean voice will sound whispered because the excitation is missing, whereas filtering a buzz, saw-tooth and alike sound supresses unvoiced parts--the famous robot effect.
The poles of the LPC (called "order" in the above code) determine the accuracy of the voice synthesis.
For 4 formants, the order should be twice plus 2 --> 10 poles. "S" and "Z" may require 300 poles to exactly reproduce them.

Alonshow
Posts: 83
Joined: Sat Oct 29, 2011 4:12 pm
Operating System: Windows 10

Re: Improving a voice recording with heavy clipping

Post by Alonshow » Sun Oct 05, 2014 10:39 pm

Thank you, Trebor, that improved the quality a bit. I was wondering though, if the de-clicking and de-crackling that you mention in the other median plugin thread would be useful in this case.

Trebor
Posts: 9847
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: Improving a voice recording with heavy clipping

Post by Trebor » Mon Oct 06, 2014 3:54 am

Alonshow wrote:Thank you, Trebor, that improved the quality a bit. I was wondering though, if the de-clicking and de-crackling that you mention in the other median plugin thread would be useful in this case.
Your "original.mp3" isn't clicking or crackling, so de-clicking and de-crackling software aren't going to help.
Even the paid-for de-noise programs I have don't make much difference to your "original.mp3".
The Nyquist code Robert-J-H came up with above, or the DtBlkFx plugin, is about the best you're going to get ,
less-noisy at the expense of sounding more-synthesised.
[ The audio recovery seen in Hollywood movies is science-fiction ].

Cutting off all the frequencies below 200Hz with the equalizer makes it sound a little less harsh.
Best I can do wit DtBlkfx (alternating).wav
(600.82 KiB) Downloaded 55 times
If you compare it with the codecs used in radio-telephony , like LPC10 and Speex, the computery-ness isn't that bad.

Post Reply