WebMVC/wwwroot/lib/audio/audio_record_lib_cust.js
// the top of the measurement range.
the top of the measurement range.
the top of the measurement range .
function SoundMeter(context) {
  this.context = context;
  this.instant = 0.0;
  this.slow = 0.0;
  this.clip = 0.0;
  this.script = context.createScriptProcessor(2048, 1, 1);
  var that = this;
  this.script.onaudioprocess = function(event) {
	var input = event.inputBuffer.getChannelData(0);
	var i;
	var sum = 0.0;
	var clipcount = 0;
	for (i = 0; i < input.length; ++i) {
	  sum += input[i] * input[i];
	  if (Math.abs(input[i]) > 0.99) {
		clipcount += 1;
	  }
	}
	that.instant = Math.sqrt(sum / input.length);
	that.slow = 0.95 * that.slow + 0.05 * that.instant;
	that.clip = clipcount / input.length;
  };
}
function SoundMeter ( context ) { this . context = context ; this . instant = 0.0 ; this . slow = 0.0 ; this . clip = 0.0 ; this . script = context . createScriptProcessor ( 2048 , 1 , 1 ) ; var that = this ; this . script . onaudioprocess = function ( event ) { var input = event . inputBuffer . getChannelData ( 0 ) ; var i ; var sum = 0.0 ; var clipcount = 0 ; for ( i = 0 ; i < input . length ; ++ i ) { sum += input [ i ] * input [ i ] ; if ( Math . abs ( input [ i ] ) > 0.99 ) { clipcount += 1 ; } } that . instant = Math . sqrt ( sum / input . length ) ; that . slow = 0.95 * that . slow + 0.05 * that . instant ; that . clip = clipcount / input . length ; } ; }
the top of the measurement range.
the top of the measurement range .