Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static double goertzel(double[] data, double freq, double sr) { double s_prev = 0; double s_prev2 = 0; double coeff = 2 * Math.cos((2 * Math.PI * freq) / sr); double s; for (int i = 0; i < data.length; i++) { double sample = data[i]; s = sample + coeff * s_prev - s_prev2; s_prev2 = s_prev; s_prev = s; } double power = s_prev2 * s_prev2 + s_prev * s_prev - coeff * s_prev2 * s_prev; return power; } }