Thursday, February 7, 2019

audio - What are good ways to detect signal clipping in a recording?


Given a recording I need to detect whether any clipping has occurred.


Can I safely conclude there was clipping if any (one) sample reaches the maximum sample value, or should I look for a series of subsequent samples at the maximum level?



The recording may be taken from 16 or 24-bit A/D converters, and are converted to floating point values ranging from $-1...1$. If this conversion takes the form of a division by $2^{15}-1$ or $2^{23}-1$, then presumably the negative peaks can be somewhat lower than -1, and samples with the value -1 are not clipped?


Obviously one can always create a signal specifically to defeat the clipping detection algorithm, but I'm looking at recordings of speech, music, sine waves or pink/white noise.



Answer



I was in the middle of typing an answer pretty much exactly like Yoda's. He's is probably the most reliable but, I'll proposed a different solution so you have some options.




If you take a histogram of your signal, you will more than likely a bell or triangle like shape depending on the signal type. Clean signals will tend to follow this pattern. Many recording studios add a "loudness" effect that causes a little bump near the top, but it is still somewhat smooth looking. Here is an example from a real song from a major musician:


Histogram


Here is the histogram of signal that Yoda gives in his answer:


Histogram with no Clipping


And now the case of their being clipping:



Histogram with Clipping


This method can be fooled at times, but it is at least something to throw in your tool bag for situations that the FFT method doesn't seem to be working for you or is too many computations for your environment.


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...