@tsparticles/plugin-sounds 3.9.0 → 4.0.0-alpha.0
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/902.min.js +2 -0
- package/902.min.js.LICENSE.txt +1 -0
- package/browser/Options/Classes/SoundsEvent.js +1 -1
- package/browser/SoundsInstance.js +26 -24
- package/browser/index.js +6 -4
- package/browser/utils.js +2 -2
- package/cjs/Options/Classes/Sounds.js +9 -13
- package/cjs/Options/Classes/SoundsAudio.js +4 -8
- package/cjs/Options/Classes/SoundsEvent.js +14 -18
- package/cjs/Options/Classes/SoundsIcon.js +3 -7
- package/cjs/Options/Classes/SoundsIcons.js +8 -12
- package/cjs/Options/Classes/SoundsMelody.js +5 -9
- package/cjs/Options/Classes/SoundsNote.js +3 -7
- package/cjs/Options/Classes/SoundsVolume.js +4 -8
- package/cjs/Options/Interfaces/ISounds.js +1 -2
- package/cjs/Options/Interfaces/ISoundsAudio.js +1 -2
- package/cjs/Options/Interfaces/ISoundsEvent.js +1 -2
- package/cjs/Options/Interfaces/ISoundsIcon.js +1 -2
- package/cjs/Options/Interfaces/ISoundsIcons.js +1 -2
- package/cjs/Options/Interfaces/ISoundsMelody.js +1 -2
- package/cjs/Options/Interfaces/ISoundsNote.js +1 -2
- package/cjs/Options/Interfaces/ISoundsVolume.js +1 -2
- package/cjs/SoundsInstance.js +53 -55
- package/cjs/SoundsPlugin.js +12 -16
- package/cjs/enums.js +4 -7
- package/cjs/index.js +6 -7
- package/cjs/types.js +1 -2
- package/cjs/utils.js +5 -11
- package/dist_browser_SoundsPlugin_js.js +140 -0
- package/esm/Options/Classes/SoundsEvent.js +1 -1
- package/esm/SoundsInstance.js +26 -24
- package/esm/index.js +6 -4
- package/esm/utils.js +2 -2
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.plugin.sounds.js +209 -140
- package/tsparticles.plugin.sounds.min.js +1 -1
- package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -1
- package/types/SoundsInstance.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/Options/Classes/SoundsEvent.js +1 -1
- package/umd/SoundsInstance.js +25 -23
- package/umd/index.js +41 -5
- package/umd/utils.js +2 -2
package/cjs/SoundsInstance.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const enums_js_1 = require("./enums.js");
|
|
6
|
-
const utils_js_1 = require("./utils.js");
|
|
1
|
+
import { clamp, executeOnSingleOrMultiple, getLogger, isArray, isNumber, itemFromArray, itemFromSingleOrMultiple, mouseDownEvent, percentDenominator, safeDocument, touchStartEvent, } from "@tsparticles/engine";
|
|
2
|
+
import { ImageDisplay, SoundsEventType } from "./enums.js";
|
|
3
|
+
import { getNoteFrequency, isWindowMuted, unmuteWindow } from "./utils.js";
|
|
7
4
|
const zIndexOffset = 1, rightOffset = 1, minVolume = 0;
|
|
8
5
|
function initImage(data) {
|
|
9
|
-
const img =
|
|
6
|
+
const img = safeDocument().createElement("img"), { clickCb, container, display, iconOptions, margin, options, pos, rightOffsets } = data, { width, path, style, svg } = iconOptions, defaultAccumulator = 0;
|
|
10
7
|
setIconStyle(img, pos.top + margin, pos.right -
|
|
11
8
|
(margin * (rightOffsets.length + rightOffset) +
|
|
12
9
|
width +
|
|
13
10
|
rightOffsets.reduce((a, b) => a + b, defaultAccumulator)), display, options.fullScreen.zIndex + zIndexOffset, width, margin, style);
|
|
14
11
|
img.src = path ?? (svg ? `data:image/svg+xml;base64,${btoa(svg)}` : "");
|
|
15
|
-
const parent = container.canvas.element?.parentNode ??
|
|
12
|
+
const parent = container.canvas.element?.parentNode ?? safeDocument().body;
|
|
16
13
|
parent.append(img);
|
|
17
14
|
img.addEventListener("click", () => {
|
|
18
15
|
void clickCb();
|
|
@@ -27,15 +24,14 @@ function removeImage(image) {
|
|
|
27
24
|
}
|
|
28
25
|
function setIconStyle(icon, top, left, display, zIndex, width, margin, style) {
|
|
29
26
|
icon.style.userSelect = "none";
|
|
30
|
-
icon.style.webkitUserSelect = "none";
|
|
31
27
|
icon.style.position = "absolute";
|
|
32
|
-
icon.style.top = `${top + margin}px`;
|
|
33
|
-
icon.style.left = `${left - margin - width}px`;
|
|
28
|
+
icon.style.top = `${(top + margin).toString()}px`;
|
|
29
|
+
icon.style.left = `${(left - margin - width).toString()}px`;
|
|
34
30
|
icon.style.display = display;
|
|
35
|
-
icon.style.zIndex =
|
|
31
|
+
icon.style.zIndex = (zIndex + zIndexOffset).toString();
|
|
36
32
|
icon.style.cssText += style;
|
|
37
33
|
}
|
|
38
|
-
class SoundsInstance {
|
|
34
|
+
export class SoundsInstance {
|
|
39
35
|
constructor(container, engine) {
|
|
40
36
|
this._addBuffer = audioCtx => {
|
|
41
37
|
const buffer = audioCtx.createBufferSource();
|
|
@@ -59,8 +55,8 @@ class SoundsInstance {
|
|
|
59
55
|
if (this._container !== args.container) {
|
|
60
56
|
return;
|
|
61
57
|
}
|
|
62
|
-
if (
|
|
63
|
-
|
|
58
|
+
if (!!this._container.muted || this._container.destroyed) {
|
|
59
|
+
executeOnSingleOrMultiple(event.event, item => {
|
|
64
60
|
this._engine.removeEventListener(item, cb);
|
|
65
61
|
});
|
|
66
62
|
return;
|
|
@@ -70,10 +66,17 @@ class SoundsInstance {
|
|
|
70
66
|
}
|
|
71
67
|
const defaultNoteIndex = 0;
|
|
72
68
|
if (event.audio) {
|
|
73
|
-
|
|
69
|
+
const audio = itemFromSingleOrMultiple(event.audio);
|
|
70
|
+
if (!audio) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._playBuffer(audio);
|
|
74
74
|
}
|
|
75
75
|
else if (event.melodies) {
|
|
76
|
-
const melody =
|
|
76
|
+
const melody = itemFromArray(event.melodies);
|
|
77
|
+
if (!melody) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
77
80
|
if (melody.melodies.length) {
|
|
78
81
|
await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
|
|
79
82
|
}
|
|
@@ -82,12 +85,15 @@ class SoundsInstance {
|
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
else if (event.notes) {
|
|
85
|
-
const note =
|
|
88
|
+
const note = itemFromArray(event.notes);
|
|
89
|
+
if (!note) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
86
92
|
await this._playNote([note], defaultNoteIndex, false);
|
|
87
93
|
}
|
|
88
94
|
})();
|
|
89
95
|
};
|
|
90
|
-
|
|
96
|
+
executeOnSingleOrMultiple(event.event, item => {
|
|
91
97
|
this._engine.addEventListener(item, cb);
|
|
92
98
|
});
|
|
93
99
|
}
|
|
@@ -102,7 +108,7 @@ class SoundsInstance {
|
|
|
102
108
|
}
|
|
103
109
|
await audioContext.close();
|
|
104
110
|
container.audioContext = undefined;
|
|
105
|
-
this._engine.dispatchEvent(
|
|
111
|
+
this._engine.dispatchEvent(SoundsEventType.mute, { container: this._container });
|
|
106
112
|
};
|
|
107
113
|
this._playBuffer = audio => {
|
|
108
114
|
const audioBuffer = this._audioMap.get(audio.source);
|
|
@@ -161,19 +167,15 @@ class SoundsInstance {
|
|
|
161
167
|
if (!note) {
|
|
162
168
|
return;
|
|
163
169
|
}
|
|
164
|
-
const value = note.value
|
|
165
|
-
const promises = (0, engine_1.executeOnSingleOrMultiple)(value, async (_, idx) => {
|
|
170
|
+
const value = note.value, promises = executeOnSingleOrMultiple(value, async (_, idx) => {
|
|
166
171
|
return this._playNoteValue(notes, noteIdx, idx);
|
|
167
172
|
});
|
|
168
|
-
await (
|
|
173
|
+
await (isArray(promises) ? Promise.allSettled(promises) : promises);
|
|
169
174
|
const indexOffset = 1;
|
|
170
175
|
let nextNoteIdx = noteIdx + indexOffset;
|
|
171
176
|
if (loop && nextNoteIdx >= notes.length) {
|
|
172
177
|
nextNoteIdx = nextNoteIdx % notes.length;
|
|
173
178
|
}
|
|
174
|
-
if (this._container.muted) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
179
|
await this._playNote(notes, nextNoteIdx, loop);
|
|
178
180
|
};
|
|
179
181
|
this._playNoteValue = async (notes, noteIdx, valueIdx) => {
|
|
@@ -181,16 +183,19 @@ class SoundsInstance {
|
|
|
181
183
|
if (!note) {
|
|
182
184
|
return;
|
|
183
185
|
}
|
|
184
|
-
const value =
|
|
186
|
+
const value = itemFromSingleOrMultiple(note.value, valueIdx, true);
|
|
187
|
+
if (!value) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
185
190
|
try {
|
|
186
|
-
const freq =
|
|
187
|
-
if (!
|
|
191
|
+
const freq = getNoteFrequency(value);
|
|
192
|
+
if (!isNumber(freq)) {
|
|
188
193
|
return;
|
|
189
194
|
}
|
|
190
195
|
await this._playFrequency(freq, note.duration);
|
|
191
196
|
}
|
|
192
197
|
catch (e) {
|
|
193
|
-
|
|
198
|
+
getLogger().error(e);
|
|
194
199
|
}
|
|
195
200
|
};
|
|
196
201
|
this._removeAudioSource = source => {
|
|
@@ -204,16 +209,12 @@ class SoundsInstance {
|
|
|
204
209
|
if (!soundsOptions) {
|
|
205
210
|
return;
|
|
206
211
|
}
|
|
207
|
-
const audioContext = this._getAudioContext();
|
|
208
|
-
if (!this._audioSources) {
|
|
209
|
-
this._audioSources = [];
|
|
210
|
-
}
|
|
211
|
-
const gain = audioContext.createGain();
|
|
212
|
+
const audioContext = this._getAudioContext(), gain = audioContext.createGain();
|
|
212
213
|
gain.connect(audioContext.destination);
|
|
213
|
-
gain.gain.value = soundsOptions.volume.value /
|
|
214
|
+
gain.gain.value = soundsOptions.volume.value / percentDenominator;
|
|
214
215
|
this._gain = gain;
|
|
215
216
|
this._initEvents();
|
|
216
|
-
this._engine.dispatchEvent(
|
|
217
|
+
this._engine.dispatchEvent(SoundsEventType.unmute, { container: this._container });
|
|
217
218
|
};
|
|
218
219
|
this._updateMuteIcons = () => {
|
|
219
220
|
const container = this._container, soundsOptions = container.actualOptions.sounds;
|
|
@@ -231,11 +232,11 @@ class SoundsInstance {
|
|
|
231
232
|
this._updateMuteStatus = async () => {
|
|
232
233
|
const container = this._container, audioContext = this._getAudioContext();
|
|
233
234
|
if (container.muted) {
|
|
234
|
-
await audioContext
|
|
235
|
+
await audioContext.suspend();
|
|
235
236
|
await this._mute();
|
|
236
237
|
}
|
|
237
238
|
else {
|
|
238
|
-
await audioContext
|
|
239
|
+
await audioContext.resume();
|
|
239
240
|
this._unmute();
|
|
240
241
|
this._playMuteSound();
|
|
241
242
|
}
|
|
@@ -245,7 +246,7 @@ class SoundsInstance {
|
|
|
245
246
|
if (!soundsOptions?.enable) {
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
|
-
|
|
249
|
+
clamp(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
|
|
249
250
|
let stateChanged = false;
|
|
250
251
|
if (this._volume <= minVolume && !container.muted) {
|
|
251
252
|
this._volume = 0;
|
|
@@ -261,7 +262,7 @@ class SoundsInstance {
|
|
|
261
262
|
await this._updateMuteStatus();
|
|
262
263
|
}
|
|
263
264
|
if (this._gain?.gain) {
|
|
264
|
-
this._gain.gain.value = this._volume /
|
|
265
|
+
this._gain.gain.value = this._volume / percentDenominator;
|
|
265
266
|
}
|
|
266
267
|
};
|
|
267
268
|
this._container = container;
|
|
@@ -275,19 +276,19 @@ class SoundsInstance {
|
|
|
275
276
|
if (!soundsOptions?.enable) {
|
|
276
277
|
return;
|
|
277
278
|
}
|
|
278
|
-
if (soundsOptions.autoPlay &&
|
|
279
|
+
if (soundsOptions.autoPlay && isWindowMuted()) {
|
|
279
280
|
const firstClickHandler = () => {
|
|
280
|
-
removeEventListener(
|
|
281
|
-
removeEventListener(
|
|
282
|
-
|
|
281
|
+
removeEventListener(mouseDownEvent, firstClickHandler);
|
|
282
|
+
removeEventListener(touchStartEvent, firstClickHandler);
|
|
283
|
+
unmuteWindow();
|
|
283
284
|
void this.unmute();
|
|
284
285
|
};
|
|
285
286
|
const listenerOptions = {
|
|
286
287
|
capture: true,
|
|
287
288
|
once: true,
|
|
288
289
|
};
|
|
289
|
-
addEventListener(
|
|
290
|
-
addEventListener(
|
|
290
|
+
addEventListener(mouseDownEvent, firstClickHandler, listenerOptions);
|
|
291
|
+
addEventListener(touchStartEvent, firstClickHandler, listenerOptions);
|
|
291
292
|
}
|
|
292
293
|
this._volume = soundsOptions.volume.value;
|
|
293
294
|
const events = soundsOptions.events;
|
|
@@ -296,7 +297,7 @@ class SoundsInstance {
|
|
|
296
297
|
if (!event.audio) {
|
|
297
298
|
continue;
|
|
298
299
|
}
|
|
299
|
-
const promises =
|
|
300
|
+
const promises = executeOnSingleOrMultiple(event.audio, async (audio) => {
|
|
300
301
|
const response = await fetch(audio.source);
|
|
301
302
|
if (!response.ok) {
|
|
302
303
|
return;
|
|
@@ -328,7 +329,7 @@ class SoundsInstance {
|
|
|
328
329
|
right: canvas.offsetLeft + canvas.offsetWidth,
|
|
329
330
|
}, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10, toggleMute = async () => {
|
|
330
331
|
await this.toggleMute();
|
|
331
|
-
}, enableIcons = soundsOptions.icons.enable, display = enableIcons ?
|
|
332
|
+
}, enableIcons = soundsOptions.icons.enable, display = enableIcons ? ImageDisplay.Block : ImageDisplay.None;
|
|
332
333
|
this._muteImg = initImage({
|
|
333
334
|
container,
|
|
334
335
|
options,
|
|
@@ -343,7 +344,7 @@ class SoundsInstance {
|
|
|
343
344
|
container,
|
|
344
345
|
options,
|
|
345
346
|
pos,
|
|
346
|
-
display:
|
|
347
|
+
display: ImageDisplay.None,
|
|
347
348
|
iconOptions: unmute,
|
|
348
349
|
margin,
|
|
349
350
|
rightOffsets: [volumeDown.width, volumeUp.width],
|
|
@@ -373,7 +374,7 @@ class SoundsInstance {
|
|
|
373
374
|
await this.volumeUp();
|
|
374
375
|
},
|
|
375
376
|
});
|
|
376
|
-
if (!
|
|
377
|
+
if (!isWindowMuted() && soundsOptions.autoPlay) {
|
|
377
378
|
await this.unmute();
|
|
378
379
|
}
|
|
379
380
|
}
|
|
@@ -419,10 +420,7 @@ class SoundsInstance {
|
|
|
419
420
|
}
|
|
420
421
|
_getAudioContext() {
|
|
421
422
|
const container = this._container;
|
|
422
|
-
|
|
423
|
-
container.audioContext = new AudioContext();
|
|
424
|
-
}
|
|
423
|
+
container.audioContext ??= new AudioContext();
|
|
425
424
|
return container.audioContext;
|
|
426
425
|
}
|
|
427
426
|
}
|
|
428
|
-
exports.SoundsInstance = SoundsInstance;
|
package/cjs/SoundsPlugin.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Sounds_js_1 = require("./Options/Classes/Sounds.js");
|
|
6
|
-
const SoundsInstance_js_1 = require("./SoundsInstance.js");
|
|
7
|
-
const utils_js_1 = require("./utils.js");
|
|
1
|
+
import { mouseDownEvent, touchStartEvent, } from "@tsparticles/engine";
|
|
2
|
+
import { Sounds } from "./Options/Classes/Sounds.js";
|
|
3
|
+
import { SoundsInstance } from "./SoundsInstance.js";
|
|
4
|
+
import { unmuteWindow } from "./utils.js";
|
|
8
5
|
const generalFirstClickHandler = () => {
|
|
9
|
-
removeEventListener(
|
|
10
|
-
removeEventListener(
|
|
11
|
-
|
|
6
|
+
removeEventListener(mouseDownEvent, generalFirstClickHandler);
|
|
7
|
+
removeEventListener(touchStartEvent, generalFirstClickHandler);
|
|
8
|
+
unmuteWindow();
|
|
12
9
|
};
|
|
13
|
-
class SoundsPlugin {
|
|
10
|
+
export class SoundsPlugin {
|
|
14
11
|
constructor(engine) {
|
|
15
12
|
this.id = "sounds";
|
|
16
13
|
this._engine = engine;
|
|
@@ -18,11 +15,11 @@ class SoundsPlugin {
|
|
|
18
15
|
capture: true,
|
|
19
16
|
once: true,
|
|
20
17
|
};
|
|
21
|
-
addEventListener(
|
|
22
|
-
addEventListener(
|
|
18
|
+
addEventListener(mouseDownEvent, generalFirstClickHandler, listenerOptions);
|
|
19
|
+
addEventListener(touchStartEvent, generalFirstClickHandler, listenerOptions);
|
|
23
20
|
}
|
|
24
21
|
getPlugin(container) {
|
|
25
|
-
return Promise.resolve(new
|
|
22
|
+
return Promise.resolve(new SoundsInstance(container, this._engine));
|
|
26
23
|
}
|
|
27
24
|
loadOptions(options, source) {
|
|
28
25
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
@@ -30,7 +27,7 @@ class SoundsPlugin {
|
|
|
30
27
|
}
|
|
31
28
|
let soundsOptions = options.sounds;
|
|
32
29
|
if (soundsOptions?.load === undefined) {
|
|
33
|
-
options.sounds = soundsOptions = new
|
|
30
|
+
options.sounds = soundsOptions = new Sounds();
|
|
34
31
|
}
|
|
35
32
|
soundsOptions.load(source?.sounds);
|
|
36
33
|
}
|
|
@@ -38,4 +35,3 @@ class SoundsPlugin {
|
|
|
38
35
|
return options?.sounds?.enable ?? false;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
exports.SoundsPlugin = SoundsPlugin;
|
package/cjs/enums.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImageDisplay = exports.SoundsEventType = void 0;
|
|
4
|
-
var SoundsEventType;
|
|
1
|
+
export var SoundsEventType;
|
|
5
2
|
(function (SoundsEventType) {
|
|
6
3
|
SoundsEventType["mute"] = "soundsMuted";
|
|
7
4
|
SoundsEventType["unmute"] = "soundsUnmuted";
|
|
8
|
-
})(SoundsEventType || (
|
|
9
|
-
var ImageDisplay;
|
|
5
|
+
})(SoundsEventType || (SoundsEventType = {}));
|
|
6
|
+
export var ImageDisplay;
|
|
10
7
|
(function (ImageDisplay) {
|
|
11
8
|
ImageDisplay["Block"] = "block";
|
|
12
9
|
ImageDisplay["None"] = "none";
|
|
13
|
-
})(ImageDisplay || (
|
|
10
|
+
})(ImageDisplay || (ImageDisplay = {}));
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
await engine.addPlugin(new SoundsPlugin_js_1.SoundsPlugin(engine), refresh);
|
|
1
|
+
export function loadSoundsPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { SoundsPlugin } = await import("./SoundsPlugin.js");
|
|
5
|
+
e.addPlugin(new SoundsPlugin(engine));
|
|
6
|
+
});
|
|
8
7
|
}
|
package/cjs/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/utils.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unmuteWindow = exports.isWindowMuted = void 0;
|
|
4
|
-
exports.getNoteFrequency = getNoteFrequency;
|
|
5
1
|
const notes = new Map();
|
|
6
2
|
notes.set("C", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);
|
|
7
3
|
notes.set("Db", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);
|
|
@@ -16,23 +12,21 @@ notes.set("A", [27.5, 55.0, 110.0, 220.0, 440.0, 880.0, 1760.0, 3520.0, 7040.0])
|
|
|
16
12
|
notes.set("Bb", [29.14, 58.27, 116.54, 233.08, 466.16, 932.33, 1864.66, 3729.31, 7458.62]);
|
|
17
13
|
notes.set("B", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);
|
|
18
14
|
notes.set("pause", [0]);
|
|
19
|
-
function getNoteFrequency(note) {
|
|
15
|
+
export function getNoteFrequency(note) {
|
|
20
16
|
const regex = /(([A-G]b?)(\d))|pause/i, result = regex.exec(note), groupKey = 2, defaultMatchKey = 0, innerGroupKey = 3;
|
|
21
17
|
if (!result?.length) {
|
|
22
18
|
return;
|
|
23
19
|
}
|
|
24
|
-
const noteKey = result[groupKey]
|
|
20
|
+
const noteKey = result[groupKey] ?? result[defaultMatchKey], noteItem = notes.get(noteKey);
|
|
25
21
|
if (!noteItem) {
|
|
26
22
|
return;
|
|
27
23
|
}
|
|
28
|
-
return noteItem[parseInt(result[innerGroupKey]
|
|
24
|
+
return noteItem[parseInt(result[innerGroupKey] ?? "0")];
|
|
29
25
|
}
|
|
30
26
|
let muted = true;
|
|
31
|
-
const isWindowMuted = () => {
|
|
27
|
+
export const isWindowMuted = () => {
|
|
32
28
|
return muted;
|
|
33
29
|
};
|
|
34
|
-
|
|
35
|
-
const unmuteWindow = () => {
|
|
30
|
+
export const unmuteWindow = () => {
|
|
36
31
|
muted = false;
|
|
37
32
|
};
|
|
38
|
-
exports.unmuteWindow = unmuteWindow;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_plugin_sounds"] = this["webpackChunk_tsparticles_plugin_sounds"] || []).push([["dist_browser_SoundsPlugin_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Options/Classes/Sounds.js"
|
|
21
|
+
/*!************************************************!*\
|
|
22
|
+
!*** ./dist/browser/Options/Classes/Sounds.js ***!
|
|
23
|
+
\************************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Sounds: () => (/* binding */ Sounds)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SoundsEvent_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SoundsEvent.js */ \"./dist/browser/Options/Classes/SoundsEvent.js\");\n/* harmony import */ var _SoundsIcons_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SoundsIcons.js */ \"./dist/browser/Options/Classes/SoundsIcons.js\");\n/* harmony import */ var _SoundsVolume_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SoundsVolume.js */ \"./dist/browser/Options/Classes/SoundsVolume.js\");\n\n\n\n\nclass Sounds {\n constructor() {\n this.autoPlay = true;\n this.enable = false;\n this.events = [];\n this.icons = new _SoundsIcons_js__WEBPACK_IMPORTED_MODULE_2__.SoundsIcons();\n this.volume = new _SoundsVolume_js__WEBPACK_IMPORTED_MODULE_3__.SoundsVolume();\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.autoPlay !== undefined) {\n this.autoPlay = data.autoPlay;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.events !== undefined) {\n this.events = data.events.map(t => {\n const event = new _SoundsEvent_js__WEBPACK_IMPORTED_MODULE_1__.SoundsEvent();\n event.load(t);\n return event;\n });\n }\n this.icons.load(data.icons);\n if (data.volume !== undefined) {\n this.volume.load(data.volume);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/Sounds.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Options/Classes/SoundsAudio.js"
|
|
31
|
+
/*!*****************************************************!*\
|
|
32
|
+
!*** ./dist/browser/Options/Classes/SoundsAudio.js ***!
|
|
33
|
+
\*****************************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsAudio: () => (/* binding */ SoundsAudio)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass SoundsAudio {\n constructor() {\n this.loop = false;\n this.source = \"\";\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isObject)(data)) {\n if (data.loop !== undefined) {\n this.loop = data.loop;\n }\n if (data.source !== undefined) {\n this.source = data.source;\n }\n } else {\n this.source = data;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsAudio.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/Options/Classes/SoundsEvent.js"
|
|
41
|
+
/*!*****************************************************!*\
|
|
42
|
+
!*** ./dist/browser/Options/Classes/SoundsEvent.js ***!
|
|
43
|
+
\*****************************************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsEvent: () => (/* binding */ SoundsEvent)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SoundsAudio_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SoundsAudio.js */ \"./dist/browser/Options/Classes/SoundsAudio.js\");\n/* harmony import */ var _SoundsMelody_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SoundsMelody.js */ \"./dist/browser/Options/Classes/SoundsMelody.js\");\n/* harmony import */ var _SoundsNote_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SoundsNote.js */ \"./dist/browser/Options/Classes/SoundsNote.js\");\n\n\n\n\nclass SoundsEvent {\n constructor() {\n this.event = [];\n this.notes = [];\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.event !== undefined) {\n this.event = data.event;\n }\n if (data.audio !== undefined) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isArray)(data.audio)) {\n this.audio = data.audio.map(s => {\n const tmp = new _SoundsAudio_js__WEBPACK_IMPORTED_MODULE_1__.SoundsAudio();\n tmp.load(s);\n return tmp;\n });\n } else {\n this.audio = new _SoundsAudio_js__WEBPACK_IMPORTED_MODULE_1__.SoundsAudio();\n this.audio.load(data.audio);\n }\n }\n if (data.notes !== undefined) {\n this.notes = data.notes.map(t => {\n const tmp = new _SoundsNote_js__WEBPACK_IMPORTED_MODULE_3__.SoundsNote();\n tmp.load(t);\n return tmp;\n });\n }\n if (data.melodies !== undefined) {\n this.melodies = data.melodies.map(t => {\n const tmp = new _SoundsMelody_js__WEBPACK_IMPORTED_MODULE_2__.SoundsMelody();\n tmp.load(t);\n return tmp;\n });\n }\n if (data.filter) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isString)(data.filter)) {\n const filterFunc = globalThis[data.filter];\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isFunction)(filterFunc)) {\n this.filter = filterFunc;\n }\n } else {\n this.filter = data.filter;\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsEvent.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ },
|
|
49
|
+
|
|
50
|
+
/***/ "./dist/browser/Options/Classes/SoundsIcon.js"
|
|
51
|
+
/*!****************************************************!*\
|
|
52
|
+
!*** ./dist/browser/Options/Classes/SoundsIcon.js ***!
|
|
53
|
+
\****************************************************/
|
|
54
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
55
|
+
|
|
56
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsIcon: () => (/* binding */ SoundsIcon)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass SoundsIcon {\n constructor() {\n this.width = 24;\n this.height = 24;\n this.style = \"\";\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.path !== undefined) {\n this.path = data.path;\n }\n if (data.svg !== undefined) {\n this.svg = data.svg;\n }\n if (data.width !== undefined) {\n this.width = data.width;\n }\n if (data.height !== undefined) {\n this.height = data.height;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsIcon.js?\n}");
|
|
57
|
+
|
|
58
|
+
/***/ },
|
|
59
|
+
|
|
60
|
+
/***/ "./dist/browser/Options/Classes/SoundsIcons.js"
|
|
61
|
+
/*!*****************************************************!*\
|
|
62
|
+
!*** ./dist/browser/Options/Classes/SoundsIcons.js ***!
|
|
63
|
+
\*****************************************************/
|
|
64
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
65
|
+
|
|
66
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsIcons: () => (/* binding */ SoundsIcons)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SoundsIcon.js */ \"./dist/browser/Options/Classes/SoundsIcon.js\");\n\n\nclass SoundsIcons {\n constructor() {\n this.mute = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_1__.SoundsIcon();\n this.unmute = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_1__.SoundsIcon();\n this.volumeDown = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_1__.SoundsIcon();\n this.volumeUp = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_1__.SoundsIcon();\n this.enable = false;\n this.mute.svg = `<?xml version=\"1.0\"?>\n<svg baseProfile=\"tiny\" height=\"24px\" version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24px\"\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <g id=\"Layer_1\">\n <path fill=\"#fff\" d=\"M19.707,5.293c-0.391-0.391-1.023-0.391-1.414,0l-1.551,1.551c-0.345-0.688-0.987-1.02-1.604-1.02c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C10.357,8.561,8.904,9,8,9c-1.654,0-3,1.346-3,3v2c0,1.237,0.754,2.302,1.826,2.76l-1.533,1.533c-0.391,0.391-0.391,1.023,0,1.414C5.488,19.902,5.744,20,6,20s0.512-0.098,0.707-0.293l2.527-2.527c0.697,0.174,1.416,0.455,1.875,0.762l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C16.035,20.176,17,19.495,17,18V9.414l2.707-2.707C20.098,6.316,20.098,5.684,19.707,5.293z M14.891,7.941c0.038-0.025,0.073-0.046,0.104-0.062C14.998,7.914,15,7.954,15,8v1.293l-2,2V9.202L14.891,7.941z M7,12c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v2.439l-2.83,2.83C8.757,15.046,8.356,15,8,15c-0.552,0-1-0.448-1-1V12z M10.301,15.406L12,13.707v2.439C11.519,15.859,10.925,15.604,10.301,15.406z M14.994,18.12c-0.03-0.016-0.065-0.036-0.104-0.062L13,16.798v-4.091l2-2V18C15,18.046,14.998,18.086,14.994,18.12z\"/>\n </g>\n</svg>`;\n this.unmute.svg = `<?xml version=\"1.0\"?>\n<svg baseProfile=\"tiny\" height=\"24px\" version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24px\"\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <g id=\"Layer_1\">\n <path fill=\"#fff\" d=\"M17.138,5.824c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C12.357,8.561,10.904,9,10,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C18.035,20.176,19,19.495,19,18V8C19,6.505,18.035,5.824,17.138,5.824z M14,16.146C12.907,15.495,11.211,15,10,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146V16.146z M17,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L15,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C16.998,7.914,17,7.954,17,8V18z\"/>\n </g>\n</svg>`;\n this.volumeDown.svg = `<?xml version=\"1.0\"?>\n<svg baseProfile=\"tiny\" height=\"24px\" version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24px\"\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <g id=\"Layer_1\">\n <path fill=\"#fff\" d=\"M15.138,5.824c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C10.357,8.561,8.904,9,8,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C16.035,20.176,17,19.495,17,18V8C17,6.505,16.035,5.824,15.138,5.824z M8,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v6.293C10.907,15.495,9.211,15,8,15z M15,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L13,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C14.998,7.914,15,7.954,15,8V18z\"/>\n <path fill=\"#fff\" d=\"M18.292,10.294c-0.39,0.391-0.39,1.023,0.002,1.414c0.345,0.345,0.535,0.803,0.535,1.291c0,0.489-0.19,0.948-0.536,1.294c-0.391,0.39-0.391,1.023,0,1.414C18.488,15.902,18.744,16,19,16s0.512-0.098,0.707-0.293c0.724-0.723,1.122-1.685,1.122-2.708s-0.398-1.984-1.123-2.707C19.317,9.903,18.683,9.901,18.292,10.294z\"/>\n </g>\n</svg>`;\n this.volumeUp.svg = `<?xml version=\"1.0\"?>\n<svg baseProfile=\"tiny\" height=\"24px\" version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24px\"\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <g id=\"Layer_1\">\n <path fill=\"#fff\" d=\"M16.706,10.292c-0.389-0.389-1.023-0.391-1.414,0.002c-0.39,0.391-0.39,1.023,0.002,1.414c0.345,0.345,0.535,0.803,0.535,1.291c0,0.489-0.19,0.948-0.536,1.294c-0.391,0.39-0.391,1.023,0,1.414C15.488,15.902,15.744,16,16,16s0.512-0.098,0.707-0.293c0.724-0.723,1.122-1.685,1.122-2.708S17.431,11.015,16.706,10.292z\"/>\n <path fill=\"#fff\" d=\"M18.706,8.292c-0.391-0.389-1.023-0.39-1.414,0.002c-0.39,0.391-0.39,1.024,0.002,1.414c0.879,0.877,1.363,2.044,1.364,3.287c0.001,1.246-0.484,2.417-1.365,3.298c-0.391,0.391-0.391,1.023,0,1.414C17.488,17.902,17.744,18,18,18s0.512-0.098,0.707-0.293c1.259-1.259,1.952-2.933,1.951-4.713C20.657,11.217,19.964,9.547,18.706,8.292z\"/>\n <path fill=\"#fff\" d=\"M20.706,6.292c-0.391-0.389-1.023-0.39-1.414,0.002c-0.39,0.391-0.39,1.024,0.002,1.414c1.412,1.409,2.191,3.285,2.192,5.284c0.002,2.002-0.777,3.885-2.193,5.301c-0.391,0.391-0.391,1.023,0,1.414C19.488,19.902,19.744,20,20,20s0.512-0.098,0.707-0.293c1.794-1.794,2.781-4.18,2.779-6.717C23.485,10.457,22.497,8.078,20.706,6.292z\"/>\n <path fill=\"#fff\" d=\"M12.138,5.824c-0.449,0-0.905,0.152-1.356,0.453L8.109,8.059C7.357,8.561,5.904,9,5,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C13.035,20.176,14,19.495,14,18V8C14,6.505,13.035,5.824,12.138,5.824z M5,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v6.293C7.907,15.495,6.211,15,5,15z M12,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L10,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C11.998,7.914,12,7.954,12,8V18z\"/>\n </g>\n</svg>`;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n this.mute.load(data.mute);\n this.unmute.load(data.unmute);\n this.volumeDown.load(data.volumeDown);\n this.volumeUp.load(data.volumeUp);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsIcons.js?\n}");
|
|
67
|
+
|
|
68
|
+
/***/ },
|
|
69
|
+
|
|
70
|
+
/***/ "./dist/browser/Options/Classes/SoundsMelody.js"
|
|
71
|
+
/*!******************************************************!*\
|
|
72
|
+
!*** ./dist/browser/Options/Classes/SoundsMelody.js ***!
|
|
73
|
+
\******************************************************/
|
|
74
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
75
|
+
|
|
76
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsMelody: () => (/* binding */ SoundsMelody)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SoundsNote_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SoundsNote.js */ \"./dist/browser/Options/Classes/SoundsNote.js\");\n\n\nclass SoundsMelody {\n constructor() {\n this.loop = false;\n this.melodies = [];\n this.notes = [];\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.loop !== undefined) {\n this.loop = data.loop;\n }\n if (data.melodies !== undefined) {\n this.melodies = data.melodies.map(s => {\n const tmp = new SoundsMelody();\n tmp.load(s);\n return tmp;\n });\n }\n if (data.notes !== undefined) {\n this.notes = data.notes.map(s => {\n const tmp = new _SoundsNote_js__WEBPACK_IMPORTED_MODULE_1__.SoundsNote();\n tmp.load(s);\n return tmp;\n });\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsMelody.js?\n}");
|
|
77
|
+
|
|
78
|
+
/***/ },
|
|
79
|
+
|
|
80
|
+
/***/ "./dist/browser/Options/Classes/SoundsNote.js"
|
|
81
|
+
/*!****************************************************!*\
|
|
82
|
+
!*** ./dist/browser/Options/Classes/SoundsNote.js ***!
|
|
83
|
+
\****************************************************/
|
|
84
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
85
|
+
|
|
86
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsNote: () => (/* binding */ SoundsNote)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass SoundsNote {\n constructor() {\n this.duration = 500;\n this.value = [];\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.duration !== undefined) {\n this.duration = data.duration;\n }\n if (data.value !== undefined) {\n this.value = data.value;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsNote.js?\n}");
|
|
87
|
+
|
|
88
|
+
/***/ },
|
|
89
|
+
|
|
90
|
+
/***/ "./dist/browser/Options/Classes/SoundsVolume.js"
|
|
91
|
+
/*!******************************************************!*\
|
|
92
|
+
!*** ./dist/browser/Options/Classes/SoundsVolume.js ***!
|
|
93
|
+
\******************************************************/
|
|
94
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
95
|
+
|
|
96
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsVolume: () => (/* binding */ SoundsVolume)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass SoundsVolume {\n constructor() {\n this.value = 100;\n this.max = 100;\n this.min = 0;\n this.step = 10;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isObject)(data)) {\n if (data.max !== undefined) {\n this.max = data.max;\n }\n if (data.min !== undefined) {\n this.min = data.min;\n }\n if (data.step !== undefined) {\n this.step = data.step;\n }\n if (data.value !== undefined) {\n this.value = data.value;\n }\n } else {\n this.value = data;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsVolume.js?\n}");
|
|
97
|
+
|
|
98
|
+
/***/ },
|
|
99
|
+
|
|
100
|
+
/***/ "./dist/browser/SoundsInstance.js"
|
|
101
|
+
/*!****************************************!*\
|
|
102
|
+
!*** ./dist/browser/SoundsInstance.js ***!
|
|
103
|
+
\****************************************/
|
|
104
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
105
|
+
|
|
106
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsInstance: () => (/* binding */ SoundsInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./enums.js */ \"./dist/browser/enums.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\n\nconst zIndexOffset = 1,\n rightOffset = 1,\n minVolume = 0;\nfunction initImage(data) {\n const img = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().createElement(\"img\"),\n {\n clickCb,\n container,\n display,\n iconOptions,\n margin,\n options,\n pos,\n rightOffsets\n } = data,\n {\n width,\n path,\n style,\n svg\n } = iconOptions,\n defaultAccumulator = 0;\n setIconStyle(img, pos.top + margin, pos.right - (margin * (rightOffsets.length + rightOffset) + width + rightOffsets.reduce((a, b) => a + b, defaultAccumulator)), display, options.fullScreen.zIndex + zIndexOffset, width, margin, style);\n img.src = path ?? (svg ? `data:image/svg+xml;base64,${btoa(svg)}` : \"\");\n const parent = container.canvas.element?.parentNode ?? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().body;\n parent.append(img);\n img.addEventListener(\"click\", () => {\n void clickCb();\n });\n return img;\n}\nfunction removeImage(image) {\n if (!image) {\n return;\n }\n image.remove();\n}\nfunction setIconStyle(icon, top, left, display, zIndex, width, margin, style) {\n icon.style.userSelect = \"none\";\n icon.style.position = \"absolute\";\n icon.style.top = `${(top + margin).toString()}px`;\n icon.style.left = `${(left - margin - width).toString()}px`;\n icon.style.display = display;\n icon.style.zIndex = (zIndex + zIndexOffset).toString();\n icon.style.cssText += style;\n}\nclass SoundsInstance {\n constructor(container, engine) {\n this._addBuffer = audioCtx => {\n const buffer = audioCtx.createBufferSource();\n this._audioSources.push(buffer);\n return buffer;\n };\n this._addOscillator = audioCtx => {\n const oscillator = audioCtx.createOscillator();\n this._audioSources.push(oscillator);\n return oscillator;\n };\n this._initEvents = () => {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable || !container.canvas.element) {\n return;\n }\n for (const event of soundsOptions.events) {\n const cb = args => {\n void (async () => {\n const filterNotValid = event.filter && !event.filter(args);\n if (this._container !== args.container) {\n return;\n }\n if (!!this._container.muted || this._container.destroyed) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(event.event, item => {\n this._engine.removeEventListener(item, cb);\n });\n return;\n }\n if (filterNotValid) {\n return;\n }\n const defaultNoteIndex = 0;\n if (event.audio) {\n const audio = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(event.audio);\n if (!audio) {\n return;\n }\n this._playBuffer(audio);\n } else if (event.melodies) {\n const melody = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(event.melodies);\n if (!melody) {\n return;\n }\n if (melody.melodies.length) {\n await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));\n } else {\n await this._playNote(melody.notes, defaultNoteIndex, melody.loop);\n }\n } else if (event.notes) {\n const note = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(event.notes);\n if (!note) {\n return;\n }\n await this._playNote([note], defaultNoteIndex, false);\n }\n })();\n };\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(event.event, item => {\n this._engine.addEventListener(item, cb);\n });\n }\n };\n this._mute = async () => {\n const container = this._container,\n audioContext = this._getAudioContext();\n for (const source of this._audioSources) {\n this._removeAudioSource(source);\n }\n if (this._gain) {\n this._gain.disconnect();\n }\n await audioContext.close();\n container.audioContext = undefined;\n this._engine.dispatchEvent(_enums_js__WEBPACK_IMPORTED_MODULE_1__.SoundsEventType.mute, {\n container: this._container\n });\n };\n this._playBuffer = audio => {\n const audioBuffer = this._audioMap.get(audio.source);\n if (!audioBuffer) {\n return;\n }\n const audioCtx = this._container.audioContext;\n if (!audioCtx) {\n return;\n }\n const source = this._addBuffer(audioCtx);\n source.loop = audio.loop;\n source.buffer = audioBuffer;\n source.connect(this._gain ?? audioCtx.destination);\n source.start();\n };\n this._playFrequency = async (frequency, duration) => {\n if (!this._gain || this._container.muted) {\n return;\n }\n const audioContext = this._getAudioContext(),\n oscillator = this._addOscillator(audioContext);\n oscillator.connect(this._gain);\n oscillator.type = \"sine\";\n oscillator.frequency.value = frequency;\n oscillator.start();\n return new Promise(resolve => {\n setTimeout(() => {\n this._removeAudioSource(oscillator);\n resolve();\n }, duration);\n });\n };\n this._playMuteSound = () => {\n if (this._container.muted) {\n return;\n }\n const audioContext = this._getAudioContext(),\n gain = audioContext.createGain();\n gain.connect(audioContext.destination);\n gain.gain.value = 0;\n const oscillator = audioContext.createOscillator();\n oscillator.connect(gain);\n oscillator.type = \"sine\";\n oscillator.frequency.value = 1;\n oscillator.start();\n setTimeout(() => {\n oscillator.stop();\n oscillator.disconnect();\n gain.disconnect();\n });\n };\n this._playNote = async (notes, noteIdx, loop) => {\n if (this._container.muted) {\n return;\n }\n const note = notes[noteIdx];\n if (!note) {\n return;\n }\n const value = note.value,\n promises = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(value, async (_, idx) => {\n return this._playNoteValue(notes, noteIdx, idx);\n });\n await ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isArray)(promises) ? Promise.allSettled(promises) : promises);\n const indexOffset = 1;\n let nextNoteIdx = noteIdx + indexOffset;\n if (loop && nextNoteIdx >= notes.length) {\n nextNoteIdx = nextNoteIdx % notes.length;\n }\n await this._playNote(notes, nextNoteIdx, loop);\n };\n this._playNoteValue = async (notes, noteIdx, valueIdx) => {\n const note = notes[noteIdx];\n if (!note) {\n return;\n }\n const value = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(note.value, valueIdx, true);\n if (!value) {\n return;\n }\n try {\n const freq = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getNoteFrequency)(value);\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNumber)(freq)) {\n return;\n }\n await this._playFrequency(freq, note.duration);\n } catch (e) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLogger)().error(e);\n }\n };\n this._removeAudioSource = source => {\n source.stop();\n source.disconnect();\n const deleteCount = 1;\n this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);\n };\n this._unmute = () => {\n const container = this._container,\n options = container.actualOptions,\n soundsOptions = options.sounds;\n if (!soundsOptions) {\n return;\n }\n const audioContext = this._getAudioContext(),\n gain = audioContext.createGain();\n gain.connect(audioContext.destination);\n gain.gain.value = soundsOptions.volume.value / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n this._gain = gain;\n this._initEvents();\n this._engine.dispatchEvent(_enums_js__WEBPACK_IMPORTED_MODULE_1__.SoundsEventType.unmute, {\n container: this._container\n });\n };\n this._updateMuteIcons = () => {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable || !soundsOptions.icons.enable) {\n return;\n }\n const muteImg = this._muteImg,\n unmuteImg = this._unmuteImg;\n if (muteImg) {\n muteImg.style.display = container.muted ? \"block\" : \"none\";\n }\n if (unmuteImg) {\n unmuteImg.style.display = container.muted ? \"none\" : \"block\";\n }\n };\n this._updateMuteStatus = async () => {\n const container = this._container,\n audioContext = this._getAudioContext();\n if (container.muted) {\n await audioContext.suspend();\n await this._mute();\n } else {\n await audioContext.resume();\n this._unmute();\n this._playMuteSound();\n }\n };\n this._updateVolume = async () => {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);\n let stateChanged = false;\n if (this._volume <= minVolume && !container.muted) {\n this._volume = 0;\n container.muted = true;\n stateChanged = true;\n } else if (this._volume > minVolume && container.muted) {\n container.muted = false;\n stateChanged = true;\n }\n if (stateChanged) {\n this._updateMuteIcons();\n await this._updateMuteStatus();\n }\n if (this._gain?.gain) {\n this._gain.gain.value = this._volume / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n };\n this._container = container;\n this._engine = engine;\n this._volume = 0;\n this._audioSources = [];\n this._audioMap = new Map();\n }\n async init() {\n const container = this._container,\n options = container.actualOptions,\n soundsOptions = options.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n if (soundsOptions.autoPlay && (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.isWindowMuted)()) {\n const firstClickHandler = () => {\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, firstClickHandler);\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, firstClickHandler);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.unmuteWindow)();\n void this.unmute();\n };\n const listenerOptions = {\n capture: true,\n once: true\n };\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, firstClickHandler, listenerOptions);\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, firstClickHandler, listenerOptions);\n }\n this._volume = soundsOptions.volume.value;\n const events = soundsOptions.events;\n this._audioMap = new Map();\n for (const event of events) {\n if (!event.audio) {\n continue;\n }\n const promises = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(event.audio, async audio => {\n const response = await fetch(audio.source);\n if (!response.ok) {\n return;\n }\n const arrayBuffer = await response.arrayBuffer(),\n audioContext = this._getAudioContext(),\n audioBuffer = await audioContext.decodeAudioData(arrayBuffer);\n this._audioMap.set(audio.source, audioBuffer);\n });\n if (promises instanceof Promise) {\n await promises;\n } else {\n await Promise.allSettled(promises);\n }\n }\n }\n async mute() {\n if (!this._container.muted) {\n await this.toggleMute();\n }\n }\n async start() {\n const container = this._container,\n options = container.actualOptions,\n soundsOptions = options.sounds;\n if (!soundsOptions?.enable || !container.canvas.element) {\n return;\n }\n container.muted = true;\n const canvas = container.canvas.element,\n pos = {\n top: canvas.offsetTop,\n right: canvas.offsetLeft + canvas.offsetWidth\n },\n {\n mute,\n unmute,\n volumeDown,\n volumeUp\n } = soundsOptions.icons,\n margin = 10,\n toggleMute = async () => {\n await this.toggleMute();\n },\n enableIcons = soundsOptions.icons.enable,\n display = enableIcons ? _enums_js__WEBPACK_IMPORTED_MODULE_1__.ImageDisplay.Block : _enums_js__WEBPACK_IMPORTED_MODULE_1__.ImageDisplay.None;\n this._muteImg = initImage({\n container,\n options,\n pos,\n display,\n iconOptions: mute,\n margin,\n rightOffsets: [volumeDown.width, volumeUp.width],\n clickCb: toggleMute\n });\n this._unmuteImg = initImage({\n container,\n options,\n pos,\n display: _enums_js__WEBPACK_IMPORTED_MODULE_1__.ImageDisplay.None,\n iconOptions: unmute,\n margin,\n rightOffsets: [volumeDown.width, volumeUp.width],\n clickCb: toggleMute\n });\n this._volumeDownImg = initImage({\n container,\n options,\n pos,\n display,\n iconOptions: volumeDown,\n margin,\n rightOffsets: [volumeUp.width],\n clickCb: async () => {\n await this.volumeDown();\n }\n });\n this._volumeUpImg = initImage({\n container,\n options,\n pos,\n display,\n iconOptions: volumeUp,\n margin,\n rightOffsets: [],\n clickCb: async () => {\n await this.volumeUp();\n }\n });\n if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.isWindowMuted)() && soundsOptions.autoPlay) {\n await this.unmute();\n }\n }\n stop() {\n this._container.muted = true;\n void (async () => {\n await this._mute();\n removeImage(this._muteImg);\n removeImage(this._unmuteImg);\n removeImage(this._volumeDownImg);\n removeImage(this._volumeUpImg);\n })();\n }\n async toggleMute() {\n const container = this._container;\n container.muted = !container.muted;\n this._updateMuteIcons();\n await this._updateMuteStatus();\n }\n async unmute() {\n if (this._container.muted) {\n await this.toggleMute();\n }\n }\n async volumeDown() {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n if (container.muted) {\n this._volume = 0;\n }\n this._volume -= soundsOptions.volume.step;\n await this._updateVolume();\n }\n async volumeUp() {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n this._volume += soundsOptions.volume.step;\n await this._updateVolume();\n }\n _getAudioContext() {\n const container = this._container;\n container.audioContext ??= new AudioContext();\n return container.audioContext;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/SoundsInstance.js?\n}");
|
|
107
|
+
|
|
108
|
+
/***/ },
|
|
109
|
+
|
|
110
|
+
/***/ "./dist/browser/SoundsPlugin.js"
|
|
111
|
+
/*!**************************************!*\
|
|
112
|
+
!*** ./dist/browser/SoundsPlugin.js ***!
|
|
113
|
+
\**************************************/
|
|
114
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
115
|
+
|
|
116
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsPlugin: () => (/* binding */ SoundsPlugin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Sounds_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Sounds.js */ \"./dist/browser/Options/Classes/Sounds.js\");\n/* harmony import */ var _SoundsInstance_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SoundsInstance.js */ \"./dist/browser/SoundsInstance.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\n\n\nconst generalFirstClickHandler = () => {\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, generalFirstClickHandler);\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, generalFirstClickHandler);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.unmuteWindow)();\n};\nclass SoundsPlugin {\n constructor(engine) {\n this.id = \"sounds\";\n this._engine = engine;\n const listenerOptions = {\n capture: true,\n once: true\n };\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, generalFirstClickHandler, listenerOptions);\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, generalFirstClickHandler, listenerOptions);\n }\n getPlugin(container) {\n return Promise.resolve(new _SoundsInstance_js__WEBPACK_IMPORTED_MODULE_2__.SoundsInstance(container, this._engine));\n }\n loadOptions(options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let soundsOptions = options.sounds;\n if (soundsOptions?.load === undefined) {\n options.sounds = soundsOptions = new _Options_Classes_Sounds_js__WEBPACK_IMPORTED_MODULE_1__.Sounds();\n }\n soundsOptions.load(source?.sounds);\n }\n needsPlugin(options) {\n return options?.sounds?.enable ?? false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/SoundsPlugin.js?\n}");
|
|
117
|
+
|
|
118
|
+
/***/ },
|
|
119
|
+
|
|
120
|
+
/***/ "./dist/browser/enums.js"
|
|
121
|
+
/*!*******************************!*\
|
|
122
|
+
!*** ./dist/browser/enums.js ***!
|
|
123
|
+
\*******************************/
|
|
124
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
125
|
+
|
|
126
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ImageDisplay: () => (/* binding */ ImageDisplay),\n/* harmony export */ SoundsEventType: () => (/* binding */ SoundsEventType)\n/* harmony export */ });\nvar SoundsEventType;\n(function (SoundsEventType) {\n SoundsEventType[\"mute\"] = \"soundsMuted\";\n SoundsEventType[\"unmute\"] = \"soundsUnmuted\";\n})(SoundsEventType || (SoundsEventType = {}));\nvar ImageDisplay;\n(function (ImageDisplay) {\n ImageDisplay[\"Block\"] = \"block\";\n ImageDisplay[\"None\"] = \"none\";\n})(ImageDisplay || (ImageDisplay = {}));\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/enums.js?\n}");
|
|
127
|
+
|
|
128
|
+
/***/ },
|
|
129
|
+
|
|
130
|
+
/***/ "./dist/browser/utils.js"
|
|
131
|
+
/*!*******************************!*\
|
|
132
|
+
!*** ./dist/browser/utils.js ***!
|
|
133
|
+
\*******************************/
|
|
134
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
135
|
+
|
|
136
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getNoteFrequency: () => (/* binding */ getNoteFrequency),\n/* harmony export */ isWindowMuted: () => (/* binding */ isWindowMuted),\n/* harmony export */ unmuteWindow: () => (/* binding */ unmuteWindow)\n/* harmony export */ });\nconst notes = new Map();\nnotes.set(\"C\", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);\nnotes.set(\"Db\", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);\nnotes.set(\"D\", [18.35, 36.71, 73.42, 146.83, 293.66, 587.33, 1174.66, 2349.32, 4698.63]);\nnotes.set(\"Eb\", [19.45, 38.89, 77.78, 155.56, 311.13, 622.25, 1244.51, 2489.02, 4978.03]);\nnotes.set(\"E\", [20.6, 41.2, 82.41, 164.81, 329.63, 659.25, 1318.51, 2637.02, 5274.04]);\nnotes.set(\"F\", [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83, 5587.65]);\nnotes.set(\"Gb\", [23.12, 46.25, 92.5, 185.0, 369.99, 739.99, 1479.98, 2959.96, 5919.91]);\nnotes.set(\"G\", [24.5, 49.0, 98.0, 196.0, 392.0, 783.99, 1567.98, 3135.96, 6271.93]);\nnotes.set(\"Ab\", [25.96, 51.91, 103.83, 207.65, 415.3, 830.61, 1661.22, 3322.44, 6644.88]);\nnotes.set(\"A\", [27.5, 55.0, 110.0, 220.0, 440.0, 880.0, 1760.0, 3520.0, 7040.0]);\nnotes.set(\"Bb\", [29.14, 58.27, 116.54, 233.08, 466.16, 932.33, 1864.66, 3729.31, 7458.62]);\nnotes.set(\"B\", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);\nnotes.set(\"pause\", [0]);\nfunction getNoteFrequency(note) {\n const regex = /(([A-G]b?)(\\d))|pause/i,\n result = regex.exec(note),\n groupKey = 2,\n defaultMatchKey = 0,\n innerGroupKey = 3;\n if (!result?.length) {\n return;\n }\n const noteKey = result[groupKey] ?? result[defaultMatchKey],\n noteItem = notes.get(noteKey);\n if (!noteItem) {\n return;\n }\n return noteItem[parseInt(result[innerGroupKey] ?? \"0\")];\n}\nlet muted = true;\nconst isWindowMuted = () => {\n return muted;\n};\nconst unmuteWindow = () => {\n muted = false;\n};\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/utils.js?\n}");
|
|
137
|
+
|
|
138
|
+
/***/ }
|
|
139
|
+
|
|
140
|
+
}]);
|