To be honest, I am still very much a C++ novice and my understanding of the correlation calculation is limited. I believe I have implemented a moving window of 512 samples, which I then accumulate to pump into the correlation calculation. So in one sense, it is only working one sample at a time, but in another sense, I am accumulating the value of 5 different variables each sample.

The CPU use *may* be acceptable, but almost certainly there is a way to improve my implementation.
You can see from the screenshot that my waveshaper uses very little CPU, because it strictly does only operate on the current sample, and it does simple calculations.

I am guessing that `std::sqrt`

is a potential bottleneck, and there is probably a better/more efficient data structure than the basic array, but I havenāt had the time to instrument my code for profiling yet, so wouldnāt like to guess at optimizations.

Also, I ideally wanted to have a way to make the buffer size variable, but not sure thatās really possible with my current implementation

```
A[bufferCursor % bufferSize] = inputs[CHNL_A_INPUT].getNormalVoltage(0.0f);
float ex = std::accumulate(A.begin(), A.end(), 0.0f);
```

```
return ((bufferSize * exy) - (ex * ey)) / std::sqrt(((bufferSize * exx) - (ex * ex)) * ((bufferSize * eyy) - (ey * ey)));
```