             res + element * element
         }
 
-        let powerTermFirstElement = buffer.reduce(0.0, addSquare)
+        var powerTermFirstElement:Float = 0.0
+        for j in 0 ..< yinBufferSize {
+            powerTermFirstElement += buffer[j] * buffer[j]
+        }
 
         powerTerms[0] = powerTermFirstElement
 

        vDSP_fft_zrip(fftSetup!, &kernelTransformedComplex, 1, log2n, FFTDirection(FFT_FORWARD))


        var yinStyleACFRealp = [Float](repeating: 0, count: inputCount)
        var yinStyleACFImagp = [Float](repeating: 0, count: inputCount)
        var yinStyleACFComplex = DSPSplitComplex(realp: &yinStyleACFRealp, imagp: &yinStyleACFImagp)

        for j in 0 ..< inputCount {

        let inputCount = bufferSizePOT / 2
        let fftSetup = vDSP_create_fftsetup(log2n, Int32(kFFTRadix2))

        // buffer.count : 4410 - inputCount : 2048 - yinBufferSize : 2205
        NSLog("buffer.count : \(buffer.count) - inputCount : \(inputCount) - yinBufferSize : \(yinBufferSize)")

        var audioRealp = [Float](repeating: 0, count: inputCount)
        var audioImagp = [Float](repeating: 0, count: inputCount)
        var audioTransformedComplex = DSPSplitComplex(realp: &audioRealp, imagp: &audioImagp)
