wavesurfer.js 7.0.0-beta.6 → 7.0.0-beta.8

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.
Files changed (58) hide show
  1. package/README.md +2 -2
  2. package/dist/plugins/minimap.min.js +1 -1
  3. package/dist/plugins/regions.d.ts +1 -0
  4. package/dist/plugins/regions.js +3 -0
  5. package/dist/plugins/regions.min.js +1 -1
  6. package/dist/renderer.d.ts +2 -0
  7. package/dist/renderer.js +33 -19
  8. package/dist/wavesurfer.d.ts +9 -9
  9. package/dist/wavesurfer.js +3 -4
  10. package/dist/wavesurfer.min.js +1 -1
  11. package/package.json +5 -5
  12. package/dist/cypress/support/commands.d.ts +0 -1
  13. package/dist/cypress/support/commands.js +0 -39
  14. package/dist/cypress/support/e2e.d.ts +0 -1
  15. package/dist/cypress/support/e2e.js +0 -18
  16. package/dist/cypress.config.d.ts +0 -2
  17. package/dist/cypress.config.js +0 -10
  18. package/dist/plugins/envelope.min.cjs +0 -1
  19. package/dist/plugins/minimap.min.cjs +0 -1
  20. package/dist/plugins/multitrack.d.ts +0 -117
  21. package/dist/plugins/multitrack.js +0 -507
  22. package/dist/plugins/multitrack.min.cjs +0 -1
  23. package/dist/plugins/multitrack.min.js +0 -1
  24. package/dist/plugins/record.min.cjs +0 -1
  25. package/dist/plugins/regions.min.cjs +0 -1
  26. package/dist/plugins/spectrogram.min.cjs +0 -1
  27. package/dist/plugins/timeline.min.cjs +0 -1
  28. package/dist/src/base-plugin.d.ts +0 -13
  29. package/dist/src/base-plugin.js +0 -22
  30. package/dist/src/decoder.d.ts +0 -9
  31. package/dist/src/decoder.js +0 -48
  32. package/dist/src/event-emitter.d.ts +0 -19
  33. package/dist/src/event-emitter.js +0 -45
  34. package/dist/src/fetcher.d.ts +0 -5
  35. package/dist/src/fetcher.js +0 -7
  36. package/dist/src/player.d.ts +0 -45
  37. package/dist/src/player.js +0 -114
  38. package/dist/src/plugins/envelope.d.ts +0 -71
  39. package/dist/src/plugins/envelope.js +0 -350
  40. package/dist/src/plugins/minimap.d.ts +0 -39
  41. package/dist/src/plugins/minimap.js +0 -117
  42. package/dist/src/plugins/record.d.ts +0 -26
  43. package/dist/src/plugins/record.js +0 -124
  44. package/dist/src/plugins/regions.d.ts +0 -93
  45. package/dist/src/plugins/regions.js +0 -395
  46. package/dist/src/plugins/spectrogram-fft.d.ts +0 -9
  47. package/dist/src/plugins/spectrogram-fft.js +0 -150
  48. package/dist/src/plugins/spectrogram.d.ts +0 -69
  49. package/dist/src/plugins/spectrogram.js +0 -340
  50. package/dist/src/plugins/timeline.d.ts +0 -45
  51. package/dist/src/plugins/timeline.js +0 -162
  52. package/dist/src/renderer.d.ts +0 -41
  53. package/dist/src/renderer.js +0 -420
  54. package/dist/src/timer.d.ts +0 -11
  55. package/dist/src/timer.js +0 -19
  56. package/dist/src/wavesurfer.d.ts +0 -149
  57. package/dist/src/wavesurfer.js +0 -229
  58. package/dist/wavesurfer.min.cjs +0 -1
