-1

Given an audio byte array data in python like so

inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NONBLOCK, card)

# Set attributes: Mono, 48000 Hz, 16 bit little endian samples
inp.setchannels(1)
inp.setrate(48000)
inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
l, data = inp.read()

How do I detect digital clipping, which value does data have to exceed to be sure that it was digitally clipped?

4

1 回答 1

1

Overdrive is basically gain distortion. It raises the voltage to the point that the driver just cuts the top off and thus distorts the signal. If you need to test this in a digital sense, it would be hard clipping. So you would need to search for values that pass the maximum threshold. With 16-bit audio files the clip is going to be 0db by the nature of it. Because if theres no more bits left to save to, then the software will automatically chop it off to the maximum a 16 bit integer can hold. Unfortunately if the track had been previously distorted and then had the volume lowered so as to blend into the mix better, your probably not going to find it. Unless that is, what you're examining is the only sound source on the track, it which case just find the maximum for the track and set that as your threshold. I can say though that hard clipping shows up as a square wave, so you could search for consecutively identical values for a time period longer then a common audible wave (as to ignore legitimate square wave tones). Thats about the best I can do for you though.

于 2013-05-17T22:12:29.773 回答