xm.js
function MixSilenceIntoBuf(ch, start, end, dataL, dataR) {
  var s = ch.filterstate[1];
  if (isNaN(s)) {
    console.log("NaN filterstate?", ch.filterstate, ch.filter);
    return;
  }
  for (var i = start; i < end; i++) {
    if (Math.abs(s) < 1.526e-5) {  // == 1/65536.0
      s = 0;
      break;
    }
    dataL[i] += s * ch.vL;
    dataR[i] += s * ch.vR;
    s *= popfilter_alpha;
  }
  ch.filterstate[1] = s;
  ch.filterstate[2] = s;
  if (isNaN(s)) {
    console.log("NaN filterstate after adding silence?", ch.filterstate, ch.filter, i);
    return;
  }
  return 0;
}
function MixSilenceIntoBuf(ch, start, end, dataL, dataR) {
  var s = ch.filterstate[1];
  if (isNaN(s)) {
    console.log("NaN filterstate?", ch.filterstate, ch.filter);
    return;
  }
  for (var i = start; i < end; i++) {
    if (Math.abs(s) < 1.526e-5) {  // == 1/65536.0
      s = 0;
      break;
    }
    dataL[i] += s * ch.vL;
    dataR[i] += s * ch.vR;
    s *= popfilter_alpha;
  }
  ch.filterstate[1] = s;
  ch.filterstate[2] = s;
  if (isNaN(s)) {
    console.log("NaN filterstate after adding silence?", ch.filterstate, ch.filter, i);
    return;
  }
  return 0;
}
function MixSilenceIntoBuf ( ch , start , end , dataL , dataR ) { var s = ch . filterstate [ 1 ] ; if ( isNaN ( s ) ) { console . log ( "NaN filterstate?" , ch . filterstate , ch . filter ) ; return ; } for ( var i = start ; i < end ; i ++ ) { if ( Math . abs ( s ) < 1.526e-5 ) { // == 1/65536.0 s = 0 ; break ; } dataL [ i ] += s * ch . vL ; dataR [ i ] += s * ch . vR ; s *= popfilter_alpha ; } ch . filterstate [ 1 ] = s ; ch . filterstate [ 2 ] = s ; if ( isNaN ( s ) ) { console . log ( "NaN filterstate after adding silence?" , ch . filterstate , ch . filter , i ) ; return ; } return 0 ; }
This function gradually brings the channel back down to zero if it isn't already to avoid clicks and pops when samples end.
This function gradually brings the channel back down to zero if it isn t already to avoid clicks and pops when samples end .