<p>Is there an algorithm or some heuristic to decide whether digital audio data is <a href="http://en.wikipedia.org/wiki/Clipping_(audio)#Digital_clipping" rel="nofollow noreferrer">clipping</a>?</p>

[{'answer_id': 53028, 'author': 'Adam Davis', 'author_id': 2915, 'author_profile': 'https://Stackoverflow.com/users/2915', 'pm_score': 3, 'selected': False, 'text': '<p>If you ever receive values at the maximum or minimum, then you are, by definition, clipping.  Those values represent their particular value as well as all values beyond, and so they are best used as outside bounds detectors.</p>\n\n<p>-Adam</p>\n'}, {'answer_id': 53053, 'author': 'Mat Noguchi', 'author_id': 1799, 'author_profile': 'https://Stackoverflow.com/users/1799', 'pm_score': 2, 'selected': False, 'text': '<p>What Adam said. You could also add some logic to detect maximum amplitude values over a period of time and only flag those, but the essence is to determine if/when the signal hits the maximum amplitude.</p>\n'}, {'answer_id': 53115, 'author': 'Ben Collins', 'author_id': 3279, 'author_profile': 'https://Stackoverflow.com/users/3279', 'pm_score': 2, 'selected': False, 'text': '<p>For digital audio data, the term "clipping" doesn\'t really carry a lot of meaning other than "max amplitude".  In the analog world, audio data comes from some hardware which usually contains a "clipping register", which allows you the possibility of a maximum amplitude that isn\'t clipped.</p>\n\n<p>What might be better suited to digital audio is to set some threshold based on the limitations of your output D/A.  If you\'re doing VOIP, then choose some threshold typical of handsets or cell phones, and call it "clipping" if your digital audio gets above that.  If you\'re outputting to high-end home theater systems, then you probably won\'t have any "clipping".</p>\n'}, {'answer_id': 59844, 'author': 'Benedikt Waldvogel', 'author_id': 4308, 'author_profile': 'https://Stackoverflow.com/users/4308', 'pm_score': 2, 'selected': False, 'text': '<p>I just noticed that there even are some nice implementations.</p>\n\n<p>For example in <a href="http://audacity.sourceforge.net/" rel="nofollow noreferrer">Audacity</a>:<br/>\n<em>Analyze</em> → <em>Find Clipping…</em></p>\n'}, {'answer_id': 176110, 'author': 'Martin Vilcans', 'author_id': 2711383, 'author_profile': 'https://Stackoverflow.com/users/2711383', 'pm_score': 4, 'selected': True, 'text': "<p>The simple answer is that if any sample has the maximum or minimum value (-32768 and +32767 respectively for 16 bit samples), you can consider it clipping. This isn't stricly true, since that value may actually be the correct value, but there is no way to tell whether +32767 really should have been +33000.</p>\n\n<p>For a more complicated answer: There is such a thing as sample counting clipping detectors that require x consecutive samples to be at the max/min value for them to be considered clipping (where x may be as high as 7). The theory here is that clipping in just a few samples is not audible.</p>\n\n<p>That said, there is audio equipment that clips quite audible even at values below the maximum (and above the minimum). Typical advice is to master music to peak at -0.3 dB instead of 0.0 dB for this reason. You might want to consider any sample above that level to be clipping. It all depends on what you need it for.</p>\n"}]
['https://Stackoverflow.com/questions/53012', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4308/']