wavesurfer.js 6.5.1 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +24 -0
- package/.prettierrc +8 -0
- package/README.md +26 -117
- package/dist/base-plugin.d.ts +10 -0
- package/dist/base-plugin.js +13 -0
- package/dist/decoder.d.ts +10 -0
- package/dist/decoder.js +43 -0
- package/dist/event-emitter.d.ts +11 -0
- package/dist/event-emitter.js +21 -0
- package/dist/fetcher.d.ts +4 -0
- package/dist/fetcher.js +17 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +166 -0
- package/dist/player-webaudio.d.ts +8 -0
- package/dist/player-webaudio.js +31 -0
- package/dist/player.d.ts +16 -0
- package/dist/player.js +40 -0
- package/dist/plugins/regions.d.ts +48 -0
- package/dist/plugins/regions.js +183 -0
- package/dist/renderer.d.ts +34 -0
- package/dist/renderer.js +193 -0
- package/dist/timer.d.ts +10 -0
- package/dist/timer.js +17 -0
- package/examples/audio.ogg +0 -0
- package/examples/bars.js +19 -0
- package/examples/basic.js +8 -0
- package/examples/gradient.js +28 -0
- package/examples/regions.js +63 -0
- package/examples/video.js +19 -0
- package/examples/webaudio.js +14 -0
- package/package.json +19 -99
- package/src/base-plugin.ts +20 -0
- package/src/decoder.ts +41 -0
- package/src/event-emitter.ts +35 -0
- package/src/fetcher.ts +7 -0
- package/src/index.ts +252 -0
- package/src/player-webaudio.ts +34 -0
- package/src/player.ts +50 -0
- package/src/plugins/regions.ts +240 -0
- package/src/renderer.ts +250 -0
- package/src/timer.ts +27 -0
- package/tsconfig.json +105 -0
- package/tutorial/index.html +47 -0
- package/tutorial/src/editor.js +70 -0
- package/tutorial/src/init.js +66 -0
- package/tutorial/src/url.js +25 -0
- package/tutorial/style.css +211 -0
- package/yarn-error.log +1049 -0
- package/LICENSE +0 -29
- package/dist/plugin/wavesurfer.cursor.js +0 -418
- package/dist/plugin/wavesurfer.cursor.js.map +0 -1
- package/dist/plugin/wavesurfer.cursor.min.js +0 -7
- package/dist/plugin/wavesurfer.cursor.min.js.map +0 -1
- package/dist/plugin/wavesurfer.elan.js +0 -381
- package/dist/plugin/wavesurfer.elan.js.map +0 -1
- package/dist/plugin/wavesurfer.elan.min.js +0 -7
- package/dist/plugin/wavesurfer.elan.min.js.map +0 -1
- package/dist/plugin/wavesurfer.markers.js +0 -520
- package/dist/plugin/wavesurfer.markers.js.map +0 -1
- package/dist/plugin/wavesurfer.markers.min.js +0 -7
- package/dist/plugin/wavesurfer.markers.min.js.map +0 -1
- package/dist/plugin/wavesurfer.mediasession.js +0 -181
- package/dist/plugin/wavesurfer.mediasession.js.map +0 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +0 -7
- package/dist/plugin/wavesurfer.mediasession.min.js.map +0 -1
- package/dist/plugin/wavesurfer.microphone.js +0 -466
- package/dist/plugin/wavesurfer.microphone.js.map +0 -1
- package/dist/plugin/wavesurfer.microphone.min.js +0 -7
- package/dist/plugin/wavesurfer.microphone.min.js.map +0 -1
- package/dist/plugin/wavesurfer.minimap.js +0 -440
- package/dist/plugin/wavesurfer.minimap.js.map +0 -1
- package/dist/plugin/wavesurfer.minimap.min.js +0 -7
- package/dist/plugin/wavesurfer.minimap.min.js.map +0 -1
- package/dist/plugin/wavesurfer.playhead.js +0 -300
- package/dist/plugin/wavesurfer.playhead.js.map +0 -1
- package/dist/plugin/wavesurfer.playhead.min.js +0 -7
- package/dist/plugin/wavesurfer.playhead.min.js.map +0 -1
- package/dist/plugin/wavesurfer.regions.js +0 -1335
- package/dist/plugin/wavesurfer.regions.js.map +0 -1
- package/dist/plugin/wavesurfer.regions.min.js +0 -7
- package/dist/plugin/wavesurfer.regions.min.js.map +0 -1
- package/dist/plugin/wavesurfer.spectrogram.js +0 -736
- package/dist/plugin/wavesurfer.spectrogram.js.map +0 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +0 -7
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +0 -1
- package/dist/plugin/wavesurfer.timeline.js +0 -649
- package/dist/plugin/wavesurfer.timeline.js.map +0 -1
- package/dist/plugin/wavesurfer.timeline.min.js +0 -7
- package/dist/plugin/wavesurfer.timeline.min.js.map +0 -1
- package/dist/wavesurfer-html-init.js +0 -381
- package/dist/wavesurfer-html-init.js.map +0 -1
- package/dist/wavesurfer-html-init.min.js +0 -7
- package/dist/wavesurfer-html-init.min.js.map +0 -1
- package/dist/wavesurfer.js +0 -6145
- package/dist/wavesurfer.js.map +0 -1
- package/dist/wavesurfer.min.js +0 -7
- package/dist/wavesurfer.min.js.map +0 -1
- package/src/drawer.canvasentry.js +0 -427
- package/src/drawer.js +0 -413
- package/src/drawer.multicanvas.js +0 -617
- package/src/html-init.js +0 -241
- package/src/mediaelement-webaudio.js +0 -77
- package/src/mediaelement.js +0 -443
- package/src/peakcache.js +0 -127
- package/src/plugin/cursor/index.js +0 -350
- package/src/plugin/elan/index.js +0 -307
- package/src/plugin/markers/index.js +0 -436
- package/src/plugin/mediasession/index.js +0 -94
- package/src/plugin/microphone/index.js +0 -415
- package/src/plugin/minimap/index.js +0 -403
- package/src/plugin/playhead/index.js +0 -226
- package/src/plugin/regions/index.js +0 -478
- package/src/plugin/regions/region.js +0 -875
- package/src/plugin/spectrogram/fft.js +0 -222
- package/src/plugin/spectrogram/index.js +0 -522
- package/src/plugin/timeline/index.js +0 -600
- package/src/util/absMax.js +0 -16
- package/src/util/clamp.js +0 -11
- package/src/util/fetch.js +0 -222
- package/src/util/frame.js +0 -13
- package/src/util/get-id.js +0 -22
- package/src/util/index.js +0 -14
- package/src/util/max.js +0 -16
- package/src/util/min.js +0 -16
- package/src/util/observer.js +0 -144
- package/src/util/orientation.js +0 -98
- package/src/util/prevent-click.js +0 -19
- package/src/util/request-animation-frame.js +0 -15
- package/src/util/silence-mode.js +0 -42
- package/src/util/style.js +0 -16
- package/src/wavesurfer.js +0 -1797
- package/src/webaudio.js +0 -779
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* wavesurfer.js microphone plugin 6.5.1 (2023-03-12)
|
|
3
|
-
* https://wavesurfer-js.org
|
|
4
|
-
* @license BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
7
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
8
|
-
module.exports = factory();
|
|
9
|
-
else if(typeof define === 'function' && define.amd)
|
|
10
|
-
define("WaveSurfer", [], factory);
|
|
11
|
-
else if(typeof exports === 'object')
|
|
12
|
-
exports["WaveSurfer"] = factory();
|
|
13
|
-
else
|
|
14
|
-
root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["microphone"] = factory();
|
|
15
|
-
})(self, () => {
|
|
16
|
-
return /******/ (() => { // webpackBootstrap
|
|
17
|
-
/******/ "use strict";
|
|
18
|
-
/******/ var __webpack_modules__ = ({
|
|
19
|
-
|
|
20
|
-
/***/ "./src/plugin/microphone/index.js":
|
|
21
|
-
/*!****************************************!*\
|
|
22
|
-
!*** ./src/plugin/microphone/index.js ***!
|
|
23
|
-
\****************************************/
|
|
24
|
-
/***/ ((module, exports) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
29
|
-
value: true
|
|
30
|
-
}));
|
|
31
|
-
exports["default"] = void 0;
|
|
32
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
33
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
35
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
36
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
37
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
38
|
-
/**
|
|
39
|
-
* @typedef {Object} MicrophonePluginParams
|
|
40
|
-
* @property {MediaStreamConstraints} constraints The constraints parameter is a
|
|
41
|
-
* MediaStreamConstaints object with two members: video and audio, describing
|
|
42
|
-
* the media types requested. Either or both must be specified.
|
|
43
|
-
* @property {number} bufferSize=4096 The buffer size in units of sample-frames.
|
|
44
|
-
* If specified, the bufferSize must be one of the following values: `256`,
|
|
45
|
-
* `512`, `1024`, `2048`, `4096`, `8192`, `16384`
|
|
46
|
-
* @property {number} numberOfInputChannels=1 Integer specifying the number of
|
|
47
|
-
* channels for this node's input. Values of up to 32 are supported.
|
|
48
|
-
* @property {number} numberOfOutputChannels=1 Integer specifying the number of
|
|
49
|
-
* channels for this node's output.
|
|
50
|
-
* @property {?boolean} deferInit Set to true to manually call
|
|
51
|
-
* `initPlugin('microphone')`
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* Visualize microphone input in a wavesurfer instance.
|
|
55
|
-
*
|
|
56
|
-
* @implements {PluginClass}
|
|
57
|
-
* @extends {Observer}
|
|
58
|
-
* @example
|
|
59
|
-
* // es6
|
|
60
|
-
* import MicrophonePlugin from 'wavesurfer.microphone.js';
|
|
61
|
-
*
|
|
62
|
-
* // commonjs
|
|
63
|
-
* var MicrophonePlugin = require('wavesurfer.microphone.js');
|
|
64
|
-
*
|
|
65
|
-
* // if you are using <script> tags
|
|
66
|
-
* var MicrophonePlugin = window.WaveSurfer.microphone;
|
|
67
|
-
*
|
|
68
|
-
* // ... initialising wavesurfer with the plugin
|
|
69
|
-
* var wavesurfer = WaveSurfer.create({
|
|
70
|
-
* // wavesurfer options ...
|
|
71
|
-
* plugins: [
|
|
72
|
-
* MicrophonePlugin.create({
|
|
73
|
-
* // plugin options ...
|
|
74
|
-
* })
|
|
75
|
-
* ]
|
|
76
|
-
* });
|
|
77
|
-
*/
|
|
78
|
-
var MicrophonePlugin = /*#__PURE__*/function () {
|
|
79
|
-
function MicrophonePlugin(params, ws) {
|
|
80
|
-
var _this = this;
|
|
81
|
-
_classCallCheck(this, MicrophonePlugin);
|
|
82
|
-
this.params = params;
|
|
83
|
-
this.wavesurfer = ws;
|
|
84
|
-
this.active = false;
|
|
85
|
-
this.paused = false;
|
|
86
|
-
this.browser = this.detectBrowser();
|
|
87
|
-
this.reloadBufferFunction = function (e) {
|
|
88
|
-
return _this.reloadBuffer(e);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// cross-browser getUserMedia
|
|
92
|
-
var promisifiedOldGUM = function promisifiedOldGUM(constraints, successCallback, errorCallback) {
|
|
93
|
-
// get a hold of getUserMedia, if present
|
|
94
|
-
var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
|
95
|
-
// Some browsers just don't implement it - return a rejected
|
|
96
|
-
// promise with an error to keep a consistent interface
|
|
97
|
-
if (!getUserMedia) {
|
|
98
|
-
return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
|
|
99
|
-
}
|
|
100
|
-
// otherwise, wrap the call to the old navigator.getUserMedia with
|
|
101
|
-
// a Promise
|
|
102
|
-
return new Promise(function (successCallback, errorCallback) {
|
|
103
|
-
getUserMedia.call(navigator, constraints, successCallback, errorCallback);
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
// Older browsers might not implement mediaDevices at all, so we set an
|
|
107
|
-
// empty object first
|
|
108
|
-
if (navigator.mediaDevices === undefined) {
|
|
109
|
-
navigator.mediaDevices = {};
|
|
110
|
-
}
|
|
111
|
-
// Some browsers partially implement mediaDevices. We can't just assign
|
|
112
|
-
// an object with getUserMedia as it would overwrite existing
|
|
113
|
-
// properties. Here, we will just add the getUserMedia property if it's
|
|
114
|
-
// missing.
|
|
115
|
-
if (navigator.mediaDevices.getUserMedia === undefined) {
|
|
116
|
-
navigator.mediaDevices.getUserMedia = promisifiedOldGUM;
|
|
117
|
-
}
|
|
118
|
-
this.constraints = this.params.constraints || {
|
|
119
|
-
video: false,
|
|
120
|
-
audio: true
|
|
121
|
-
};
|
|
122
|
-
this.bufferSize = this.params.bufferSize || 4096;
|
|
123
|
-
this.numberOfInputChannels = this.params.numberOfInputChannels || 1;
|
|
124
|
-
this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;
|
|
125
|
-
this._onBackendCreated = function () {
|
|
126
|
-
// wavesurfer's AudioContext where we'll route the mic signal to
|
|
127
|
-
_this.micContext = _this.wavesurfer.backend.getAudioContext();
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
_createClass(MicrophonePlugin, [{
|
|
131
|
-
key: "init",
|
|
132
|
-
value: function init() {
|
|
133
|
-
this.wavesurfer.on('backend-created', this._onBackendCreated);
|
|
134
|
-
if (this.wavesurfer.backend) {
|
|
135
|
-
this._onBackendCreated();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Destroy the microphone plugin.
|
|
141
|
-
*/
|
|
142
|
-
}, {
|
|
143
|
-
key: "destroy",
|
|
144
|
-
value: function destroy() {
|
|
145
|
-
// make sure the buffer is not redrawn during
|
|
146
|
-
// cleanup and demolition of this plugin.
|
|
147
|
-
this.paused = true;
|
|
148
|
-
this.wavesurfer.un('backend-created', this._onBackendCreated);
|
|
149
|
-
this.stop();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Allow user to select audio input device, e.g. microphone, and
|
|
154
|
-
* start the visualization.
|
|
155
|
-
*/
|
|
156
|
-
}, {
|
|
157
|
-
key: "start",
|
|
158
|
-
value: function start() {
|
|
159
|
-
var _this2 = this;
|
|
160
|
-
navigator.mediaDevices.getUserMedia(this.constraints).then(function (data) {
|
|
161
|
-
return _this2.gotStream(data);
|
|
162
|
-
}).catch(function (data) {
|
|
163
|
-
return _this2.deviceError(data);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Pause/resume visualization.
|
|
169
|
-
*/
|
|
170
|
-
}, {
|
|
171
|
-
key: "togglePlay",
|
|
172
|
-
value: function togglePlay() {
|
|
173
|
-
if (!this.active) {
|
|
174
|
-
// start it first
|
|
175
|
-
this.start();
|
|
176
|
-
} else {
|
|
177
|
-
// toggle paused
|
|
178
|
-
this.paused = !this.paused;
|
|
179
|
-
if (this.paused) {
|
|
180
|
-
this.pause();
|
|
181
|
-
} else {
|
|
182
|
-
this.play();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Play visualization.
|
|
189
|
-
*/
|
|
190
|
-
}, {
|
|
191
|
-
key: "play",
|
|
192
|
-
value: function play() {
|
|
193
|
-
this.paused = false;
|
|
194
|
-
this.connect();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Pause visualization.
|
|
199
|
-
*/
|
|
200
|
-
}, {
|
|
201
|
-
key: "pause",
|
|
202
|
-
value: function pause() {
|
|
203
|
-
this.paused = true;
|
|
204
|
-
|
|
205
|
-
// disconnect sources so they can be used elsewhere
|
|
206
|
-
// (eg. during audio playback)
|
|
207
|
-
this.disconnect();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Stop the device stream and remove any remaining waveform drawing from
|
|
212
|
-
* the wavesurfer canvas.
|
|
213
|
-
*/
|
|
214
|
-
}, {
|
|
215
|
-
key: "stop",
|
|
216
|
-
value: function stop() {
|
|
217
|
-
if (this.active) {
|
|
218
|
-
// stop visualization and device
|
|
219
|
-
this.stopDevice();
|
|
220
|
-
|
|
221
|
-
// empty last frame
|
|
222
|
-
this.wavesurfer.empty();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Stop the device and the visualization.
|
|
228
|
-
*/
|
|
229
|
-
}, {
|
|
230
|
-
key: "stopDevice",
|
|
231
|
-
value: function stopDevice() {
|
|
232
|
-
this.active = false;
|
|
233
|
-
|
|
234
|
-
// stop visualization
|
|
235
|
-
this.disconnect();
|
|
236
|
-
|
|
237
|
-
// stop stream from device
|
|
238
|
-
if (this.stream && this.stream.getTracks) {
|
|
239
|
-
this.stream.getTracks().forEach(function (stream) {
|
|
240
|
-
return stream.stop();
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Connect the media sources that feed the visualization.
|
|
247
|
-
*/
|
|
248
|
-
}, {
|
|
249
|
-
key: "connect",
|
|
250
|
-
value: function connect() {
|
|
251
|
-
if (this.stream !== undefined) {
|
|
252
|
-
// Create a local buffer for data to be copied to the Wavesurfer buffer for Edge
|
|
253
|
-
if (this.browser.browser === 'edge') {
|
|
254
|
-
this.localAudioBuffer = this.micContext.createBuffer(this.numberOfInputChannels, this.bufferSize, this.micContext.sampleRate);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Create an AudioNode from the stream.
|
|
258
|
-
this.mediaStreamSource = this.micContext.createMediaStreamSource(this.stream);
|
|
259
|
-
this.levelChecker = this.micContext.createScriptProcessor(this.bufferSize, this.numberOfInputChannels, this.numberOfOutputChannels);
|
|
260
|
-
this.mediaStreamSource.connect(this.levelChecker);
|
|
261
|
-
this.levelChecker.connect(this.micContext.destination);
|
|
262
|
-
this.levelChecker.onaudioprocess = this.reloadBufferFunction;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Disconnect the media sources that feed the visualization.
|
|
268
|
-
*/
|
|
269
|
-
}, {
|
|
270
|
-
key: "disconnect",
|
|
271
|
-
value: function disconnect() {
|
|
272
|
-
if (this.mediaStreamSource !== undefined) {
|
|
273
|
-
this.mediaStreamSource.disconnect();
|
|
274
|
-
}
|
|
275
|
-
if (this.levelChecker !== undefined) {
|
|
276
|
-
this.levelChecker.disconnect();
|
|
277
|
-
this.levelChecker.onaudioprocess = undefined;
|
|
278
|
-
}
|
|
279
|
-
if (this.localAudioBuffer !== undefined) {
|
|
280
|
-
this.localAudioBuffer = undefined;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Redraw the waveform.
|
|
286
|
-
*
|
|
287
|
-
* @param {object} event Audioprocess event
|
|
288
|
-
*/
|
|
289
|
-
}, {
|
|
290
|
-
key: "reloadBuffer",
|
|
291
|
-
value: function reloadBuffer(event) {
|
|
292
|
-
if (!this.paused) {
|
|
293
|
-
this.wavesurfer.empty();
|
|
294
|
-
if (this.browser.browser === 'edge') {
|
|
295
|
-
// copy audio data to a local audio buffer,
|
|
296
|
-
// from https://github.com/audiojs/audio-buffer-utils
|
|
297
|
-
var channel, l;
|
|
298
|
-
for (channel = 0, l = Math.min(this.localAudioBuffer.numberOfChannels, event.inputBuffer.numberOfChannels); channel < l; channel++) {
|
|
299
|
-
this.localAudioBuffer.getChannelData(channel).set(event.inputBuffer.getChannelData(channel));
|
|
300
|
-
}
|
|
301
|
-
this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);
|
|
302
|
-
} else {
|
|
303
|
-
this.wavesurfer.loadDecodedBuffer(event.inputBuffer);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Audio input device is ready.
|
|
310
|
-
*
|
|
311
|
-
* @param {MediaStream} stream The microphone's media stream.
|
|
312
|
-
*/
|
|
313
|
-
}, {
|
|
314
|
-
key: "gotStream",
|
|
315
|
-
value: function gotStream(stream) {
|
|
316
|
-
this.stream = stream;
|
|
317
|
-
this.active = true;
|
|
318
|
-
|
|
319
|
-
// start visualization
|
|
320
|
-
this.play();
|
|
321
|
-
|
|
322
|
-
// notify listeners
|
|
323
|
-
this.fireEvent('deviceReady', stream);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Device error callback.
|
|
328
|
-
*
|
|
329
|
-
* @param {string} code Error message
|
|
330
|
-
*/
|
|
331
|
-
}, {
|
|
332
|
-
key: "deviceError",
|
|
333
|
-
value: function deviceError(code) {
|
|
334
|
-
// notify listeners
|
|
335
|
-
this.fireEvent('deviceError', code);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Extract browser version out of the provided user agent string.
|
|
340
|
-
* @param {!string} uastring userAgent string.
|
|
341
|
-
* @param {!string} expr Regular expression used as match criteria.
|
|
342
|
-
* @param {!number} pos position in the version string to be returned.
|
|
343
|
-
* @return {!number} browser version.
|
|
344
|
-
*/
|
|
345
|
-
}, {
|
|
346
|
-
key: "extractVersion",
|
|
347
|
-
value: function extractVersion(uastring, expr, pos) {
|
|
348
|
-
var match = uastring.match(expr);
|
|
349
|
-
return match && match.length >= pos && parseInt(match[pos], 10);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Browser detector.
|
|
354
|
-
* @return {object} result containing browser, version and minVersion
|
|
355
|
-
* properties.
|
|
356
|
-
*/
|
|
357
|
-
}, {
|
|
358
|
-
key: "detectBrowser",
|
|
359
|
-
value: function detectBrowser() {
|
|
360
|
-
// Returned result object.
|
|
361
|
-
var result = {};
|
|
362
|
-
result.browser = null;
|
|
363
|
-
result.version = null;
|
|
364
|
-
result.minVersion = null;
|
|
365
|
-
|
|
366
|
-
// Non supported browser.
|
|
367
|
-
if (typeof window === 'undefined' || !window.navigator) {
|
|
368
|
-
result.browser = 'Not a supported browser.';
|
|
369
|
-
return result;
|
|
370
|
-
}
|
|
371
|
-
if (navigator.mozGetUserMedia) {
|
|
372
|
-
// Firefox
|
|
373
|
-
result.browser = 'firefox';
|
|
374
|
-
result.version = this.extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1);
|
|
375
|
-
result.minVersion = 31;
|
|
376
|
-
return result;
|
|
377
|
-
} else if (navigator.webkitGetUserMedia) {
|
|
378
|
-
// Chrome/Chromium/Webview/Opera
|
|
379
|
-
result.browser = 'chrome';
|
|
380
|
-
result.version = this.extractVersion(navigator.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
|
|
381
|
-
result.minVersion = 38;
|
|
382
|
-
return result;
|
|
383
|
-
} else if (navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) {
|
|
384
|
-
// Edge
|
|
385
|
-
result.browser = 'edge';
|
|
386
|
-
result.version = this.extractVersion(navigator.userAgent, /Edge\/(\d+).(\d+)$/, 2);
|
|
387
|
-
result.minVersion = 10547;
|
|
388
|
-
return result;
|
|
389
|
-
} else if (window.RTCPeerConnection && navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) {
|
|
390
|
-
// Safari
|
|
391
|
-
result.browser = 'safari';
|
|
392
|
-
result.minVersion = 11;
|
|
393
|
-
result.version = this.extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1);
|
|
394
|
-
return result;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// Non supported browser default.
|
|
398
|
-
result.browser = 'Not a supported browser.';
|
|
399
|
-
return result;
|
|
400
|
-
}
|
|
401
|
-
}], [{
|
|
402
|
-
key: "create",
|
|
403
|
-
value:
|
|
404
|
-
/**
|
|
405
|
-
* Microphone plugin definition factory
|
|
406
|
-
*
|
|
407
|
-
* This function must be used to create a plugin definition which can be
|
|
408
|
-
* used by wavesurfer to correctly instantiate the plugin.
|
|
409
|
-
*
|
|
410
|
-
* @param {MicrophonePluginParams} params parameters use to initialise the plugin
|
|
411
|
-
* @return {PluginDefinition} an object representing the plugin
|
|
412
|
-
*/
|
|
413
|
-
function create(params) {
|
|
414
|
-
return {
|
|
415
|
-
name: 'microphone',
|
|
416
|
-
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
417
|
-
params: params,
|
|
418
|
-
instance: MicrophonePlugin
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
}]);
|
|
422
|
-
return MicrophonePlugin;
|
|
423
|
-
}();
|
|
424
|
-
exports["default"] = MicrophonePlugin;
|
|
425
|
-
module.exports = exports.default;
|
|
426
|
-
|
|
427
|
-
/***/ })
|
|
428
|
-
|
|
429
|
-
/******/ });
|
|
430
|
-
/************************************************************************/
|
|
431
|
-
/******/ // The module cache
|
|
432
|
-
/******/ var __webpack_module_cache__ = {};
|
|
433
|
-
/******/
|
|
434
|
-
/******/ // The require function
|
|
435
|
-
/******/ function __webpack_require__(moduleId) {
|
|
436
|
-
/******/ // Check if module is in cache
|
|
437
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
438
|
-
/******/ if (cachedModule !== undefined) {
|
|
439
|
-
/******/ return cachedModule.exports;
|
|
440
|
-
/******/ }
|
|
441
|
-
/******/ // Create a new module (and put it into the cache)
|
|
442
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
443
|
-
/******/ // no module.id needed
|
|
444
|
-
/******/ // no module.loaded needed
|
|
445
|
-
/******/ exports: {}
|
|
446
|
-
/******/ };
|
|
447
|
-
/******/
|
|
448
|
-
/******/ // Execute the module function
|
|
449
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
450
|
-
/******/
|
|
451
|
-
/******/ // Return the exports of the module
|
|
452
|
-
/******/ return module.exports;
|
|
453
|
-
/******/ }
|
|
454
|
-
/******/
|
|
455
|
-
/************************************************************************/
|
|
456
|
-
/******/
|
|
457
|
-
/******/ // startup
|
|
458
|
-
/******/ // Load entry module and return exports
|
|
459
|
-
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
460
|
-
/******/ var __webpack_exports__ = __webpack_require__("./src/plugin/microphone/index.js");
|
|
461
|
-
/******/
|
|
462
|
-
/******/ return __webpack_exports__;
|
|
463
|
-
/******/ })()
|
|
464
|
-
;
|
|
465
|
-
});
|
|
466
|
-
//# sourceMappingURL=wavesurfer.microphone.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.microphone.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBA,IAyBqBA,gBAAgB;EAmBjC,SAAAA,iBAAYC,MAAM,EAAEC,EAAE,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,gBAAA;IACpB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACI,UAAU,GAAGH,EAAE;IAEpB,IAAI,CAACI,MAAM,GAAG,KAAK;IACnB,IAAI,CAACC,MAAM,GAAG,KAAK;IACnB,IAAI,CAACC,OAAO,GAAG,IAAI,CAACC,aAAa,EAAE;IACnC,IAAI,CAACC,oBAAoB,GAAG,UAAAC,CAAC;MAAA,OAAIR,KAAI,CAACS,YAAY,CAACD,CAAC,CAAC;IAAA;;IAErD;IACA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CACnBC,WAAW,EACXC,eAAe,EACfC,aA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AAM,CAACE,UAAU,GAAG,KAAK;QACzB,OAAOF,MAAM;MACjB,CAAC,MAAM,IACHG,MAAM,CAACE,iBAAiB,IACxB7E,SAAS,CAAC4E,SAAS,CAACP,KAAK,CAAC,sBAAsB,CAAC,EACnD;QACE;QACAG,MAAM,CAAClF,OAAO,GAAG,QAAQ;QACzBkF,MAAM,CAACE,UAAU,GAAG,EAAE;QACtBF,MAAM,CAACC,OAAO,GAAG,IAAI,CAACR,cAAc,CAChCjE,SAAS,CAAC4E,SAAS,EACnB,sBAAsB,EACtB,CAAC,CACJ;QACD,OAAOJ,MAAM;MACjB;;MAEA;MACAA,MAAM,CAAClF,OAAO,GAAG,0BAA0B;MAC3C,OAAOkF,MAAM;IACjB;EAAC;IAAApD,GAAA;IAAAC,KAAA;IAnXD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,SAAAyD,OAAc/F,MAAM,EAAE;MAClB,OAAO;QACHgG,IAAI,EAAE,YAAY;QAClBC,SAAS,EAAEjG,MAAM,IAAIA,MAAM,CAACiG,SAAS,GAAGjG,MAAM,CAACiG,SAAS,GAAG,KAAK;QAChEjG,MAAM,EAAEA,MAAM;QACdkG,QAAQ,EAAEnG;MACd,CAAC;IACL;EAAC;EAAA,OAAAA,gBAAA;AAAA;AAAAoG,kBAAA,GAAApG,gBAAA;AAAAsG,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA;;;;;;UC1DL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/microphone/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"microphone\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} MicrophonePluginParams\n * @property {MediaStreamConstraints} constraints The constraints parameter is a\n * MediaStreamConstaints object with two members: video and audio, describing\n * the media types requested. Either or both must be specified.\n * @property {number} bufferSize=4096 The buffer size in units of sample-frames.\n * If specified, the bufferSize must be one of the following values: `256`,\n * `512`, `1024`, `2048`, `4096`, `8192`, `16384`\n * @property {number} numberOfInputChannels=1 Integer specifying the number of\n * channels for this node's input. Values of up to 32 are supported.\n * @property {number} numberOfOutputChannels=1 Integer specifying the number of\n * channels for this node's output.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('microphone')`\n */\n\n/**\n * Visualize microphone input in a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MicrophonePlugin from 'wavesurfer.microphone.js';\n *\n * // commonjs\n * var MicrophonePlugin = require('wavesurfer.microphone.js');\n *\n * // if you are using <script> tags\n * var MicrophonePlugin = window.WaveSurfer.microphone;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MicrophonePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MicrophonePlugin {\n /**\n * Microphone plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MicrophonePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'microphone',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MicrophonePlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n this.active = false;\n this.paused = false;\n this.browser = this.detectBrowser();\n this.reloadBufferFunction = e => this.reloadBuffer(e);\n\n // cross-browser getUserMedia\n const promisifiedOldGUM = (\n constraints,\n successCallback,\n errorCallback\n ) => {\n // get a hold of getUserMedia, if present\n const getUserMedia =\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n // Some browsers just don't implement it - return a rejected\n // promise with an error to keep a consistent interface\n if (!getUserMedia) {\n return Promise.reject(\n new Error('getUserMedia is not implemented in this browser')\n );\n }\n // otherwise, wrap the call to the old navigator.getUserMedia with\n // a Promise\n return new Promise((successCallback, errorCallback) => {\n getUserMedia.call(\n navigator,\n constraints,\n successCallback,\n errorCallback\n );\n });\n };\n // Older browsers might not implement mediaDevices at all, so we set an\n // empty object first\n if (navigator.mediaDevices === undefined) {\n navigator.mediaDevices = {};\n }\n // Some browsers partially implement mediaDevices. We can't just assign\n // an object with getUserMedia as it would overwrite existing\n // properties. Here, we will just add the getUserMedia property if it's\n // missing.\n if (navigator.mediaDevices.getUserMedia === undefined) {\n navigator.mediaDevices.getUserMedia = promisifiedOldGUM;\n }\n this.constraints = this.params.constraints || {\n video: false,\n audio: true\n };\n this.bufferSize = this.params.bufferSize || 4096;\n this.numberOfInputChannels = this.params.numberOfInputChannels || 1;\n this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;\n\n this._onBackendCreated = () => {\n // wavesurfer's AudioContext where we'll route the mic signal to\n this.micContext = this.wavesurfer.backend.getAudioContext();\n };\n }\n\n init() {\n this.wavesurfer.on('backend-created', this._onBackendCreated);\n if (this.wavesurfer.backend) {\n this._onBackendCreated();\n }\n }\n\n /**\n * Destroy the microphone plugin.\n */\n destroy() {\n // make sure the buffer is not redrawn during\n // cleanup and demolition of this plugin.\n this.paused = true;\n\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.stop();\n }\n\n /**\n * Allow user to select audio input device, e.g. microphone, and\n * start the visualization.\n */\n start() {\n navigator.mediaDevices\n .getUserMedia(this.constraints)\n .then(data => this.gotStream(data))\n .catch(data => this.deviceError(data));\n }\n\n /**\n * Pause/resume visualization.\n */\n togglePlay() {\n if (!this.active) {\n // start it first\n this.start();\n } else {\n // toggle paused\n this.paused = !this.paused;\n\n if (this.paused) {\n this.pause();\n } else {\n this.play();\n }\n }\n }\n\n /**\n * Play visualization.\n */\n play() {\n this.paused = false;\n\n this.connect();\n }\n\n /**\n * Pause visualization.\n */\n pause() {\n this.paused = true;\n\n // disconnect sources so they can be used elsewhere\n // (eg. during audio playback)\n this.disconnect();\n }\n\n /**\n * Stop the device stream and remove any remaining waveform drawing from\n * the wavesurfer canvas.\n */\n stop() {\n if (this.active) {\n // stop visualization and device\n this.stopDevice();\n\n // empty last frame\n this.wavesurfer.empty();\n }\n }\n\n /**\n * Stop the device and the visualization.\n */\n stopDevice() {\n this.active = false;\n\n // stop visualization\n this.disconnect();\n\n // stop stream from device\n if (this.stream && this.stream.getTracks) {\n this.stream.getTracks().forEach(stream => stream.stop());\n }\n }\n\n /**\n * Connect the media sources that feed the visualization.\n */\n connect() {\n if (this.stream !== undefined) {\n // Create a local buffer for data to be copied to the Wavesurfer buffer for Edge\n if (this.browser.browser === 'edge') {\n this.localAudioBuffer = this.micContext.createBuffer(\n this.numberOfInputChannels,\n this.bufferSize,\n this.micContext.sampleRate\n );\n }\n\n // Create an AudioNode from the stream.\n this.mediaStreamSource = this.micContext.createMediaStreamSource(\n this.stream\n );\n\n this.levelChecker = this.micContext.createScriptProcessor(\n this.bufferSize,\n this.numberOfInputChannels,\n this.numberOfOutputChannels\n );\n this.mediaStreamSource.connect(this.levelChecker);\n\n this.levelChecker.connect(this.micContext.destination);\n this.levelChecker.onaudioprocess = this.reloadBufferFunction;\n }\n }\n\n /**\n * Disconnect the media sources that feed the visualization.\n */\n disconnect() {\n if (this.mediaStreamSource !== undefined) {\n this.mediaStreamSource.disconnect();\n }\n\n if (this.levelChecker !== undefined) {\n this.levelChecker.disconnect();\n this.levelChecker.onaudioprocess = undefined;\n }\n\n if (this.localAudioBuffer !== undefined) {\n this.localAudioBuffer = undefined;\n }\n }\n\n /**\n * Redraw the waveform.\n *\n * @param {object} event Audioprocess event\n */\n reloadBuffer(event) {\n if (!this.paused) {\n this.wavesurfer.empty();\n\n if (this.browser.browser === 'edge') {\n // copy audio data to a local audio buffer,\n // from https://github.com/audiojs/audio-buffer-utils\n let channel, l;\n for (\n channel = 0,\n l = Math.min(\n this.localAudioBuffer.numberOfChannels,\n event.inputBuffer.numberOfChannels\n );\n channel < l;\n channel++\n ) {\n this.localAudioBuffer\n .getChannelData(channel)\n .set(event.inputBuffer.getChannelData(channel));\n }\n\n this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);\n } else {\n this.wavesurfer.loadDecodedBuffer(event.inputBuffer);\n }\n }\n }\n\n /**\n * Audio input device is ready.\n *\n * @param {MediaStream} stream The microphone's media stream.\n */\n gotStream(stream) {\n this.stream = stream;\n this.active = true;\n\n // start visualization\n this.play();\n\n // notify listeners\n this.fireEvent('deviceReady', stream);\n }\n\n /**\n * Device error callback.\n *\n * @param {string} code Error message\n */\n deviceError(code) {\n // notify listeners\n this.fireEvent('deviceError', code);\n }\n\n /**\n * Extract browser version out of the provided user agent string.\n * @param {!string} uastring userAgent string.\n * @param {!string} expr Regular expression used as match criteria.\n * @param {!number} pos position in the version string to be returned.\n * @return {!number} browser version.\n */\n extractVersion(uastring, expr, pos) {\n const match = uastring.match(expr);\n return match && match.length >= pos && parseInt(match[pos], 10);\n }\n\n /**\n * Browser detector.\n * @return {object} result containing browser, version and minVersion\n * properties.\n */\n detectBrowser() {\n // Returned result object.\n const result = {};\n result.browser = null;\n result.version = null;\n result.minVersion = null;\n\n // Non supported browser.\n if (typeof window === 'undefined' || !window.navigator) {\n result.browser = 'Not a supported browser.';\n return result;\n }\n\n if (navigator.mozGetUserMedia) {\n // Firefox\n result.browser = 'firefox';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Firefox\\/(\\d+)\\./,\n 1\n );\n result.minVersion = 31;\n return result;\n } else if (navigator.webkitGetUserMedia) {\n // Chrome/Chromium/Webview/Opera\n result.browser = 'chrome';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Chrom(e|ium)\\/(\\d+)\\./,\n 2\n );\n result.minVersion = 38;\n return result;\n } else if (\n navigator.mediaDevices &&\n navigator.userAgent.match(/Edge\\/(\\d+).(\\d+)$/)\n ) {\n // Edge\n result.browser = 'edge';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Edge\\/(\\d+).(\\d+)$/,\n 2\n );\n result.minVersion = 10547;\n return result;\n } else if (\n window.RTCPeerConnection &&\n navigator.userAgent.match(/AppleWebKit\\/(\\d+)\\./)\n ) {\n // Safari\n result.browser = 'safari';\n result.minVersion = 11;\n result.version = this.extractVersion(\n navigator.userAgent,\n /AppleWebKit\\/(\\d+)\\./,\n 1\n );\n return result;\n }\n\n // Non supported browser default.\n result.browser = 'Not a supported browser.';\n return result;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/microphone/index.js\");\n",""],"names":["MicrophonePlugin","params","ws","_this","_classCallCheck","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","promisifiedOldGUM","constraints","successCallback","errorCallback","getUserMedia","navigator","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","reject","Error","call","mediaDevices","undefined","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","_createClass","key","value","init","on","destroy","un","stop","start","_this2","then","data","gotStream","catch","deviceError","togglePlay","pause","play","connect","disconnect","stopDevice","empty","stream","getTracks","forEach","localAudioBuffer","createBuffer","sampleRate","mediaStreamSource","createMediaStreamSource","levelChecker","createScriptProcessor","destination","onaudioprocess","event","channel","l","Math","min","numberOfChannels","inputBuffer","getChannelData","set","loadDecodedBuffer","fireEvent","code","extractVersion","uastring","expr","pos","match","length","parseInt","result","version","minVersion","window","userAgent","RTCPeerConnection","create","name","deferInit","instance","exports","default","module"],"sourceRoot":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* wavesurfer.js microphone plugin 6.5.1 (2023-03-12)
|
|
3
|
-
* https://wavesurfer-js.org
|
|
4
|
-
* @license BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.microphone=t())}(self,(()=>(()=>{"use strict";var e={872:(e,t)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(o=n.key,a=void 0,a=function(e,t){if("object"!==r(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===r(a)?a:String(a)),n)}var o,a}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.active=!1,this.paused=!1,this.browser=this.detectBrowser(),this.reloadBufferFunction=function(e){return i.reloadBuffer(e)};void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(e,t,r){var i=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return i?new Promise((function(t,r){i.call(navigator,e,t,r)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),this.constraints=this.params.constraints||{video:!1,audio:!0},this.bufferSize=this.params.bufferSize||4096,this.numberOfInputChannels=this.params.numberOfInputChannels||1,this.numberOfOutputChannels=this.params.numberOfOutputChannels||1,this._onBackendCreated=function(){i.micContext=i.wavesurfer.backend.getAudioContext()}}var t,r,n;return t=e,n=[{key:"create",value:function(t){return{name:"microphone",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"init",value:function(){this.wavesurfer.on("backend-created",this._onBackendCreated),this.wavesurfer.backend&&this._onBackendCreated()}},{key:"destroy",value:function(){this.paused=!0,this.wavesurfer.un("backend-created",this._onBackendCreated),this.stop()}},{key:"start",value:function(){var e=this;navigator.mediaDevices.getUserMedia(this.constraints).then((function(t){return e.gotStream(t)})).catch((function(t){return e.deviceError(t)}))}},{key:"togglePlay",value:function(){this.active?(this.paused=!this.paused,this.paused?this.pause():this.play()):this.start()}},{key:"play",value:function(){this.paused=!1,this.connect()}},{key:"pause",value:function(){this.paused=!0,this.disconnect()}},{key:"stop",value:function(){this.active&&(this.stopDevice(),this.wavesurfer.empty())}},{key:"stopDevice",value:function(){this.active=!1,this.disconnect(),this.stream&&this.stream.getTracks&&this.stream.getTracks().forEach((function(e){return e.stop()}))}},{key:"connect",value:function(){void 0!==this.stream&&("edge"===this.browser.browser&&(this.localAudioBuffer=this.micContext.createBuffer(this.numberOfInputChannels,this.bufferSize,this.micContext.sampleRate)),this.mediaStreamSource=this.micContext.createMediaStreamSource(this.stream),this.levelChecker=this.micContext.createScriptProcessor(this.bufferSize,this.numberOfInputChannels,this.numberOfOutputChannels),this.mediaStreamSource.connect(this.levelChecker),this.levelChecker.connect(this.micContext.destination),this.levelChecker.onaudioprocess=this.reloadBufferFunction)}},{key:"disconnect",value:function(){void 0!==this.mediaStreamSource&&this.mediaStreamSource.disconnect(),void 0!==this.levelChecker&&(this.levelChecker.disconnect(),this.levelChecker.onaudioprocess=void 0),void 0!==this.localAudioBuffer&&(this.localAudioBuffer=void 0)}},{key:"reloadBuffer",value:function(e){if(!this.paused)if(this.wavesurfer.empty(),"edge"===this.browser.browser){var t,r;for(t=0,r=Math.min(this.localAudioBuffer.numberOfChannels,e.inputBuffer.numberOfChannels);t<r;t++)this.localAudioBuffer.getChannelData(t).set(e.inputBuffer.getChannelData(t));this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer)}else this.wavesurfer.loadDecodedBuffer(e.inputBuffer)}},{key:"gotStream",value:function(e){this.stream=e,this.active=!0,this.play(),this.fireEvent("deviceReady",e)}},{key:"deviceError",value:function(e){this.fireEvent("deviceError",e)}},{key:"extractVersion",value:function(e,t,r){var i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}},{key:"detectBrowser",value:function(){var e={browser:null,version:null,minVersion:null};return"undefined"!=typeof window&&window.navigator?navigator.mozGetUserMedia?(e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/(\d+)\./,1),e.minVersion=31,e):navigator.webkitGetUserMedia?(e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/(\d+)\./,2),e.minVersion=38,e):navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?(e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),e.minVersion=10547,e):window.RTCPeerConnection&&navigator.userAgent.match(/AppleWebKit\/(\d+)\./)?(e.browser="safari",e.minVersion=11,e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1),e):(e.browser="Not a supported browser.",e):(e.browser="Not a supported browser.",e)}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n,e.exports=t.default}},t={};var r=function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,r),o.exports}(872);return r})()));
|
|
7
|
-
//# sourceMappingURL=wavesurfer.microphone.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.microphone.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EAAGA,EAAiB,WAAc,WAAIC,IACnF,CATD,CASGK,MAAM,IACT,M,+yBCMA,IAyBqBC,EAAgB,WAmBjC,SAAAA,EAAYC,EAAQC,GAAI,IAAAC,EAAA,M,4FAAAC,CAAA,KAAAJ,GACpBK,KAAKJ,OAASA,EACdI,KAAKC,WAAaJ,EAElBG,KAAKE,QAAS,EACdF,KAAKG,QAAS,EACdH,KAAKI,QAAUJ,KAAKK,gBACpBL,KAAKM,qBAAuB,SAAAC,GAAC,OAAIT,EAAKU,aAAaD,EAAE,OAkCtBE,IAA3BC,UAAUC,eACVD,UAAUC,aAAe,CAAC,QAMcF,IAAxCC,UAAUC,aAAaC,eACvBF,UAAUC,aAAaC,aAvCD,SACtBC,EACAC,EACAC,GAGA,IAAM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E,QAAU,OACjB+E,EAAOE,QAAUrF,KAAKsF,eAClB5E,UAAU6E,UACV,qBACA,GAEJJ,EAAOK,WAAa,MACbL,GAEPC,OAAOK,mBACP/E,UAAU6E,UAAUP,MAAM,yBAG1BG,EAAO/E,QAAU,SACjB+E,EAAOK,WAAa,GACpBL,EAAOE,QAAUrF,KAAKsF,eAClB5E,UAAU6E,UACV,uBACA,GAEGJ,IAIXA,EAAO/E,QAAU,2BACV+E,IAtDHA,EAAO/E,QAAU,2BACV+E,EAsDf,M,8EAnWCxF,CAAA,CAjBgC,GAiBhCL,EAAAA,QAAAK,EAAAJ,EAAAD,QAAAA,EAAAoG,O,GCzDDC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBrF,IAAjBsF,EACH,OAAOA,EAAazG,QAGrB,IAAIC,EAASoG,EAAyBG,GAAY,CAGjDxG,QAAS,CAAC,GAOX,OAHA0G,EAAoBF,GAAUvG,EAAQA,EAAOD,QAASuG,GAG/CtG,EAAOD,OACf,CCnB0BuG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/microphone/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"microphone\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} MicrophonePluginParams\n * @property {MediaStreamConstraints} constraints The constraints parameter is a\n * MediaStreamConstaints object with two members: video and audio, describing\n * the media types requested. Either or both must be specified.\n * @property {number} bufferSize=4096 The buffer size in units of sample-frames.\n * If specified, the bufferSize must be one of the following values: `256`,\n * `512`, `1024`, `2048`, `4096`, `8192`, `16384`\n * @property {number} numberOfInputChannels=1 Integer specifying the number of\n * channels for this node's input. Values of up to 32 are supported.\n * @property {number} numberOfOutputChannels=1 Integer specifying the number of\n * channels for this node's output.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('microphone')`\n */\n\n/**\n * Visualize microphone input in a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MicrophonePlugin from 'wavesurfer.microphone.js';\n *\n * // commonjs\n * var MicrophonePlugin = require('wavesurfer.microphone.js');\n *\n * // if you are using <script> tags\n * var MicrophonePlugin = window.WaveSurfer.microphone;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MicrophonePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MicrophonePlugin {\n /**\n * Microphone plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MicrophonePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'microphone',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MicrophonePlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n this.active = false;\n this.paused = false;\n this.browser = this.detectBrowser();\n this.reloadBufferFunction = e => this.reloadBuffer(e);\n\n // cross-browser getUserMedia\n const promisifiedOldGUM = (\n constraints,\n successCallback,\n errorCallback\n ) => {\n // get a hold of getUserMedia, if present\n const getUserMedia =\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n // Some browsers just don't implement it - return a rejected\n // promise with an error to keep a consistent interface\n if (!getUserMedia) {\n return Promise.reject(\n new Error('getUserMedia is not implemented in this browser')\n );\n }\n // otherwise, wrap the call to the old navigator.getUserMedia with\n // a Promise\n return new Promise((successCallback, errorCallback) => {\n getUserMedia.call(\n navigator,\n constraints,\n successCallback,\n errorCallback\n );\n });\n };\n // Older browsers might not implement mediaDevices at all, so we set an\n // empty object first\n if (navigator.mediaDevices === undefined) {\n navigator.mediaDevices = {};\n }\n // Some browsers partially implement mediaDevices. We can't just assign\n // an object with getUserMedia as it would overwrite existing\n // properties. Here, we will just add the getUserMedia property if it's\n // missing.\n if (navigator.mediaDevices.getUserMedia === undefined) {\n navigator.mediaDevices.getUserMedia = promisifiedOldGUM;\n }\n this.constraints = this.params.constraints || {\n video: false,\n audio: true\n };\n this.bufferSize = this.params.bufferSize || 4096;\n this.numberOfInputChannels = this.params.numberOfInputChannels || 1;\n this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;\n\n this._onBackendCreated = () => {\n // wavesurfer's AudioContext where we'll route the mic signal to\n this.micContext = this.wavesurfer.backend.getAudioContext();\n };\n }\n\n init() {\n this.wavesurfer.on('backend-created', this._onBackendCreated);\n if (this.wavesurfer.backend) {\n this._onBackendCreated();\n }\n }\n\n /**\n * Destroy the microphone plugin.\n */\n destroy() {\n // make sure the buffer is not redrawn during\n // cleanup and demolition of this plugin.\n this.paused = true;\n\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.stop();\n }\n\n /**\n * Allow user to select audio input device, e.g. microphone, and\n * start the visualization.\n */\n start() {\n navigator.mediaDevices\n .getUserMedia(this.constraints)\n .then(data => this.gotStream(data))\n .catch(data => this.deviceError(data));\n }\n\n /**\n * Pause/resume visualization.\n */\n togglePlay() {\n if (!this.active) {\n // start it first\n this.start();\n } else {\n // toggle paused\n this.paused = !this.paused;\n\n if (this.paused) {\n this.pause();\n } else {\n this.play();\n }\n }\n }\n\n /**\n * Play visualization.\n */\n play() {\n this.paused = false;\n\n this.connect();\n }\n\n /**\n * Pause visualization.\n */\n pause() {\n this.paused = true;\n\n // disconnect sources so they can be used elsewhere\n // (eg. during audio playback)\n this.disconnect();\n }\n\n /**\n * Stop the device stream and remove any remaining waveform drawing from\n * the wavesurfer canvas.\n */\n stop() {\n if (this.active) {\n // stop visualization and device\n this.stopDevice();\n\n // empty last frame\n this.wavesurfer.empty();\n }\n }\n\n /**\n * Stop the device and the visualization.\n */\n stopDevice() {\n this.active = false;\n\n // stop visualization\n this.disconnect();\n\n // stop stream from device\n if (this.stream && this.stream.getTracks) {\n this.stream.getTracks().forEach(stream => stream.stop());\n }\n }\n\n /**\n * Connect the media sources that feed the visualization.\n */\n connect() {\n if (this.stream !== undefined) {\n // Create a local buffer for data to be copied to the Wavesurfer buffer for Edge\n if (this.browser.browser === 'edge') {\n this.localAudioBuffer = this.micContext.createBuffer(\n this.numberOfInputChannels,\n this.bufferSize,\n this.micContext.sampleRate\n );\n }\n\n // Create an AudioNode from the stream.\n this.mediaStreamSource = this.micContext.createMediaStreamSource(\n this.stream\n );\n\n this.levelChecker = this.micContext.createScriptProcessor(\n this.bufferSize,\n this.numberOfInputChannels,\n this.numberOfOutputChannels\n );\n this.mediaStreamSource.connect(this.levelChecker);\n\n this.levelChecker.connect(this.micContext.destination);\n this.levelChecker.onaudioprocess = this.reloadBufferFunction;\n }\n }\n\n /**\n * Disconnect the media sources that feed the visualization.\n */\n disconnect() {\n if (this.mediaStreamSource !== undefined) {\n this.mediaStreamSource.disconnect();\n }\n\n if (this.levelChecker !== undefined) {\n this.levelChecker.disconnect();\n this.levelChecker.onaudioprocess = undefined;\n }\n\n if (this.localAudioBuffer !== undefined) {\n this.localAudioBuffer = undefined;\n }\n }\n\n /**\n * Redraw the waveform.\n *\n * @param {object} event Audioprocess event\n */\n reloadBuffer(event) {\n if (!this.paused) {\n this.wavesurfer.empty();\n\n if (this.browser.browser === 'edge') {\n // copy audio data to a local audio buffer,\n // from https://github.com/audiojs/audio-buffer-utils\n let channel, l;\n for (\n channel = 0,\n l = Math.min(\n this.localAudioBuffer.numberOfChannels,\n event.inputBuffer.numberOfChannels\n );\n channel < l;\n channel++\n ) {\n this.localAudioBuffer\n .getChannelData(channel)\n .set(event.inputBuffer.getChannelData(channel));\n }\n\n this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);\n } else {\n this.wavesurfer.loadDecodedBuffer(event.inputBuffer);\n }\n }\n }\n\n /**\n * Audio input device is ready.\n *\n * @param {MediaStream} stream The microphone's media stream.\n */\n gotStream(stream) {\n this.stream = stream;\n this.active = true;\n\n // start visualization\n this.play();\n\n // notify listeners\n this.fireEvent('deviceReady', stream);\n }\n\n /**\n * Device error callback.\n *\n * @param {string} code Error message\n */\n deviceError(code) {\n // notify listeners\n this.fireEvent('deviceError', code);\n }\n\n /**\n * Extract browser version out of the provided user agent string.\n * @param {!string} uastring userAgent string.\n * @param {!string} expr Regular expression used as match criteria.\n * @param {!number} pos position in the version string to be returned.\n * @return {!number} browser version.\n */\n extractVersion(uastring, expr, pos) {\n const match = uastring.match(expr);\n return match && match.length >= pos && parseInt(match[pos], 10);\n }\n\n /**\n * Browser detector.\n * @return {object} result containing browser, version and minVersion\n * properties.\n */\n detectBrowser() {\n // Returned result object.\n const result = {};\n result.browser = null;\n result.version = null;\n result.minVersion = null;\n\n // Non supported browser.\n if (typeof window === 'undefined' || !window.navigator) {\n result.browser = 'Not a supported browser.';\n return result;\n }\n\n if (navigator.mozGetUserMedia) {\n // Firefox\n result.browser = 'firefox';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Firefox\\/(\\d+)\\./,\n 1\n );\n result.minVersion = 31;\n return result;\n } else if (navigator.webkitGetUserMedia) {\n // Chrome/Chromium/Webview/Opera\n result.browser = 'chrome';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Chrom(e|ium)\\/(\\d+)\\./,\n 2\n );\n result.minVersion = 38;\n return result;\n } else if (\n navigator.mediaDevices &&\n navigator.userAgent.match(/Edge\\/(\\d+).(\\d+)$/)\n ) {\n // Edge\n result.browser = 'edge';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Edge\\/(\\d+).(\\d+)$/,\n 2\n );\n result.minVersion = 10547;\n return result;\n } else if (\n window.RTCPeerConnection &&\n navigator.userAgent.match(/AppleWebKit\\/(\\d+)\\./)\n ) {\n // Safari\n result.browser = 'safari';\n result.minVersion = 11;\n result.version = this.extractVersion(\n navigator.userAgent,\n /AppleWebKit\\/(\\d+)\\./,\n 1\n );\n return result;\n }\n\n // Non supported browser default.\n result.browser = 'Not a supported browser.';\n return result;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(872);\n"],"names":["root","factory","exports","module","define","amd","self","MicrophonePlugin","params","ws","_this","_classCallCheck","this","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","undefined","navigator","mediaDevices","getUserMedia","constraints","successCallback","errorCallback","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","call","reject","Error","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","key","value","name","deferInit","instance","on","un","stop","_this2","then","data","gotStream","catch","deviceError","pause","play","start","connect","disconnect","stopDevice","empty","stream","getTracks","forEach","localAudioBuffer","createBuffer","sampleRate","mediaStreamSource","createMediaStreamSource","levelChecker","createScriptProcessor","destination","onaudioprocess","event","channel","l","Math","min","numberOfChannels","inputBuffer","getChannelData","set","loadDecodedBuffer","fireEvent","code","uastring","expr","pos","match","length","parseInt","result","window","version","extractVersion","userAgent","minVersion","RTCPeerConnection","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|