I have this recording from my DAW that showed a strange form of distortion: the signal clipped at many places, but instead of simply being clipped (loss of information), somehow the integer value of the signal overflowed and has been stored in the file. It resulted in worse-sounding distortion, but the information is still there, as a mirrored image in the opposite side of the signal.
This is plainly evident when looking at the waveform. You can clearly tell when the signal clips because the rest of the wave is visible between the peaks.
How should I approach fixing this file? I am very comfortable with SOX, ffmpeg, the C language, SuperCollider and various other tools.