DSPRelated.com
Forums

unclipping

Started by glen herrmannsfeldt March 4, 2012
I have a digitized WAV file about 71 minutes long (actually, 10
files totaling 71 minutes) with three samples clipped, I believe
not all consecutive. 

I can't actually hear them, as I usually can with much more
clipping, but I do know that they are there. I was, then,
wondering about possibly reducing the effect by substituting
(after rescaling) a more appropriate value. Most likely it
wouldn't work well for longer clipped regions, but maybe for
such short ones.

One that I have thought about so far is to fit a quadratic to
the two points before and after and use its value at the point
(or two) in question. I don't remember ever hearing about anyone
else doing something like this. 

-- glen
On 3/4/12 8:12 PM, glen herrmannsfeldt wrote:
> I have a digitized WAV file about 71 minutes long (actually, 10 > files totaling 71 minutes) with three samples clipped, I believe > not all consecutive.
only three isolated samples? they're at 0x7FFF or 0x8000 ?
> > I can't actually hear them, as I usually can with much more > clipping, but I do know that they are there.
if they're isolated spikes that cut trimmed back a bit, i dunno how you would be able to hear it as clipping.
> I was, then, > wondering about possibly reducing the effect by substituting > (after rescaling) a more appropriate value. Most likely it > wouldn't work well for longer clipped regions, but maybe for > such short ones. > > One that I have thought about so far is to fit a quadratic to > the two points before and after and use its value at the point > (or two) in question. I don't remember ever hearing about anyone > else doing something like this. >
i sure thought that someone in the AES has done a paper or convention preprint about this. seems to me that they would approach the clipped region from both the left and the right, analyzing the audio on both sides and coming up with an LPC model, and then at the clipped region using the LPC to extend into it, sorta crossfading from the left-to-right LPC to the right-to-left LPC. something about this rings a bell, but i dunno who had done it. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
robert bristow-johnson <rbj@audioimagination.com> wrote:
> On 3/4/12 8:12 PM, glen herrmannsfeldt wrote: >> I have a digitized WAV file about 71 minutes long (actually, 10 >> files totaling 71 minutes) with three samples clipped, I believe >> not all consecutive.
> only three isolated samples? they're at 0x7FFF or 0x8000 ?
All three at X'8000'. The peak light blinked at least twice, so two might be together.
>> I can't actually hear them, as I usually can with much more >> clipping, but I do know that they are there.
> if they're isolated spikes that cut trimmed back a bit, i > dunno how you would be able to hear it as clipping.
(snip)
>> One that I have thought about so far is to fit a quadratic to >> the two points before and after and use its value at the point >> (or two) in question. I don't remember ever hearing about anyone >> else doing something like this.
> i sure thought that someone in the AES has done a paper or convention > preprint about this. seems to me that they would approach the clipped > region from both the left and the right, analyzing the audio on both > sides and coming up with an LPC model, and then at the clipped region > using the LPC to extend into it, sorta crossfading from the > left-to-right LPC to the right-to-left LPC. something about this rings > a bell, but i dunno who had done it.
For a longer one, something more complicated would be better. I thought a simpler one would do for one or two samples. -- glen
>I have a digitized WAV file about 71 minutes long (actually, 10 >files totaling 71 minutes) with three samples clipped, I believe >not all consecutive. > >I can't actually hear them, as I usually can with much more >clipping, but I do know that they are there. I was, then, >wondering about possibly reducing the effect by substituting >(after rescaling) a more appropriate value. Most likely it >wouldn't work well for longer clipped regions, but maybe for >such short ones. > >One that I have thought about so far is to fit a quadratic to >the two points before and after and use its value at the point >(or two) in question. I don't remember ever hearing about anyone >else doing something like this. > >-- glen >
You want to fudge the audio to mask the effect of the clipping, but you can't hear the clipping right now? Sounds like your job is done. :-) Steve
On 3/4/12 9:47 PM, glen herrmannsfeldt wrote:
> robert bristow-johnson<rbj@audioimagination.com> wrote: >> On 3/4/12 8:12 PM, glen herrmannsfeldt wrote: >>> I have a digitized WAV file about 71 minutes long (actually, 10 >>> files totaling 71 minutes) with three samples clipped, I believe >>> not all consecutive. > >> only three isolated samples? they're at 0x7FFF or 0x8000 ? > > All three at X'8000'. The peak light blinked at least twice, > so two might be together.
even if 2 samples are adjacent, i can't imagine that clipping to be salient, from an audibility perspective. dunno what the problem is.
>>> I can't actually hear them, as I usually can with much more >>> clipping, but I do know that they are there. > >> if they're isolated spikes that cut trimmed back a bit, i >> dunno how you would be able to hear it as clipping. > > (snip) >>> One that I have thought about so far is to fit a quadratic to >>> the two points before and after and use its value at the point >>> (or two) in question. I don't remember ever hearing about anyone >>> else doing something like this. > >> i sure thought that someone in the AES has done a paper or convention >> preprint about this. seems to me that they would approach the clipped >> region from both the left and the right, analyzing the audio on both >> sides and coming up with an LPC model, and then at the clipped region >> using the LPC to extend into it, sorta crossfading from the >> left-to-right LPC to the right-to-left LPC. something about this rings >> a bell, but i dunno who had done it. > > For a longer one, something more complicated would be better. > I thought a simpler one would do for one or two samples. >
well, the only way to guess at what the unclipped level is, is from the adjacent segments of samples, both on the left and the right, that are not clipped. you can take two samples and linearly extend it. three unclipped samples and quadratically extend it. four and cubicly extend it. might not be such a bad guess for just one or two samples. but i doubt that one or two samples that are clipped amidst a bunch of unclipped samples is an audible problem anyway. heck, they might not be clipped, but the segment might be normalized and those were the maximum samples that got normalized to fullscale. but if you had a segment of audio where 50 adjacent samples were clipped, that's different. first, it will be audible. second, probing in from the left and from the right gets shakier and shakier the deeper in you go. the only method that i can recall that had any good results was something using LPC. but neither steve nor i really get what the problem is if you have 1 or 2 or 3 isolated samples (or maybe 2 are adjacent) that are at one rail or the other. sounds like someone turned on "Normalize" or "AGC" or something and just took the audio up to the rail with no headroom. you might not have a problem at all. "If it sounds good, it *is* good." ain't that right? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
robert bristow-johnson <rbj@audioimagination.com> wrote:

