plectrum

Plectrum: instrument tuner for Android
Log | Files | Refs | README | LICENSE

BlackmanHarrisNuttall.java (654B)


      1 package be.tarsos.dsp.util.fft;
      2 
      3 /**
      4  * @author joren
      5  * See https://mgasior.web.cern.ch/mgasior/pap/FFT_resol_note.pdf
      6  */
      7 public class BlackmanHarrisNuttall extends WindowFunction {
      8 	float c0 = 0.355768f;
      9 	float c1 = 0.487396f;
     10 	float c2 = 0.144232f; 
     11 	float c3 = 0.012604f;
     12 	
     13 	@Override
     14 	protected float value(int length, int index) {
     15 	      
     16 		float sum = 0;
     17 		
     18 		sum += c0 * Math.cos((TWO_PI * 0 * index ) / (float) (length)) ;
     19 		sum += c1 * Math.cos((TWO_PI * 1 * index ) / (float) (length));
     20 		sum += c2 * Math.cos((TWO_PI * 2 * index ) / (float) (length));
     21 		sum += c3 * Math.cos((TWO_PI * 3 * index ) / (float) (length));
     22 		
     23 		return sum;
     24 	}
     25 
     26 }