dist/howler.js
function(sound, from, to, len, id, isGroup) {
      var self = this;
      var vol = from;
      var diff = to - from;
      var steps = Math.abs(diff / 0.01);
      var stepLen = Math.max(4, (steps > 0) ? len / steps : len);
      var lastTick = Date.now();

      // Store the value being faded to.
      sound._fadeTo = to;

      // Update the volume value on each interval tick.
      sound._interval = setInterval(function() {
        // Update the volume based on the time since the last tick.
        var tick = (Date.now() - lastTick) / len;
        lastTick = Date.now();
        vol += diff * tick;

        // Make sure the volume is in the right bounds.
        vol = Math.max(0, vol);
        vol = Math.min(1, vol);

        // Round to within 2 decimal points.
        vol = Math.round(vol * 100) / 100;

        // Change the volume.
        if (self._webAudio) {
          sound._volume = vol;
        } else {
          self.volume(vol, sound._id, true);
        }

        // Set the group's volume.
        if (isGroup) {
          self._volume = vol;
        }

        // When the fade is complete, stop it and fire event.
        if ((to < from && vol <= to) || (to > from && vol >= to)) {
          clearInterval(sound._interval);
          sound._interval = null;
          sound._fadeTo = null;
          self.volume(to, sound._id);
          self._emit('fade', sound._id);
        }
      }, stepLen);
    }
function(sound, from, to, len, id, isGroup) {
      var self = this;
      var vol = from;
      var diff = to - from;
      var steps = Math.abs(diff / 0.01);
      var stepLen = Math.max(4, (steps > 0) ? len / steps : len);
      var lastTick = Date.now();

      // Store the value being faded to.
      sound._fadeTo = to;

      // Update the volume value on each interval tick.
      sound._interval = setInterval(function() {
        // Update the volume based on the time since the last tick.
        var tick = (Date.now() - lastTick) / len;
        lastTick = Date.now();
        vol += diff * tick;

        // Make sure the volume is in the right bounds.
        vol = Math.max(0, vol);
        vol = Math.min(1, vol);

        // Round to within 2 decimal points.
        vol = Math.round(vol * 100) / 100;

        // Change the volume.
        if (self._webAudio) {
          sound._volume = vol;
        } else {
          self.volume(vol, sound._id, true);
        }

        // Set the group's volume.
        if (isGroup) {
          self._volume = vol;
        }

        // When the fade is complete, stop it and fire event.
        if ((to < from && vol <= to) || (to > from && vol >= to)) {
          clearInterval(sound._interval);
          sound._interval = null;
          sound._fadeTo = null;
          self.volume(to, sound._id);
          self._emit('fade', sound._id);
        }
      }, stepLen);
    }
function ( sound , from , to , len , id , isGroup ) { var self = this ; var vol = from ; var diff = to - from ; var steps = Math . abs ( diff / 0.01 ) ; var stepLen = Math . max ( 4 , ( steps > 0 ) ? len / steps : len ) ; var lastTick = Date . now ( ) ; // Store the value being faded to. sound . _fadeTo = to ; // Update the volume value on each interval tick. sound . _interval = setInterval ( function ( ) { // Update the volume based on the time since the last tick. var tick = ( Date . now ( ) - lastTick ) / len ; lastTick = Date . now ( ) ; vol += diff * tick ; // Make sure the volume is in the right bounds. vol = Math . max ( 0 , vol ) ; vol = Math . min ( 1 , vol ) ; // Round to within 2 decimal points. vol = Math . round ( vol * 100 ) / 100 ; // Change the volume. if ( self . _webAudio ) { sound . _volume = vol ; } else { self . volume ( vol , sound . _id , true ) ; } // Set the group's volume. if ( isGroup ) { self . _volume = vol ; } // When the fade is complete, stop it and fire event. if ( ( to < from && vol <= to ) || ( to > from && vol >= to ) ) { clearInterval ( sound . _interval ) ; sound . _interval = null ; sound . _fadeTo = null ; self . volume ( to , sound . _id ) ; self . _emit ( 'fade' , sound . _id ) ; } } , stepLen ) ; }
Starts the internal interval to fade a sound.
@param  {Object} sound Reference to sound to fade.
@param  {Number} from The value to fade from (0.0 to 1.0).
@param  {Number} to   The volume to fade to (0.0 to 1.0).
@param  {Number} len  Time in milliseconds to fade.
@param  {Number} id   The sound id to fade.
@param  {Boolean} isGroup   If true, set the volume on the group.
Starts the internal interval to fade a sound .