src/codeandchords/input/Input.java
public synchronized void process(TimeStamp startTime, TimeStamp endTime, float[] powerSpectrum) {
			if (bufferSize != powerSpectrum.length) {
				bufferSize = powerSpectrum.length;
				bin2hz = sampleRate / (2 * bufferSize);
			} // if

			hps  = new float[powerSpectrum.length];

			features = null;
			// now pick best peak from linspec
			double pmax = -1;
			int maxbin = 0;
			
			// This is where the hps squishing happens:
			for(int i = 0; i < hps.length; i++)
			{
				hps[i]  = powerSpectrum[i];
			} // for

			// 2:
			int  i;
			for(i = 0; (i * 2) < hps.length; i++)
			{
				hps[i]  = hps[i] + powerSpectrum[i*2];
			} // for

			// 3:
			for(i = 0; (i * 3) < hps.length; i++)
			{
				hps[i]  = hps[i] + powerSpectrum[i*3];
			} // for

			// 4:
			for(i = 0; (i * 4) < hps.length; i++)
			{
				hps[i]  = hps[i] + powerSpectrum[i*4];
			} // for

			// Pick the largest frequency from the hps spectrum:
			for (int band = FIRSTBAND; band < hps.length; band++) {
				double pwr = hps[band];
				if (pwr > pmax) {
					pmax = pwr;
					maxbin = band;
				} // if
			} // for

			// I (Emily) added the following line;
			// 10/5 edits may cause it to be a larger num than it was previously:
//			amplitude  = (float)pmax;
			amplitude	= powerSpectrum[maxbin];

			// cubic interpolation
			double yz = hps[maxbin];
			double ym;
			if(maxbin <= 0) {
				ym = hps[maxbin];
			} else {
				ym = hps[maxbin - 1];
			} // else

			double yp;
			if(maxbin < hps.length - 1) {
				yp  = hps[maxbin + 1];
			} else {
				yp  = hps[maxbin];
			} // else

			double k = (yp + ym) / 2 - yz;
			double x0 = (ym - yp) / (4 * k);
			features = (float)(bin2hz * (maxbin + x0));

			forward(startTime, endTime);
		}
/* (non-Javadoc)
		 * @see com.olliebown.beads.core.PowerSpectrumListener#calculateFeatures(float[])
		 * 
		 * This is where the harmonic product spectrum is calculated.
		 * 
		 * @param powerSpectrum	frequency-domain spectrum to be analyzed
		 */


This is where the harmonic product spectrum is calculated.

@param powerSpectrum frequency-domain spectrum to be analyzed
This is where the harmonic product spectrum is calculated . @param powerSpectrum frequency - domain spectrum to be analyzed
public synchronized void process(TimeStamp startTime, TimeStamp endTime, float[] powerSpectrum) {
			if (bufferSize != powerSpectrum.length) {
				bufferSize = powerSpectrum.length;
				bin2hz = sampleRate / (2 * bufferSize);
			} 
			hps  = new float[powerSpectrum.length];
			features = null;
			double pmax = -1;
			int maxbin = 0;
			for(int i = 0; i < hps.length; i++)
			{
				hps[i]  = powerSpectrum[i];
			} 
			int  i;
			for(i = 0; (i * 2) < hps.length; i++)
			{
				hps[i]  = hps[i] + powerSpectrum[i*2];
			} 
			for(i = 0; (i * 3) < hps.length; i++)
			{
				hps[i]  = hps[i] + powerSpectrum[i*3];
			} 
			for(i = 0; (i * 4) < hps.length; i++)
			{
				hps[i]  = hps[i] + powerSpectrum[i*4];
			} 
			for (int band = FIRSTBAND; band < hps.length; band++) {
				double pwr = hps[band];
				if (pwr > pmax) {
					pmax = pwr;
					maxbin = band;
				} 
			} 
			amplitude	= powerSpectrum[maxbin];
			double yz = hps[maxbin];
			double ym;
			if(maxbin <= 0) {
				ym = hps[maxbin];
			} else {
				ym = hps[maxbin - 1];
			} 
			double yp;
			if(maxbin < hps.length - 1) {
				yp  = hps[maxbin + 1];
			} else {
				yp  = hps[maxbin];
			} 
			double k = (yp + ym) / 2 - yz;
			double x0 = (ym - yp) / (4 * k);
			features = (float)(bin2hz * (maxbin + x0));
			forward(startTime, endTime);
		}
public synchronized void process ( TimeStamp startTime , TimeStamp endTime , float [ ] powerSpectrum ) { if ( bufferSize != powerSpectrum . length ) { bufferSize = powerSpectrum . length ; bin2hz = sampleRate / ( 2 * bufferSize ) ; } hps = new float [ powerSpectrum . length ] ; features = null ; double pmax = - 1 ; int maxbin = 0 ; for ( int i = 0 ; i < hps . length ; i ++ ) { hps [ i ] = powerSpectrum [ i ] ; } int i ; for ( i = 0 ; ( i * 2 ) < hps . length ; i ++ ) { hps [ i ] = hps [ i ] + powerSpectrum [ i * 2 ] ; } for ( i = 0 ; ( i * 3 ) < hps . length ; i ++ ) { hps [ i ] = hps [ i ] + powerSpectrum [ i * 3 ] ; } for ( i = 0 ; ( i * 4 ) < hps . length ; i ++ ) { hps [ i ] = hps [ i ] + powerSpectrum [ i * 4 ] ; } for ( int band = FIRSTBAND ; band < hps . length ; band ++ ) { double pwr = hps [ band ] ; if ( pwr > pmax ) { pmax = pwr ; maxbin = band ; } } amplitude = powerSpectrum [ maxbin ] ; double yz = hps [ maxbin ] ; double ym ; if ( maxbin <= 0 ) { ym = hps [ maxbin ] ; } else { ym = hps [ maxbin - 1 ] ; } double yp ; if ( maxbin < hps . length - 1 ) { yp = hps [ maxbin + 1 ] ; } else { yp = hps [ maxbin ] ; } double k = ( yp + ym ) / 2 - yz ; double x0 = ( ym - yp ) / ( 4 * k ) ; features = ( float ) ( bin2hz * ( maxbin + x0 ) ) ; forward ( startTime , endTime ) ; }
(non-Javadoc)
 @see com.olliebown.beads.core.PowerSpectrumListener#calculateFeatures(float[])
( non - Javadoc ) @see com . olliebown . beads . core . PowerSpectrumListener#calculateFeatures ( float [] )
// if // now pick best peak from linspec // This is where the hps squishing happens: // for // 2: // for // 3: // for // 4: // for // Pick the largest frequency from the hps spectrum: // if // for // I (Emily) added the following line; // 10/5 edits may cause it to be a larger num than it was previously: //			amplitude  = (float)pmax; // cubic interpolation // else // else