(snip)
> even if 2 samples are adjacent, i can't imagine that clipping to be > salient, from an audibility perspective. dunno what the problem is.
(snip, I wrote)
>>>> I can't actually hear them, as I usually can with much more >>>> clipping, but I do know that they are there.
(snip)
> well, the only way to guess at what the unclipped level is, is from the > adjacent segments of samples, both on the left and the right, that are > not clipped. you can take two samples and linearly extend it. three > unclipped samples and quadratically extend it. four and cubicly extend > it. might not be such a bad guess for just one or two samples. but i > doubt that one or two samples that are clipped amidst a bunch of > unclipped samples is an audible problem anyway. heck, they might not be > clipped, but the segment might be normalized and those were the maximum > samples that got normalized to fullscale.
I know I have had ones before that I could hear. The tend to come from a single loud drum beat, which doesn't have the right sound. (snip)
> but neither steve nor i really get what the problem is if you > have 1 or 2 or 3 isolated samples (or maybe 2 are adjacent) > that are at one rail or the other. sounds like someone > turned on "Normalize" or "AGC" or something and just took > the audio up to the rail with no headroom.
I made the recording, so I know how it was done. There is no AGC, it just turned out louder than I thought. It it helps any, it is Shostakovich Symphony No. 10. in the second movement. I had noticed in the first movement that it was getting higher than I expected (0.6dB below clipping, I now know) and turned the level down a little before the second movement. I turned it down even more before the third movement. If you want even more details, I compute the RMS and both positive and negative peaks for each track. The first was -35.3dB RMS, -0.6dB for the negative peak, and -1.8dB for the positive peak. The second -32.3dB RMS, -0.0dB for negative peak, and -2.2dB for the positive peak. The third, with the level turned down more, -41.7dB RMS, -10.3dB negative peak, and -10.4dB positive peak. Even more, it was recorded on a Tascam DR-1. I don't remember if there is an option for ALC, but if there is I don't use it.
> you might not have a problem at all.
> "If it sounds good, it *is* good." ain't that right?
Well, I could try listening even more carefully. -- glen
glen herrmannsfeldt wrote:

