         //            kernel[j] = 0.0
         //        }
 
-        var kernelRealp = [Float](repeating: 0, count: inputCount)
-        var kernelImagp = [Float](repeating: 0, count: inputCount)
+        var kernelRealp = [Float](repeating: 0, count: frameSize)
+        var kernelImagp = [Float](repeating: 0, count: frameSize)
         var kernelTransformedComplex = DSPSplitComplex(realp: &kernelRealp, imagp: &kernelImagp)
 
         let ktemp = UnsafePointer<Float>(kernel)

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

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

            res + element * element
        }

        var powerTermFirstElement:Float = 0.0
        for j in 0 ..< yinBufferSize {
            powerTermFirstElement += buffer[j] * buffer[j]
        }

        powerTerms[0] = powerTermFirstElement

