Forums

Proper Overflow Adjustment

Started by abb2104 4 years ago5 replieslatest reply 4 years ago93 views

Post deleted by author

[ - ]
Reply by Tim WescottMarch 10, 2018

Are you sure you're overflowing in that step?  Running the code on a test vector and looking at the output may be instructional.  It certainly sounds nasty -- I should have dug out the cheap speakers for this one...

[ - ]
Reply by jbrowerMarch 10, 2018

Abb, I'm not clear ... you're using floating-point to look at sampled audio data ?  How did you get the data in the first place ?  Most (by far) audio devices I know of sample at no more than 24-bit fixed-point ... is that how your data was originally sampled ?

Or was it originally 16-bit ?  If the latter case, then what you're doing won't work because "overflow" (actually clipping) has already occurred and comparing with +/- max signed 16-bit values can't detect.

Also your array naming indicates you're checking frequency domain values, but your graph shows time domain waveforms ?  Please clarify.

-Jeff


[ - ]
Reply by abb2104March 10, 2018

Post deleted by author

[ - ]
Reply by jbrowerMarch 10, 2018

Abb-

I think first you may want to be absolutely sure it's overflow or clipping that you have.  My suggestion is to look carefully (zoom in to sample level), starting with your earliest waveform source, and verify.  If you have overflow you should see something like this:

audio waveform overflow example shown in Hypersignal

Overflow typically results from summing too many values in a processing step or a shifting operation gone wrong, for example you have 24-bit sampled audio data, and you shift that right to 16-bits, but some values are outside the +/- 16-bit limits.  If it's clipping it would look like this (using same waveform segment as above):

audio waveform clipping example shown in Hypersignal

Clipping typically happens at the point of sampling -- audio amplitude exceeds limits of the audio input circuit and A/D converter.

To look for these artifacts, try to find areas of your waveform that are relatively smooth and low frequency, approximating a sinusoid (as in the pics).  To be relatively sure, amplitude needs to be approaching 16-bit limits -32768 / 32767 but in recent data (say 20 samples or so) has not exceeded them.

Depending on what you see, continue to check each stage of your processing flow.  You may find that overflow or clipping is being introduced by an intermediate processing or format conversion stage, and was not in your original sampled data.  So it's a basic debug process -- go step-by-step with a magnifying glass :-) 

If you find either of these artifacts, they can be compensated using an algorithm, but that approach is complex and depending on the waveform content and amount of artifact, I don't think there is any foolproof method to restore original audio under all circumstances.

-Jeff

[ - ]
Reply by Tim WescottMarch 10, 2018

Mixed by adding all the channels together?  If so, the overflow could be happening in the mixer.