@@ -1,124 +0,0 @@
1
- /**
2
- * Record audio from the microphone, render a waveform and download the audio.
3
- */
4
- import BasePlugin from '../base-plugin.js';
5
- class RecordPlugin extends BasePlugin {
6
- mediaRecorder = null;
7
- recordedUrl = '';
8
- static create(options) {
9
- return new RecordPlugin(options || {});
10
- }
11
- loadBlob(data) {
12
- const blob = new Blob(data, { type: 'audio/webm' });
13
- this.recordedUrl = URL.createObjectURL(blob);
14
- this.wavesurfer?.load(this.recordedUrl);
15
- }
16
- render(stream) {
17
- if (!this.wavesurfer)
18
- return () => undefined;
19
- const container = this.wavesurfer.getWrapper();
20
- const canvas = document.createElement('canvas');
21
- canvas.width = container.clientWidth;
22
- canvas.height = container.clientHeight;
23
- canvas.style.zIndex = '10';
24
- container.appendChild(canvas);
25
- const canvasCtx = canvas.getContext('2d');
26
- const audioContext = new AudioContext();
27
- const source = audioContext.createMediaStreamSource(stream);
28
- const analyser = audioContext.createAnalyser();
29
- source.connect(analyser);
30
- let animationId;
31
- const drawWaveform = () => {
32
- if (!canvasCtx)
33
- return;
34
- canvasCtx.clearRect(0, 0, canvas.width, canvas.height);
35
- const bufferLength = analyser.frequencyBinCount;
36
- const dataArray = new Uint8Array(bufferLength);
37
- analyser.getByteTimeDomainData(dataArray);
38
- canvasCtx.lineWidth = this.options.lineWidth || 2;
39
- const color = this.options.realtimeWaveColor || this.wavesurfer?.options.waveColor || '';
40
- canvasCtx.strokeStyle = Array.isArray(color) ? color[0] : color;
41
- canvasCtx.beginPath();
42
- const sliceWidth = (canvas.width * 1.0) / bufferLength;
43
- let x = 0;
44
- for (let i = 0; i < bufferLength; i++) {
45
- const v = dataArray[i] / 128.0;
46
- const y = (v * canvas.height) / 2;
47
- if (i === 0) {
48
- canvasCtx.moveTo(x, y);
49
- }
50
- else {
51
- canvasCtx.lineTo(x, y);
52
- }
53
- x += sliceWidth;
54
- }
55
- canvasCtx.lineTo(canvas.width, canvas.height / 2);
56
- canvasCtx.stroke();
57
- animationId = requestAnimationFrame(drawWaveform);
58
- };
59
- drawWaveform();
60
- return () => {
61
- if (animationId) {
62
- cancelAnimationFrame(animationId);
63
- }
64
- if (source) {
65
- source.disconnect();
66
- source.mediaStream.getTracks().forEach((track) => track.stop());
67
- }
68
- if (audioContext) {
69
- audioContext.close();
70
- }
71
- canvas?.remove();
72
- };
73
- }
74
- cleanUp() {
75
- this.stopRecording();
76
- this.wavesurfer?.empty();
77
- if (this.recordedUrl) {
78
- URL.revokeObjectURL(this.recordedUrl);
79
- this.recordedUrl = '';
80
- }
81
- }
82
- async startRecording() {
83
- this.cleanUp();
84
- let stream;
85
- try {
86
- stream = await navigator.mediaDevices.getUserMedia({ audio: true });
87
- }
88
- catch (err) {
89
- throw new Error('Error accessing the microphone: ' + err.message);
90
- }
91
- const onStop = this.render(stream);
92
- const mediaRecorder = new MediaRecorder(stream);
93
- const recordedChunks = [];
94
- mediaRecorder.addEventListener('dataavailable', (event) => {
95
- if (event.data.size > 0) {
96
- recordedChunks.push(event.data);
97
- }
98
- });
99
- mediaRecorder.addEventListener('stop', () => {
100
- onStop();
101
- this.loadBlob(recordedChunks);
102
- this.emit('stopRecording');
103
- });
104
- mediaRecorder.start();
105
- this.emit('startRecording');
106
- this.mediaRecorder = mediaRecorder;
107
- }
108
- isRecording() {
109
- return this.mediaRecorder?.state === 'recording';
110
- }
111
- stopRecording() {
112
- if (this.isRecording()) {
113
- this.mediaRecorder?.stop();
114
- }
115
- }
116
- getRecordedUrl() {
117
- return this.recordedUrl;
118
- }
119
- destroy() {
120
- super.destroy();
121
- this.cleanUp();
122
- }
123
- }
124
- export default RecordPlugin;
@@ -1,93 +0,0 @@
1
- /**
2
- * Regions are visual overlays on the waveform that can be used to mark segments of audio.
3
- * Regions can be clicked on, dragged and resized.
4
- * You can set the color and content of each region, as well as their HTML content.
5
- */
6
- import BasePlugin from '../base-plugin.js';
7
- import EventEmitter from '../event-emitter.js';
8
- export type RegionsPluginOptions = undefined;
9
- export type RegionsPluginEvents = {
10
- 'region-created': [region: Region];
11
- 'region-updated': [region: Region];
12
- 'region-clicked': [region: Region, e: MouseEvent];
13
- };
14
- export type RegionEvents = {
15
- remove: [];
16
- update: [];
17
- 'update-end': [];
18
- play: [];
19
- click: [event: MouseEvent];
20
- dblclick: [event: MouseEvent];
21
- over: [event: MouseEvent];
22
- leave: [event: MouseEvent];
23
- };
24
- export type RegionParams = {
25
- id?: string;
26
- start: number;
27
- end?: number;
28
- drag?: boolean;
29
- resize?: boolean;
30
- color?: string;
31
- content?: string | HTMLElement;
32
- };
33
- export declare class Region extends EventEmitter<RegionEvents> {
34
- private totalDuration;
35
- element: HTMLElement;
36
- id: string;
37
- start: number;
38
- end: number;
39
- drag: boolean;
40
- resize: boolean;
41
- color: string;
42
- content?: HTMLElement;
43
- constructor(params: RegionParams, totalDuration: number);
44
- private initElement;
45
- private renderPosition;
46
- private initMouseEvents;
47
- private onStartMoving;
48
- private onEndMoving;
49
- private onUpdate;
50
- private onMove;
51
- private onResize;
52
- private onEndResizing;
53
- _setTotalDuration(totalDuration: number): void;
54
- /** Play the region from start to end */
55
- play(): void;
56
- /** Update the region's options */
57
- setOptions(options: {
58
- color?: string;
59
- drag?: boolean;
60
- resize?: boolean;
61
- start?: number;
62
- end?: number;
63
- }): void;
64
- /** Remove the region */
65
- remove(): void;
66
- }
67
- declare class RegionsPlugin extends BasePlugin<RegionsPluginEvents, RegionsPluginOptions> {
68
- private regions;
69
- private regionsContainer;
70
- /** Create an instance of RegionsPlugin */
71
- constructor(options?: RegionsPluginOptions);
72
- /** Create an instance of RegionsPlugin */
73
- static create(options?: RegionsPluginOptions): RegionsPlugin;
74
- /** Called by wavesurfer, don't call manually */
75
- onInit(): void;
76
- private initRegionsContainer;
77
- /** Get all created regions */
78
- getRegions(): Region[];
79
- private avoidOverlapping;
80
- private saveRegion;
81
- /** Create a region with given parameters */
82
- addRegion(options: RegionParams): Region;
83
- /**
84
- * Enable creation of regions by dragging on an empty space on the waveform.
85
- * Returns a function to disable the drag selection.
86
- */
87
- enableDragSelection(options: Omit<RegionParams, 'start' | 'end'>): () => void;
88
- /** Remove all regions */
89
- clearRegions(): void;
90
- /** Destroy the plugin and clean up */
91
- destroy(): void;
92
- }
93
- export default RegionsPlugin;
@@ -1,395 +0,0 @@
1
- /**
2
- * Regions are visual overlays on the waveform that can be used to mark segments of audio.
3
- * Regions can be clicked on, dragged and resized.
4
- * You can set the color and content of each region, as well as their HTML content.
5
- */
6
- import BasePlugin from '../base-plugin.js';
7
- import EventEmitter from '../event-emitter.js';
8
- function makeDraggable(element, onStart, onMove, onEnd, threshold = 5) {
9
- if (!element)
10
- return () => undefined;
11
- let isDragging = false;
12
- const onClick = (e) => {
13
- isDragging && e.stopPropagation();
14
- };
15
- const onMouseDown = (e) => {
16
- e.stopPropagation();
17
- let x = e.clientX;
18
- let sumDx = 0;
19
- onStart(x);
20
- const onMouseMove = (e) => {
21
- const newX = e.clientX;
22
- const dx = newX - x;
23
- sumDx += dx;
24
- x = newX;
25
- if (isDragging || Math.abs(sumDx) >= threshold) {
26
- onMove(isDragging ? dx : sumDx);
27
- isDragging = true;
28
- }
29
- };
30
- const onMouseUp = () => {
31
- if (isDragging) {
32
- onEnd();
33
- setTimeout(() => (isDragging = false), 10);
34
- }
35
- document.removeEventListener('mousemove', onMouseMove);
36
- document.removeEventListener('mouseup', onMouseUp);
37
- };
38
- document.addEventListener('mousemove', onMouseMove);
39
- document.addEventListener('mouseup', onMouseUp);
40
- };
41
- element.addEventListener('click', onClick);
42
- element.addEventListener('mousedown', onMouseDown);
43
- return () => {
44
- element.removeEventListener('click', onClick);
45
- element.removeEventListener('mousedown', onMouseDown);
46
- };
47
- }
48
- export class Region extends EventEmitter {
49
- totalDuration;
50
- element;
51
- id;
52
- start;
53
- end;
54
- drag;
55
- resize;
56
- color;
57
- content;
58
- constructor(params, totalDuration) {
59
- super();
60
- this.totalDuration = totalDuration;
61
- this.id = params.id || `region-${Math.random().toString(32).slice(2)}`;
62
- this.start = params.start;
63
- this.end = params.end ?? params.start;
64
- this.drag = params.drag ?? true;
65
- this.resize = params.resize ?? true;
66
- this.color = params.color ?? 'rgba(0, 0, 0, 0.1)';
67
- this.element = this.initElement(params.content);
68
- this.renderPosition();
69
- this.initMouseEvents();
70
- }
71
- initElement(content) {
72
- const element = document.createElement('div');
73
- const isMarker = this.start === this.end;
74
- element.setAttribute('part', `${isMarker ? 'marker' : 'region'} ${this.id}`);
75
- element.setAttribute('style', `
76
- position: absolute;
77
- height: 100%;
78
- background-color: ${isMarker ? 'none' : this.color};
79
- border-left: ${isMarker ? '2px solid ' + this.color : 'none'};
80
- border-radius: 2px;
81
- box-sizing: border-box;
82
- transition: background-color 0.2s ease;
83
- cursor: ${this.drag ? 'grab' : 'default'};
84
- pointer-events: all;
85
- padding: 0.2em ${isMarker ? 0.2 : 0.4}em;
86
- pointer-events: all;
87
- `);
88
- // Init content
89
- if (content) {
90
- if (typeof content === 'string') {
91
- this.content = document.createElement('div');
92
- this.content.textContent = content;
93
- }
94
- else {
95
- this.content = content;
96
- }
97
- this.content.setAttribute('part', 'region-content');
98
- element.appendChild(this.content);
99
- }
100
- // Add resize handles
101
- if (!isMarker) {
102
- const leftHandle = document.createElement('div');
103
- leftHandle.setAttribute('data-resize', 'left');
104
- leftHandle.setAttribute('style', `
105
- position: absolute;
106
- z-index: 2;
107
- width: 6px;
108
- height: 100%;
109
- top: 0;
110
- left: 0;
111
- border-left: 2px solid rgba(0, 0, 0, 0.5);
112
- border-radius: 2px 0 0 2px;
113
- cursor: ${this.resize ? 'ew-resize' : 'default'};
114
- word-break: keep-all;
115
- `);
116
- leftHandle.setAttribute('part', 'region-handle region-handle-left');
117
- const rightHandle = leftHandle.cloneNode();
118
- rightHandle.setAttribute('data-resize', 'right');
119
- rightHandle.style.left = '';
120
- rightHandle.style.right = '0';
121
- rightHandle.style.borderRight = rightHandle.style.borderLeft;
122
- rightHandle.style.borderLeft = '';
123
- rightHandle.style.borderRadius = '0 2px 2px 0';
124
- rightHandle.setAttribute('part', 'region-handle region-handle-right');
125
- element.appendChild(leftHandle);
126
- element.appendChild(rightHandle);
127
- }
128
- return element;
129
- }
130
- renderPosition() {
131
- const start = this.start / this.totalDuration;
132
- const end = this.end / this.totalDuration;
133
- this.element.style.left = `${start * 100}%`;
134
- this.element.style.width = `${(end - start) * 100}%`;
135
- }
136
- initMouseEvents() {
137
- const { element } = this;
138
- element.addEventListener('click', (e) => this.emit('click', e));
139
- element.addEventListener('mouseenter', (e) => this.emit('over', e));
140
- element.addEventListener('mouseleave', (e) => this.emit('leave', e));
141
- element.addEventListener('dblclick', (e) => this.emit('dblclick', e));
142
- // Drag
143
- makeDraggable(element, () => this.onStartMoving(), (dx) => this.onMove(dx), () => this.onEndMoving());
144
- // Resize
145
- const resizeThreshold = 1;
146
- makeDraggable(element.querySelector('[data-resize="left"]'), () => null, (dx) => this.onResize(dx, 'start'), () => this.onEndResizing(), resizeThreshold);
147
- makeDraggable(element.querySelector('[data-resize="right"]'), () => null, (dx) => this.onResize(dx, 'end'), () => this.onEndResizing(), resizeThreshold);
148
- }
149
- onStartMoving() {
150
- if (!this.drag)
151
- return;
152
- this.element.style.cursor = 'grabbing';
153
- }
154
- onEndMoving() {
155
- if (!this.drag)
156
- return;
157
- this.element.style.cursor = 'grab';
158
- this.emit('update-end');
159
- }
160
- onUpdate(dx, sides) {
161
- if (!this.element.parentElement)
162
- return;
163
- const deltaSeconds = (dx / this.element.parentElement.clientWidth) * this.totalDuration;
164
- sides.forEach((side) => {
165
- this[side] += deltaSeconds;
166
- if (side === 'start') {
167
- this.start = Math.max(0, Math.min(this.start, this.end));
168
- }
169
- else {
170
- this.end = Math.max(this.start, Math.min(this.end, this.totalDuration));
171
- }
172
- });
173
- this.renderPosition();
174
- this.emit('update');
175
- }
176
- onMove(dx) {
177
- if (!this.drag)
178
- return;
179
- this.onUpdate(dx, ['start', 'end']);
180
- }
181
- onResize(dx, side) {
182
- if (!this.resize)
183
- return;
184
- this.onUpdate(dx, [side]);
185
- }
186
- onEndResizing() {
187
- if (!this.resize)
188
- return;
189
- this.emit('update-end');
190
- }
191
- _setTotalDuration(totalDuration) {
192
- this.totalDuration = totalDuration;
193
- this.renderPosition();
194
- }
195
- /** Play the region from start to end */
196
- play() {
197
- this.emit('play');
198
- }
199
- /** Update the region's options */
200
- setOptions(options) {
201
- if (options.color) {
202
- this.color = options.color;
203
- this.element.style.backgroundColor = this.color;
204
- }
205
- if (options.drag !== undefined) {
206
- this.drag = options.drag;
207
- this.element.style.cursor = this.drag ? 'grab' : 'default';
208
- }
209
- if (options.resize !== undefined) {
210
- this.resize = options.resize;
211
- this.element.querySelectorAll('[data-resize]').forEach((handle) => {
212
- ;
213
- handle.style.cursor = this.resize ? 'ew-resize' : 'default';
214
- });
215
- }
216
- if (options.start !== undefined || options.end !== undefined) {
217
- this.start = options.start ?? this.start;
218
- this.end = options.end ?? this.end;
219
- this.renderPosition();
220
- }
221
- }
222
- /** Remove the region */
223
- remove() {
224
- this.emit('remove');
225
- this.element.remove();
226
- // This violates the type but we want to clean up the DOM reference
227
- // w/o having to have a nullable type of the element
228
- this.element = null;
229
- }
230
- }
231
- class RegionsPlugin extends BasePlugin {
232
- regions = [];
233
- regionsContainer;
234
- /** Create an instance of RegionsPlugin */
235
- constructor(options) {
236
- super(options);
237
- this.regionsContainer = this.initRegionsContainer();
238
- }
239
- /** Create an instance of RegionsPlugin */
240
- static create(options) {
241
- return new RegionsPlugin(options);
242
- }
243
- /** Called by wavesurfer, don't call manually */
244
- onInit() {
245
- if (!this.wavesurfer) {
246
- throw Error('WaveSurfer is not initialized');
247
- }
248
- this.wavesurfer.getWrapper().appendChild(this.regionsContainer);
249
- }
250
- initRegionsContainer() {
251
- const div = document.createElement('div');
252
- div.setAttribute('style', `
253
- position: absolute;
254
- top: 0;
255
- left: 0;
256
- width: 100%;
257
- height: 100%;
258
- z-index: 3;
259
- pointer-events: none;
260
- `);
261
- return div;
262
- }
263
- /** Get all created regions */
264
- getRegions() {
265
- return this.regions;
266
- }
267
- avoidOverlapping(region) {
268
- if (!region.content)
269
- return;
270
- // Check that the label doesn't overlap with other labels
271
- // If it does, push it down until it doesn't
272
- const div = region.content;
273
- const labelLeft = div.getBoundingClientRect().left;
274
- const labelWidth = region.element.scrollWidth;
275
- const overlap = this.regions
276
- .filter((reg) => {
277
- if (reg === region || !reg.content)
278
- return false;
279
- const left = reg.content.getBoundingClientRect().left;
280
- const width = reg.element.scrollWidth;
281
- return labelLeft < left + width && left < labelLeft + labelWidth;
282
- })
283
- .map((reg) => reg.content?.getBoundingClientRect().height || 0)
284
- .reduce((sum, val) => sum + val, 0);
285
- div.style.marginTop = `${overlap}px`;
286
- }
287
- saveRegion(region) {
288
- this.regionsContainer.appendChild(region.element);
289
- this.avoidOverlapping(region);
290
- this.regions.push(region);
291
- this.emit('region-created', region);
292
- const regionSubscriptions = [
293
- region.on('update-end', () => {
294
- this.avoidOverlapping(region);
295
- this.emit('region-updated', region);
296
- }),
297
- region.on('play', () => {
298
- this.wavesurfer?.play();
299
- this.wavesurfer?.setTime(region.start);
300
- }),
301
- region.on('click', (e) => {
302
- this.emit('region-clicked', region, e);
303
- }),
304
- // Remove the region from the list when it's removed
305
- region.once('remove', () => {
306
- regionSubscriptions.forEach((unsubscribe) => unsubscribe());
307
- this.regions = this.regions.filter((reg) => reg !== region);
308
- }),
309
- ];
310
- this.subscriptions.push(...regionSubscriptions);
311
- }
312
- /** Create a region with given parameters */
313
- addRegion(options) {
314
- if (!this.wavesurfer) {
315
- throw Error('WaveSurfer is not initialized');
316
- }
317
- const duration = this.wavesurfer.getDuration();
318
- const region = new Region(options, duration);
319
- if (!duration) {
320
- this.subscriptions.push(this.wavesurfer.once('ready', (duration) => {
321
- region._setTotalDuration(duration);
322
- this.saveRegion(region);
323
- }));
324
- }
325
- else {
326
- this.saveRegion(region);
327
- }
328
- return region;
329
- }
330
- /**
331
- * Enable creation of regions by dragging on an empty space on the waveform.
332
- * Returns a function to disable the drag selection.
333
- */
334
- enableDragSelection(options) {
335
- const wrapper = this.wavesurfer?.getWrapper()?.querySelector('div');
336
- if (!wrapper)
337
- return () => undefined;
338
- let region = null;
339
- let startX = 0;
340
- let sumDx = 0;
341
- return makeDraggable(wrapper,
342
- // On mousedown
343
- (x) => (startX = x),
344
- // On mousemove
345
- (dx) => {
346
- if (!this.wavesurfer)
347
- return;
348
- if (!region) {
349
- const duration = this.wavesurfer.getDuration();
350
- const box = wrapper.getBoundingClientRect();
351
- let start = ((startX - box.left) / box.width) * duration;
352
- let end = ((startX + dx - box.left) / box.width) * duration;
353
- if (start > end)
354
- [start, end] = [end, start];
355
- region = new Region({
356
- ...options,
357
- start,
358
- end,
359
- }, duration);
360
- this.regionsContainer.appendChild(region.element);
361
- }
362
- sumDx += dx;
363
- if (region) {
364
- const privateRegion = region;
365
- privateRegion.onUpdate(dx, [sumDx > 0 ? 'end' : 'start']);
366
- }
367
- },
368
- // On mouseup
369
- () => {
370
- if (region) {
371
- this.saveRegion(region);
372
- region = null;
373
- sumDx = 0;
374
- // Prevent a click event on the waveform
375
- if (this.wavesurfer) {
376
- const { interact } = this.wavesurfer.options;
377
- if (interact) {
378
- this.wavesurfer.toggleInteraction(false);
379
- setTimeout(() => this.wavesurfer?.toggleInteraction(interact), 10);
380
- }
381
- }
382
- }
383
- });
384
- }
385
- /** Remove all regions */
386
- clearRegions() {
387
- this.regions.forEach((region) => region.remove());
388
- }
389
- /** Destroy the plugin and clean up */
390
- destroy() {
391
- this.clearRegions();
392
- super.destroy();
393
- }
394
- }
395
- export default RegionsPlugin;
@@ -1,9 +0,0 @@
1
- /**
2
- * Calculate FFT - Based on https://github.com/corbanbrook/dsp.js
3
- *
4
- * @param {Number} bufferSize Buffer size
5
- * @param {Number} sampleRate Sample rate
6
- * @param {Function} windowFunc Window function
7
- * @param {Number} alpha Alpha channel
8
- */
9
- export default function FFT(bufferSize: any, sampleRate: any, windowFunc: any, alpha: any): void;