 Electronic Pages Die Homepage der Familie Beis

## False and Correct Audio Correlation Measurements

### Preface

A while ago I implemented audio correlation measurements in several projects, e.g., in the Digital Audio Peak Level and Correlation Meter DPLCM-VFD. I cared about how to do that correctly and implemented it in a digital algorithm. This algorithm is not just trivial. Later I heard about a very simple method which obviously is implemented even in several professional audio devices. Hardly more than two simple comparators and one Exclusive Or should do. Could that be true? I doubted that.

### Audio Correlation Measurement Basics

In our case correlation means the similarity of two audio signals. These two signals can be:

• +100% correlated, i.e., both signals are identical (except that their levels may be completely different).
• -100% correlated, i.e., both signals are identical but inverted to each other (while their levels may again be different).
• 0% correlated, i.e., both signals are either completely independent of each other or, e.g. in case of sine waves, 90° phase shifted.
• Anything in between

The correlation is either expressed in % from -100% to +100% or as the correlation factor, which ranges from -1 to +1. Note that due to the correlation algorithm the level of both signals does not matter, i.e., it does not influence the measured result.

When a mono source is used for a stereo signal both stereo channels will be +100% correlated. When e.g. in a stereo signal both channels contain completely different signals, e.g. left (and only left) is the trumpet and right (and only right) is the guitar these stereo channels will be 0% correlated. With a third instrument appearing in both channels, the correlation will be somewhere between 0 and +100%.

### The Correct Algorithm

Instead of explaining it mathematically I rather use a block diagram. For this algorithm

• two times two signals need to be multiplied,
• two times a signal needs to be squared,
• two times the square root of a signal needs to be calculated,
• one division takes place and
• three identical low-pass filters are necessary.

This algorithm can be implemented as an analog circuit using 7 multipliers and a couple of op-amps. It can be implemented digitally, of course, too.

### The "Simplified" Algorithm

I put "simplified" in quotation marks, because it is not only simplified. Actually it is incorrect. Even though it seems to be used often. Only the signals' zero crossings are evaluated. I wouldn't say this algorithm is just easier to implement than the one above. Instead, I would rather say it is trivial. And thus cheap, of course.

### What is the Difference, how Big is the Error?

When you compare both algorithms working with pure sine waves only they both show the same results. Both results do not depend on the signals' amplitudes and in both cases phase shifts of 0°, 90° and 180° result in correlation factors of +1, 0 and -1. So far there is no difference.

But when you use more complex signals like in the examples below, both results differ from each other:

Due to the fact that in these examples the zero crossings of both signals are the same, the "simplified" algorithm will result 100% correlation even though both signals are obviously not fully correlated. The red and the blue signal is evaluated for the correlation result. Both signals are the sum of a sine wave and its 3rd and 5th harmonic. The difference between both signals is that in the blue signal the sum of the 3rd and 5th harmonic seems to be phase reversed (it is not perfectly phase reversed). To be precise,
the red signal is y = sin(x) + 0.35 * sin(3 * x )+ 0.91 * sin(5 * x) and
the blue signal is y = sin(x) + 0.5 * sin(3 * x) - 0.5 * sin(5 * x)

The actual correlation of the signal pairs above is approx. 42%. Compared to this correct result, the "simplified" algorithm's result of 100% is a simple catastrophe.

In another experiment I tried the third harmonic only: In this case
the red signal is y = sin(x) + sin(3 * x) and
the blue signal is y = sin(x) - sin(3 * x) / 3.

And in this case the actual correlation of the signal pairs is approx. 44%.

By the way, the correlation between the red and the green signal above is 70.7% while it is 95% between the blue and the green signal.

Admittedly, these examples are extreme cases. In practice the errors will be significantly less but still the "simplified" results will be more or less rough estimations only. For professional equipment such rough estimations are totally unacceptable. People would kill you there for much less.

 Last update: October 13th, 2015 Questions? Suggestions? Email Me! Uwe Beis