         micGain: 1.0,
         processorBufferSize: 2048,
         stopTracksAndCloseCtxWhenFinished: true,
-        userMediaConstraints:
+        userMediaConstraints: {
           audio: true
-      return
-
-    createWorker: (fn) ->
-      js = fn
-        .toString()
-        .replace(/^function\s*\(\)\s*{/, '')
-        .replace(/}$/, '')
-      blob = new Blob([js])
-      return new Worker(URL.createObjectURL(blob))
-
-    startRecording: (timeslice) ->
+        }
+      }
+      return
+
+    # Called once when the recording is initated
+    startRecording: () ->
       if (@state != 'inactive')
         return
 

        @audioCtx.close()
        @audioCtx = null

      @em.dispatchEvent(new CustomEvent('recording', {detail: {recording: recording}}))
      return

    _onError: (evt) ->
      console.log('error', evt)
      @em.dispatchEvent(new Event('error'))
      alert('error:' + evt) # for debugging purposes
      return
)

            @encoderWorker.postMessage(['encode', e.inputBuffer.getChannelData(0)])
      return

    # Called once when the recording has been stopped
    stopRecording: () ->
      if (@state == 'inactive')
        return
