private int autoCorrelation(int index, int windowWidth) {

		double max = -1;
		int indexAtMaximum = -1;
		
		if(index + windowWidth > modifiedSamples.length){
			return -1;
		}
		
		windowWidth = windowWidth/2;
		
		//the window is assigned as between i and i + windowWidth
		int end = index + windowWidth;
		
		for(int i = (index+20); i < end; i++){//value added to index dramatically reduces analysis time
			
			double difference = 0;
			
			//the sum of every value in the window (-20) multiplied by every other value in the window
			for(int j = 0; j < windowWidth; j++){
				difference+= modifiedSamples[index+j] * //index + j cycles through every value in the current window
						modifiedSamples[i+j]; //i + j cycles through a window sized range of values starting at index + i
			}
			
			//the largest multiplication of the magnitudes is recorded
			//along with the point in the window that it occurred
			if(difference > max){
				max = difference;
				indexAtMaximum = i;
			}
		}//the index within the window that produced the largest result is returned
		return indexAtMaximum;
	}