public static int calculateRMSLevel(short[] audioData,int numframes){
  long lSum=0;
  int numread=0;
  for (  short s : audioData) {
    lSum=lSum + s;
    numread++;
    if (numread == numframes)     break;
  }
  double dAvg=lSum / numframes;
  double sumMeanSquare=0d;
  numread=0;
  for (  short anAudioData : audioData) {
    sumMeanSquare=sumMeanSquare + Math.pow(anAudioData - dAvg,2d);
    numread++;
    if (numread == numframes)     break;
  }
  double averageMeanSquare=sumMeanSquare / numframes;
  return (int)(Math.pow(averageMeanSquare,0.5d) + 0.5);
}

public static int calculateRMSLevel ( short [ ] audioData , int numframes ) { long lSum = 0 ; int numread = 0 ; for ( short s : audioData ) { lSum = lSum + s ; numread ++ ; if ( numread == numframes ) break ; } double dAvg = lSum / numframes ; double sumMeanSquare = 0d ; numread = 0 ; for ( short anAudioData : audioData ) { sumMeanSquare = sumMeanSquare + Math . pow ( anAudioData - dAvg , 2d ) ; numread ++ ; if ( numread == numframes ) break ; } double averageMeanSquare = sumMeanSquare / numframes ; return ( int ) ( Math . pow ( averageMeanSquare , 0.5d ) + 0.5 ) ; }
calculates the rms audio level from the provided short sample extract
