示例#1
0
    //My method
    public void CrossCorrelate(float[] signalA, float[] signalB)
    {
        Complex[] ComplexSignalA = new Complex[signalA.Length];
        Complex[] ComplexSignalB = new Complex[signalB.Length];
        //Convert float values from signal to complex numbers
        for (int i = 0; i < signalA.Length; i++)
        {
            //First parameter is the real value second is the imaginary
            ComplexSignalA[i] = new Complex(signalA[i], 0);
            ComplexSignalB[i] = new Complex(signalB[i], 0);
        }

        crossCorrelationCoefficient = Mathf.Lerp((float)crossCorrelationCoefficient,
                                                 (float)Correlation.CorrelationCoefficient(ComplexSignalA, ComplexSignalB), 5 * Time.deltaTime);
    }