dancer.js
function ( source ) {
      var _this = this;
      this.path = source ? source.src : this.path;

      this.isLoaded = false;
      this.progress = 0;

      !window.soundManager && !smLoading && loadSM.call( this );

      if ( window.soundManager ) {
        this.audio = soundManager.createSound({
          id       : 'dancer' + Math.random() + '',
          url      : this.path,
          stream   : true,
          autoPlay : false,
          autoLoad : true,
          whileplaying : function () {
            _this.update();
          },
          whileloading : function () {
            _this.progress = this.bytesLoaded / this.bytesTotal;
          },
          onload   : function () {
            _this.fft = new FFT( SAMPLE_SIZE, SAMPLE_RATE );
            _this.signal = new Float32Array( SAMPLE_SIZE );
            _this.waveform = new Float32Array( SAMPLE_SIZE );
            _this.isLoaded = true;
            _this.progress = 1;
            _this.dancer.trigger( 'loaded' );
          }
        });
        this.dancer.audio = this.audio;
      }

      // Returns audio if SM already loaded -- otherwise,
      // sets dancer instance's audio property after load
      return this.audio;
    }
function ( source ) {
      var _this = this;
      this.path = source ? source.src : this.path;

      this.isLoaded = false;
      this.progress = 0;

      !window.soundManager && !smLoading && loadSM.call( this );

      if ( window.soundManager ) {
        this.audio = soundManager.createSound({
          id       : 'dancer' + Math.random() + '',
          url      : this.path,
          stream   : true,
          autoPlay : false,
          autoLoad : true,
          whileplaying : function () {
            _this.update();
          },
          whileloading : function () {
            _this.progress = this.bytesLoaded / this.bytesTotal;
          },
          onload   : function () {
            _this.fft = new FFT( SAMPLE_SIZE, SAMPLE_RATE );
            _this.signal = new Float32Array( SAMPLE_SIZE );
            _this.waveform = new Float32Array( SAMPLE_SIZE );
            _this.isLoaded = true;
            _this.progress = 1;
            _this.dancer.trigger( 'loaded' );
          }
        });
        this.dancer.audio = this.audio;
      }

      // Returns audio if SM already loaded -- otherwise,
      // sets dancer instance's audio property after load
      return this.audio;
    }
function ( source ) { var _this = this ; this . path = source ? source . src : this . path ; this . isLoaded = false ; this . progress = 0 ; ! window . soundManager && ! smLoading && loadSM . call ( this ) ; if ( window . soundManager ) { this . audio = soundManager . createSound ( { id : 'dancer' + Math . random ( ) + '' , url : this . path , stream : true , autoPlay : false , autoLoad : true , whileplaying : function ( ) { _this . update ( ) ; } , whileloading : function ( ) { _this . progress = this . bytesLoaded / this . bytesTotal ; } , onload : function ( ) { _this . fft = new FFT ( SAMPLE_SIZE , SAMPLE_RATE ) ; _this . signal = new Float32Array ( SAMPLE_SIZE ) ; _this . waveform = new Float32Array ( SAMPLE_SIZE ) ; _this . isLoaded = true ; _this . progress = 1 ; _this . dancer . trigger ( 'loaded' ) ; } } ) ; this . dancer . audio = this . audio ; } // Returns audio if SM already loaded -- otherwise, // sets dancer instance's audio property after load return this . audio ; }
`source` can be either an Audio element, if supported, or an object either way, the path is stored in the `src` property
source can be either an Audio element if supported or an object either way the path is stored in the src property