float m = numberOfTaps -1;   if(cutoffFreq == 0.0) {  float tapTotal = 0;  for(int i=0;i<numberOfTaps;i++) { temptaps[i] = (float)(0.54 - 0.46*java.lang.Math.cos((2*pi)*(i/m))); tapTotal += temptaps[i]; }
float pi = (float)java.lang.Math.PI;  float temptaps[] = new float[numberOfTaps];
    public void init(float sampleRate, float cutFreq, int numTaps)    {	//all frequencies are in hz	samplingRate = sampleRate;	cutoffFreq = cutFreq;	numberOfTaps = numTaps;	COEFF = new float[numTaps];	float pi = (float)java.lang.Math.PI;	//build the taps, and call super.init(taps[])	float temptaps[] = new float[numberOfTaps];	float m = numberOfTaps -1; 	//from Oppenheim and Schafer, m is the order of filter   	if(cutoffFreq == 0.0)	    {		//Using a Hamming window for filter taps:		float tapTotal = 0;				for(int i=0;i<numberOfTaps;i++)		    {			temptaps[i] = (float)(0.54 - 0.46*java.lang.Math.cos((2*pi)*(i/m)));			tapTotal += temptaps[i];		    }		//normalize all the taps to a sum of 1		for(int i=0;i<numberOfTaps;i++)		    {			temptaps[i] = temptaps[i]/tapTotal;		    }	    }	else{	    //ideal lowpass filter ==> Hamming window	    //has IR h[n] = sin(omega*n)/(n*pi)	    //reference: Oppenheim and Schafer	    float w = (2*pi) * cutoffFreq/samplingRate;	    	    for(int i=0;i<numberOfTaps;i++)		{		    //check for div by zero		    if(i-m/2 == 0)			temptaps[i] = w/pi;		    else			temptaps[i] = (float)(java.lang.Math.sin(w*(i-m/2)) / pi 				       / (i-m/2) * (0.54 - 0.46						    * java.lang.Math.cos((2*pi)*(i/m))));		}	}	COEFF = temptaps;	numberOfTaps = COEFF.length;    }