             request.responseType = 'arraybuffer'
 
             #request event handlers
-            request.successCallback = (buffer) =>
-                @_buffer = buffer
-                if Greenhorn.isRunning() and @_config.autoplay
-                    @play()
+            request.successCallback = (@_buffer) =>
+                if Greenhorn.isRunning() and @_config.autoplay then @play()
             request.errorCallback = ->
-                throw new Error "AJAX request Error"
+                console.log "could not load sound file at url: #{@_config.url}"
             request.onload = ->
                 audioContext.decodeAudioData @response, @successCallback, @errorCallback
 

                snd.play()
            else
                snd.play volume: 0, loop: false
                setTimeout (-> snd.stop()), 50
        return
    @_pauseAll = ->
        snd.pause() for snd in _list

###

class Sound
    #closures
    _list = []
    _play = (opt) ->
        #create audio nodes
        gainNode = audioContext.createGain()
        @_source = audioContext.createBufferSource()

        #set values on source node
        @_source.buffer = @_buffer
        @_source.loop = opt.loop ? @_config.loop
        @_source.onended = =>
            @_isEnded = true
            @_elapsedTime += audioContext.currentTime - @_startTime
            if @_elapsedTime >= @_buffer.duration
                @_elapsedTime = 0

        #set value on gain node
        gainNode.gain.value = opt.volume ? @_config.volume

        #connect nodes
        @_source.connect gainNode
        gainNode.connect audioContext.destination

        #record start time
        @_startTime = audioContext.currentTime

        #start playing
        @_source.start @_startTime, @_elapsedTime

    #class level objects
    @config:
