Is there a plug-ins which gives, in a way, the algebraic sum of all samples of a ‘wav’ track?
The sum, in case of a normal audio track, is zero or close to it.
But if the values of the ‘wav’ samples were corrupted, this sum would likely be far from zero. In case the sum is a big number and exceeds a certain high limit, the plug-ins needs returning the value of the limit only.
For instance, the word ‘integral’ on your code reminded me the low pass filter. Even with 0.1 Hz bandwidth (lowest limit), the filter output gives a good visual sign about the average DC of the track.
Edit1:
I run 2.3.0 on windows 7. I tested your code on a short mono track (“M_RoadToHell_ChrisRea1.wav”, I uploaded earlier). I got:
That could have been avoided by error checking. for example:
;type analyze
;version 4
(cond
((= len 0)
"Error.\nSelection Required")
((arrayp *track*)
"Error.\nStereo tracks are not supported.")
(t
(let ((t1 (/ (1- len) *sound-srate*))
(integral (mult (/ *sound-srate* len)
(integrate *track*))))
(print (abs-env (sref integral t1))))))
Another way you could do that would be to duplicate the track, then use the Normalize effect to “Remove DC offset” (only), then invert the duplicate track and mix the two tracks (Tracks menu > Mix > Mix and Render). The result will be the DC offset. This could also be automated with a Macro (Macros - Audacity Manual), or a Nyquist-Macro (Nyquist-Macros - Audacity Manual).
Thank you, Steve, for the extra work. I saved it and I will install it as a new plug-in.
Although this sum/average function may help, as I mentioned earlier, in detecting corrupted samples in rare cases, it is useful in the case (about which we will talk later if you like) when a different signature is inserted in every copy of an audio file but without affecting in any way the audio quality and its originality**… also its DC zero average**.
It should probably be “;type analyze”, given that it is analyzing the audio.
“;type process” is intended for plug-ins that return a modified (processed) version of the selected audio.