[music-dsp] Re: Declipping
James Chandler Jr
jchandjr at bellsouth.net
Mon Feb 21 12:34:05 EST 2005
Some dumb ideas--
Given a third-generation cassette copy of a clipped live recording, which
someone had already processed with EQ and Compression, the distortion would be
easy to identify by ear, but perhaps nearly impossible to fix with a de-clipper
However, even a less-ambitious de-clipper which only aspires to repair D-A
overload hard clips on a 'fresh' disk file, could still be useful. If you just
recorded that perfect sax take, but unfortunately there were hard-clip overloads
on a few notes...
For a less-ambitious de-clipper which doesn't pretend to fix all cases, perhaps
it is safe to make some assumptions?
If this is a nonrealtime disk-based declipper tool, perhaps we can assume the
user wouldn't have invoked the plugin unless there is high probability of
clipping in the file?
Given this assumption, we could pre-scan the entire file for max positive and
negative values. Even if the track had been gain-scaled after the original
recording, we might safely infer that the audio max positive and max negative
values which are found in the file, are the hard-clip rails?
If the track has been otherwise processed (other than gain scaling), this simple
scheme probably wouldn't be reliable.
Anyway, one could identify likely hard-clips by looking for samples at the
positive and negative 'clip rails'.
If using float samples for processing, we don't have to worry about a max
amplitude until we convert back to a possibly integer file format. After the
clips have been repaired, we could 'normalize' down the entire repaired file so
that the new max values will comfortably fit in the output sample format.
To 'fix' a single sample that hits the rail, perhaps set that sample to zero,
and then center a sinc FIR on the zero sample. Use a kernel with steep
attenuation right below nyquist? Shouldn't the FIR pretty accurately guess the
value of that single missing sample? Each single sample clip, could be repaired
with a single FIR calculation, to recover the value of that missing sample which
would 'fit within nyquist'?
Similarly, if there are two consecutive samples 'on the rail', use a sinc FIR
set for quarter-band, to guestimate the two consecutive missing samples?
With clips of progressively longer lengths, more high frequency info would be
lost by this process, but perhaps whatever info that survives the FIR at least
would't sound as obnoxious as hard-clipping?
This approach might work fairly well for sparse short-duration clipping? It
might not work very well for sustained sections of clipping, a long chain of
heavy-clipped wave cycles.
Perhaps on long clips, rather than setting clips to zero before filtering, one
might first use a Hermite interpolator to guess the missing samples? Then FIR to
smooth out whatever 'errors' are in the Hermite interpolation? Maybe something
like that would sound better on a long chain of heavy-clipped wave cycles?
Perhaps multiple passes would help? First scan the file and fix any
single-sample clips. Then scan the file and fix any two-sample clips, etc? Or
perhaps it would be better to first attempt fixing the longer clips, and work
down to the single-clip instances?
More information about the music-dsp