text: (function (global, factory) {
      typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('standardized-audio-context'), require('babel-runtime/regenerator'), require('tslib'), require('fast-unique-numbers')) :
      typeof define === 'function' && define.amd ? define(['exports', 'standardized-audio-context', 'babel-runtime/regenerator', 'tslib', 'fast-unique-numbers'], factory) :
      (factory((global.webAudioBeatDetectorBroker = {}),global.standardizedAudioContext,global._regeneratorRuntime,global.tslib_1,global.fastUniqueNumbers));
  }(this, (function (exports,standardizedAudioContext,_regeneratorRuntime,tslib_1,fastUniqueNumbers) { 'use strict';
  
      _regeneratorRuntime = _regeneratorRuntime && _regeneratorRuntime.hasOwnProperty('default') ? _regeneratorRuntime['default'] : _regeneratorRuntime;
  
      var render = function render(audioBuffer, offset, duration) {
          var offlineAudioContext = new standardizedAudioContext.OfflineAudioContext(audioBuffer.numberOfChannels, duration * audioBuffer.sampleRate, audioBuffer.sampleRate);
          var biquadFilter = offlineAudioContext.createBiquadFilter();
          var bufferSourceNode = offlineAudioContext.createBufferSource();
          biquadFilter.frequency.value = 240;
          biquadFilter.type = 'lowpass';
          bufferSourceNode.buffer = audioBuffer;
          bufferSourceNode.connect(biquadFilter).connect(offlineAudioContext.destination);
          bufferSourceNode.start(0, offset, duration);
          return offlineAudioContext.startRendering().then(function (renderedBuffer) {
              var channelData = renderedBuffer.getChannelData(0);
              var sampleRate = renderedBuffer.sampleRate;
              return { channelData: channelData, sampleRate: sampleRate };
          });
      };
  
      var _this = undefined;
      var load = function load(url) {
          var worker = new Worker(url);
          var ongoingRecordingRequests = new Set();
          var analyze = function analyze(audioBuffer) {
              var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
              var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : audioBuffer.duration - offset;
  
              return new Promise(function (resolve, reject) {
                  return tslib_1.__awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
                      var _ref, channelData, sampleRate, id, onMessage;
  
                      return _regeneratorRuntime.wrap(function _callee$(_context) {
                          while (1) {
                              switch (_context.prev = _context.next) {
                                  case 0:
                                      _context.next = 2;
                                      return render(audioBuffer, offset, duration);
  
                                  case 2:
                                      _ref = _context.sent;
                                      channelData = _ref.channelData;
                                      sampleRate = _ref.sampleRate;
                                      id = fastUniqueNumbers.addUniqueNumber(ongoingRecordingRequests);
  
                                      onMessage = function onMessage(_ref2) {
                                          var data = _ref2.data;
  
                                          if (data.id === id) {
                                              ongoingRecordingRequests.delete(id);
                                              worker.removeEventListener('message', onMessage);
                                              if (data.error === null) {
                                                  resolve(data.result.tempo);
                                              } else {
                                                  reject(new Error(data.error.message));
                                              }
                                          }
                                      };
  
                                      worker.addEventListener('message', onMessage);
                                      worker.postMessage({ id: id, method: 'analyze', params: { channelData: channelData, sampleRate: sampleRate } }, [channelData.buffer]);
  
                                  case 9:
                                  case 'end':
                                      return _context.stop();
                              }
                          }
                      }, _callee, this);
                  }));
              });
          };
          var guess = function guess(audioBuffer) {
              var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
              var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : audioBuffer.duration - offset;
  
              return new Promise(function (resolve, reject) {
                  return tslib_1.__awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
                      var _ref3, channelData, sampleRate, id, onMessage;
  
                      return _regeneratorRuntime.wrap(function _callee2$(_context2) {
                          while (1) {
                              switch (_context2.prev = _context2.next) {
                                  case 0:
                                      _context2.next = 2;
                                      return render(audioBuffer, offset, duration);
  
                                  case 2:
                                      _ref3 = _context2.sent;
                                      channelData = _ref3.channelData;
                                      sampleRate = _ref3.sampleRate;
                                      id = fastUniqueNumbers.addUniqueNumber(ongoingRecordingRequests);
  
                                      onMessage = function onMessage(_ref4) {
                                          var data = _ref4.data;
  
                                          if (data.id === id) {
                                              ongoingRecordingRequests.delete(id);
                                              worker.removeEventListener('message', onMessage);
                                              if (data.error === null) {
                                                  resolve(data.result);
                                              } else {
                                                  reject(new Error(data.error.message));
                                              }
                                          }
                                      };
  
                                      worker.addEventListener('message', onMessage);
                                      worker.postMessage({ id: id, method: 'guess', params: { channelData: channelData, sampleRate: sampleRate } }, [channelData.buffer]);
  
                                  case 9:
                                  case 'end':
                                      return _context2.stop();
                              }
                          }
                      }, _callee2, this);
                  }));
              });
          };
          return {
              analyze: analyze,
              guess: guess
          };
      };
  
      exports.isSupported = standardizedAudioContext.isSupported;
      exports.load = load;
  
      Object.defineProperty(exports, '__esModule', { value: true });
  
  })));
  