Unit testing audio algorithms?

Is there a way to somewhat reliably unit-test audio algorithms?

I’m thinking for example making sure filters behave the same on different samplerates etc.

You could throw a sine in and compare the max output amplitude? not exactly neat…
Do a spectal analysis and compare that? Same problem with accuracy etc.

Is there a better way than manually testing? Some result on stackoverflow said this is lost territory…

1 Like

Spectral analysis doesn’t sound too bad. Send in an impulse, depending on the filter calculate enough bins of your impulse response (IIR might need more than FIR), zero-pad to taste for better comparison and transform to frequency domain. Accuracy shouldn’t be a problem, if you doubt it you can still do the transform with double precision.

You just have to keep in mind that the filters’ frequency responses won’t match near their Nyquist frequencies, the rest should be quite similar.

hmm but then I would have to check for a X% margin, and also, I can’t hit the same points in the spectrum, since FFT produces a discrete spectrum the sample points of which wouldn’t be the same (unless I use exactly 2 times the original samplerate… which I could for testing purposes…)

Calculating the Fourier-coefficients for a set of specific frequencies (combined with a look up table of target values (or ranges)) could help here. However, it won’t be as efficient as using the FFT.

Alternative: resampling of the gathered IRs, however then you have to trust your resampling algorithm :slight_smile:

1 Like

IIRC, there was a talk from Adobe’s Audition team at last year’s ADC on testing, probably worth looking up the video of that.

I came across this one when pondering about algorithm testing a long time ago:
Automated system level testing of a software audio platform
Not that specific but good overview of the topic.

1 Like