public double getPower(double f, double[] signal, int offset, int len, double scale) {
        int N = len;
        int M = N + offset;
        
        double o = 2* Math.PI / N;
        
        //hamming window
        for (int i = offset; i < M; i++) {
            signal[i] *= (0.54-0.46 * Math.cos(o* i));
        }
        
        //Goertzel filter
        double realW = 2.0 * Math.cos(o* scale* f);
        double imagW = Math.sin(o * scale* f);
        
        double d1 = 0.0;
        double d2 = 0.0;
        double y = 0;
        
        for (int n = offset; n < M; ++n) {
            y  = signal[n] + realW*d1 - d2;
            d2 = d1;
            d1 = y;
        }
        
        double resultr = 0.5*realW*d1 - d2;
        double resulti = imagW*d1;
        
        return Math.sqrt( (resultr * resultr) + (resulti * resulti));
    }
public double getPower ( double f , double [ ] signal , int offset , int len , double scale ) { int N = len ; int M = N + offset ; double o = 2 * Math . PI / N ; for ( int i = offset ; i < M ; i ++ ) { signal [ i ] *= ( 0.54 - 0.46 * Math . cos ( o * i ) ) ; } double realW = 2.0 * Math . cos ( o * scale * f ) ; double imagW = Math . sin ( o * scale * f ) ; double d1 = 0.0 ; double d2 = 0.0 ; double y = 0 ; for ( int n = offset ; n < M ; ++ n ) { y = signal [ n ] + realW * d1 - d2 ; d2 = d1 ; d1 = y ; } double resultr = 0.5 * realW * d1 - d2 ; double resulti = imagW * d1 ; return Math . sqrt ( ( resultr * resultr ) + ( resulti * resulti ) ) ; }
Calculates power of the specified frequence of the specified signal.

@param f the frequence value.
@param signal sampled signal.
@param offset index of the first sample of the signal.
@param len the length of signal in samples
@param scale the length of signal in seconds
@return the power of the specified frequency