> I have a digitized WAV file about 71 minutes long (actually, 10 > files totaling 71 minutes) with three samples clipped, I believe > not all consecutive. > > I can't actually hear them, as I usually can with much more > clipping, but I do know that they are there. I was, then, > wondering about possibly reducing the effect by substituting > (after rescaling) a more appropriate value. Most likely it > wouldn't work well for longer clipped regions, but maybe for > such short ones. > > One that I have thought about so far is to fit a quadratic to > the two points before and after and use its value at the point > (or two) in question. I don't remember ever hearing about anyone > else doing something like this.
You can do this in audacity. Select the clipped region and use the repair tool (or whatever it's called). It will 'repair' up to 128 samples. I use it usually for repairing clicks and ticks in analog recordings (those old fashioned black vinyl disks ;-) bye Andreas -- Andreas H&#4294967295;nnebeck | email: acmh@gmx.de ----- privat ---- | www : http://www.huennebeck-online.de Fax/Anrufbeantworter: 0721/151-284301 GPG-Key: http://www.huennebeck-online.de/public_keys/andreas.asc PGP-Key: http://www.huennebeck-online.de/public_keys/pgp_andreas.asc
Andreas Huennebeck <acmh@gmx.de> wrote:

(snip)
> You can do this in audacity. Select the clipped region and use the > repair tool (or whatever it's called). It will 'repair' up to 128 samples. > I use it usually for repairing clicks and ticks in analog recordings (those > old fashioned black vinyl disks ;-)
I remember in the vinyl days, a box that you could put between the turntable and amplifier, or maybe after the pre-amp, that would remove such ticks, I believe with analog circuits. Always too expensive for me, though. -- glen
On Mon, 05 Mar 2012 07:56:42 +0000, glen herrmannsfeldt wrote:

> robert bristow-johnson <rbj@audioimagination.com> wrote: > > (snip) >> even if 2 samples are adjacent, i can't imagine that clipping to be >> salient, from an audibility perspective. dunno what the problem is. > > (snip, I wrote) >>>>> I can't actually hear them, as I usually can with much more >>>>> clipping, but I do know that they are there. > > (snip) >> well, the only way to guess at what the unclipped level is, is from the >> adjacent segments of samples, both on the left and the right, that are >> not clipped. you can take two samples and linearly extend it. three >> unclipped samples and quadratically extend it. four and cubicly extend >> it. might not be such a bad guess for just one or two samples. but i >> doubt that one or two samples that are clipped amidst a bunch of >> unclipped samples is an audible problem anyway. heck, they might not >> be clipped, but the segment might be normalized and those were the >> maximum samples that got normalized to fullscale. > > I know I have had ones before that I could hear. The tend to come from a > single loud drum beat, which doesn't have the right sound. > > (snip) > >> but neither steve nor i really get what the problem is if you have 1 or >> 2 or 3 isolated samples (or maybe 2 are adjacent) that are at one rail >> or the other. sounds like someone turned on "Normalize" or "AGC" or >> something and just took the audio up to the rail with no headroom. > > I made the recording, so I know how it was done. There is no AGC, it > just turned out louder than I thought. > > It it helps any, it is Shostakovich Symphony No. 10. in the second > movement. I had noticed in the first movement that it was getting higher > than I expected (0.6dB below clipping, I now know) and turned the level > down a little before the second movement. I turned it down even more > before the third movement. > > If you want even more details, I compute the RMS and both positive and > negative peaks for each track. The first was -35.3dB RMS, -0.6dB for the > negative peak, and -1.8dB for the positive peak. The second -32.3dB RMS, > -0.0dB for negative peak, and -2.2dB for the positive peak. The third, > with the level turned down more, -41.7dB RMS, -10.3dB negative peak, and > -10.4dB positive peak. > > Even more, it was recorded on a Tascam DR-1. I don't remember if there > is an option for ALC, but if there is I don't use it. > > >> you might not have a problem at all. > >> "If it sounds good, it *is* good." ain't that right? > > Well, I could try listening even more carefully.
Well, next time use a floating-point ADC, for heaven's sake! (Slightly) more seriously, in theory you could use an ADC with sufficient dynamic range to encompass the dynamic range of your analog system. Assuming you have lots of $$. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Tim Wescott <tim@seemywebsite.com> wrote:

(snip, I wrote)
>> Well, I could try listening even more carefully.
> Well, next time use a floating-point ADC, for heaven's sake!
> (Slightly) more seriously, in theory you could use an ADC with > sufficient dynamic range to encompass the dynamic range of > your analog system. Assuming you have lots of $$.
The DR-1 has, and I used, 24 bit WAV, and usually not so close to clipping. This one I did with a different microphone position, which might have made the level a little higher, but I didn't think that much higher. Either this symphony is a lot louder, or the microphone position makes more difference than I though. (or both.) I record them 24 bit, check the RMS and peak amplitude for each track, and then choose a shift value from those. (That is, changes in 6dB increments.) Since the rest of the analog signal chain might not be good enough for 24 bits, I try not to get too low, but if I use 18 to 20 bits it shouldn't be so far off. -- glen