function SmoothArray(numSamples) {
    var numSamples = numSamples
    // Number of samples that will be used for smoothing the samples
    var smoothArray = [];
    var pos = 0;

    this.push = function(vol) {
        // adds the sample to the correct location
        smoothArray[pos] = vol;
        pos = (pos +1) % numSamples;

        // returns smoothened value
        var sum = smoothArray.reduce(function(a, b) { return a + b; });
        var mean = sum / smoothArray.length;
        return mean;
    }.bind(this);

    this.getSmoothArray = function() {
        return smoothArray;
    }.bind(this);
}
//Class for smoothening the volume signal
Class for smoothening the volume signal
Class for smoothening the volume signal
function SmoothArray(numSamples) {
    var numSamples = numSamples
    var smoothArray = [];
    var pos = 0;
    this.push = function(vol) {
        smoothArray[pos] = vol;
        pos = (pos +1) % numSamples;
        var sum = smoothArray.reduce(function(a, b) { return a + b; });
        var mean = sum / smoothArray.length;
        return mean;
    }.bind(this);
    this.getSmoothArray = function() {
        return smoothArray;
    }.bind(this);
}
function SmoothArray ( numSamples ) { var numSamples = numSamples var smoothArray = [ ] ; var pos = 0 ; this . push = function ( vol ) { smoothArray [ pos ] = vol ; pos = ( pos + 1 ) % numSamples ; var sum = smoothArray . reduce ( function ( a , b ) { return a + b ; } ) ; var mean = sum / smoothArray . length ; return mean ; } . bind ( this ) ; this . getSmoothArray = function ( ) { return smoothArray ; } . bind ( this ) ; }
Class for smoothening the volume signal
Class for smoothening the volume signal
// Number of samples that will be used for smoothing the samples // adds the sample to the correct location // returns smoothened value