@al8b/audio 0.1.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.
Files changed (56) hide show
  1. package/README.md +23 -0
  2. package/dist/constants.d.mts +8 -0
  3. package/dist/constants.d.ts +8 -0
  4. package/dist/constants.js +37 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/constants.mjs +10 -0
  7. package/dist/constants.mjs.map +1 -0
  8. package/dist/core/audio-core.d.mts +98 -0
  9. package/dist/core/audio-core.d.ts +98 -0
  10. package/dist/core/audio-core.js +664 -0
  11. package/dist/core/audio-core.js.map +1 -0
  12. package/dist/core/audio-core.mjs +641 -0
  13. package/dist/core/audio-core.mjs.map +1 -0
  14. package/dist/core/audio-worklet.d.mts +3 -0
  15. package/dist/core/audio-worklet.d.ts +3 -0
  16. package/dist/core/audio-worklet.js +153 -0
  17. package/dist/core/audio-worklet.js.map +1 -0
  18. package/dist/core/audio-worklet.mjs +128 -0
  19. package/dist/core/audio-worklet.mjs.map +1 -0
  20. package/dist/core/index.d.mts +2 -0
  21. package/dist/core/index.d.ts +2 -0
  22. package/dist/core/index.js +666 -0
  23. package/dist/core/index.js.map +1 -0
  24. package/dist/core/index.mjs +641 -0
  25. package/dist/core/index.mjs.map +1 -0
  26. package/dist/devices/beeper.d.mts +21 -0
  27. package/dist/devices/beeper.d.ts +21 -0
  28. package/dist/devices/beeper.js +286 -0
  29. package/dist/devices/beeper.js.map +1 -0
  30. package/dist/devices/beeper.mjs +261 -0
  31. package/dist/devices/beeper.mjs.map +1 -0
  32. package/dist/devices/index.d.mts +3 -0
  33. package/dist/devices/index.d.ts +3 -0
  34. package/dist/devices/index.js +534 -0
  35. package/dist/devices/index.js.map +1 -0
  36. package/dist/devices/index.mjs +507 -0
  37. package/dist/devices/index.mjs.map +1 -0
  38. package/dist/devices/music.d.mts +27 -0
  39. package/dist/devices/music.d.ts +27 -0
  40. package/dist/devices/music.js +104 -0
  41. package/dist/devices/music.js.map +1 -0
  42. package/dist/devices/music.mjs +81 -0
  43. package/dist/devices/music.mjs.map +1 -0
  44. package/dist/devices/sound.d.mts +22 -0
  45. package/dist/devices/sound.d.ts +22 -0
  46. package/dist/devices/sound.js +198 -0
  47. package/dist/devices/sound.js.map +1 -0
  48. package/dist/devices/sound.mjs +175 -0
  49. package/dist/devices/sound.mjs.map +1 -0
  50. package/dist/index.d.mts +4 -0
  51. package/dist/index.d.ts +4 -0
  52. package/dist/index.js +916 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/index.mjs +888 -0
  55. package/dist/index.mjs.map +1 -0
  56. package/package.json +37 -0
@@ -0,0 +1,534 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/devices/index.ts
22
+ var devices_exports = {};
23
+ __export(devices_exports, {
24
+ Beeper: () => Beeper,
25
+ Music: () => Music,
26
+ Sound: () => Sound
27
+ });
28
+ module.exports = __toCommonJS(devices_exports);
29
+
30
+ // src/constants.ts
31
+ var A4_FREQUENCY = 440;
32
+ var SEMITONE_RATIO = 2 ** (1 / 12);
33
+ var A4_MIDI_NOTE = 69;
34
+
35
+ // src/devices/beeper.ts
36
+ var Beeper = class {
37
+ static {
38
+ __name(this, "Beeper");
39
+ }
40
+ audio;
41
+ notes = {};
42
+ plainNotes = {};
43
+ currentOctave = 5;
44
+ currentDuration = 0.5;
45
+ currentVolume = 0.5;
46
+ currentSpan = 1;
47
+ currentWaveform = "square";
48
+ constructor(audio) {
49
+ this.audio = audio;
50
+ this.initializeNotes();
51
+ }
52
+ /**
53
+ * Initialize note mappings
54
+ */
55
+ initializeNotes() {
56
+ const noteNames = [
57
+ [
58
+ "C",
59
+ "DO"
60
+ ],
61
+ [
62
+ "C#",
63
+ "DO#",
64
+ "Db",
65
+ "REb"
66
+ ],
67
+ [
68
+ "D",
69
+ "RE"
70
+ ],
71
+ [
72
+ "D#",
73
+ "RE#",
74
+ "Eb",
75
+ "MIb"
76
+ ],
77
+ [
78
+ "E",
79
+ "MI"
80
+ ],
81
+ [
82
+ "F",
83
+ "FA"
84
+ ],
85
+ [
86
+ "F#",
87
+ "FA#",
88
+ "Gb",
89
+ "SOLb"
90
+ ],
91
+ [
92
+ "G",
93
+ "SOL"
94
+ ],
95
+ [
96
+ "G#",
97
+ "SOL#",
98
+ "Ab",
99
+ "LAb"
100
+ ],
101
+ [
102
+ "A",
103
+ "LA"
104
+ ],
105
+ [
106
+ "A#",
107
+ "LA#",
108
+ "Bb",
109
+ "SIb"
110
+ ],
111
+ [
112
+ "B",
113
+ "SI"
114
+ ]
115
+ ];
116
+ for (let i = 0; i <= 127; i++) {
117
+ this.notes[i] = i;
118
+ const oct = Math.floor(i / 12) - 1;
119
+ for (const n of noteNames[i % 12]) {
120
+ this.notes[n + oct] = i;
121
+ }
122
+ if (oct === -1) {
123
+ for (const n of noteNames[i % 12]) {
124
+ this.plainNotes[n] = i;
125
+ }
126
+ }
127
+ }
128
+ }
129
+ /**
130
+ * Parse and play beep sequence
131
+ */
132
+ beep(input) {
133
+ let status = "normal";
134
+ const sequence = [];
135
+ const loops = [];
136
+ let note;
137
+ const parsed = input.split(" ");
138
+ for (const t of parsed) {
139
+ if (t === "") continue;
140
+ switch (status) {
141
+ case "normal":
142
+ if (this.notes[t] !== void 0) {
143
+ note = this.notes[t];
144
+ this.currentOctave = Math.floor(note / 12);
145
+ sequence.push({
146
+ frequency: A4_FREQUENCY * SEMITONE_RATIO ** (note - A4_MIDI_NOTE),
147
+ volume: this.currentVolume,
148
+ span: this.currentSpan,
149
+ duration: this.currentDuration,
150
+ waveform: this.currentWaveform
151
+ });
152
+ } else if (this.plainNotes[t] !== void 0) {
153
+ note = this.plainNotes[t] + this.currentOctave * 12;
154
+ sequence.push({
155
+ frequency: A4_FREQUENCY * SEMITONE_RATIO ** (note - A4_MIDI_NOTE),
156
+ volume: this.currentVolume,
157
+ span: this.currentSpan,
158
+ duration: this.currentDuration,
159
+ waveform: this.currentWaveform
160
+ });
161
+ } else if ([
162
+ "square",
163
+ "sine",
164
+ "saw",
165
+ "noise"
166
+ ].includes(t)) {
167
+ this.currentWaveform = t;
168
+ } else if ([
169
+ "tempo",
170
+ "duration",
171
+ "volume",
172
+ "span",
173
+ "loop",
174
+ "to"
175
+ ].includes(t)) {
176
+ status = t;
177
+ } else if (t === "-") {
178
+ sequence.push({
179
+ frequency: A4_FREQUENCY,
180
+ volume: 0,
181
+ span: this.currentSpan,
182
+ duration: this.currentDuration,
183
+ waveform: this.currentWaveform
184
+ });
185
+ } else if (t === "end") {
186
+ if (loops.length > 0 && sequence.length > 0) {
187
+ sequence.push({
188
+ frequency: A4_FREQUENCY,
189
+ volume: 0,
190
+ span: this.currentSpan,
191
+ duration: 0,
192
+ waveform: this.currentWaveform
193
+ });
194
+ const lop = loops.splice(loops.length - 1, 1)[0];
195
+ sequence[sequence.length - 1].loopto = lop.start;
196
+ sequence[sequence.length - 1].repeats = lop.repeats;
197
+ }
198
+ }
199
+ break;
200
+ case "tempo": {
201
+ status = "normal";
202
+ const tempo = Number.parseFloat(t);
203
+ if (!Number.isNaN(tempo) && tempo > 0) {
204
+ this.currentDuration = 60 / tempo;
205
+ }
206
+ break;
207
+ }
208
+ case "duration": {
209
+ status = "normal";
210
+ const duration = Number.parseFloat(t);
211
+ if (!Number.isNaN(duration) && duration > 0) {
212
+ this.currentDuration = duration / 1e3;
213
+ }
214
+ break;
215
+ }
216
+ case "volume": {
217
+ status = "normal";
218
+ const volume = Number.parseFloat(t);
219
+ if (!Number.isNaN(volume)) {
220
+ this.currentVolume = volume / 100;
221
+ }
222
+ break;
223
+ }
224
+ case "span": {
225
+ status = "normal";
226
+ const span = Number.parseFloat(t);
227
+ if (!Number.isNaN(span)) {
228
+ this.currentSpan = span / 100;
229
+ }
230
+ break;
231
+ }
232
+ case "loop": {
233
+ status = "normal";
234
+ loops.push({
235
+ start: sequence.length
236
+ });
237
+ const repeats = Number.parseFloat(t);
238
+ if (!Number.isNaN(repeats)) {
239
+ loops[loops.length - 1].repeats = repeats;
240
+ }
241
+ break;
242
+ }
243
+ case "to":
244
+ status = "normal";
245
+ if (note !== void 0) {
246
+ let n;
247
+ if (this.notes[t] !== void 0) {
248
+ n = this.notes[t];
249
+ } else if (this.plainNotes[t] !== void 0) {
250
+ n = this.plainNotes[t] + this.currentOctave * 12;
251
+ }
252
+ if (n !== void 0 && n !== note) {
253
+ const step = n > note ? 1 : -1;
254
+ for (let i = note + step; step > 0 ? i <= n : i >= n; i += step) {
255
+ sequence.push({
256
+ frequency: A4_FREQUENCY * SEMITONE_RATIO ** (i - A4_MIDI_NOTE),
257
+ volume: this.currentVolume,
258
+ span: this.currentSpan,
259
+ duration: this.currentDuration,
260
+ waveform: this.currentWaveform
261
+ });
262
+ }
263
+ note = n;
264
+ }
265
+ }
266
+ break;
267
+ }
268
+ }
269
+ if (loops.length > 0 && sequence.length > 0) {
270
+ const lop = loops.splice(loops.length - 1, 1)[0];
271
+ sequence.push({
272
+ frequency: A4_FREQUENCY,
273
+ volume: 0,
274
+ span: this.currentSpan,
275
+ duration: 0,
276
+ waveform: this.currentWaveform
277
+ });
278
+ sequence[sequence.length - 1].loopto = lop.start;
279
+ sequence[sequence.length - 1].repeats = lop.repeats;
280
+ }
281
+ this.audio.addBeeps(sequence);
282
+ }
283
+ };
284
+
285
+ // src/devices/music.ts
286
+ var Music = class {
287
+ static {
288
+ __name(this, "Music");
289
+ }
290
+ ready = 1;
291
+ name = "";
292
+ url;
293
+ tag;
294
+ playing = false;
295
+ audio;
296
+ constructor(audio, url) {
297
+ this.audio = audio;
298
+ this.url = url;
299
+ this.tag = new Audio(this.url);
300
+ this.ready = 1;
301
+ }
302
+ /**
303
+ * Play music with volume and loop (HTML5 Audio implementation)
304
+ */
305
+ play(volume = 1, loopit = false) {
306
+ this.playing = true;
307
+ this.tag.loop = !!loopit;
308
+ this.tag.volume = Math.max(0, Math.min(1, volume));
309
+ if (this.audio.isStarted()) {
310
+ this.tag.play();
311
+ } else {
312
+ this.audio.addToWakeUpList(this);
313
+ }
314
+ this.audio.addPlaying(this);
315
+ return {
316
+ play: /* @__PURE__ */ __name(() => {
317
+ return this.tag.play();
318
+ }, "play"),
319
+ stop: /* @__PURE__ */ __name(() => {
320
+ this.playing = false;
321
+ this.tag.pause();
322
+ this.audio.removePlaying(this);
323
+ }, "stop"),
324
+ setVolume: /* @__PURE__ */ __name((v) => {
325
+ this.tag.volume = Math.max(0, Math.min(1, v));
326
+ }, "setVolume"),
327
+ getPosition: /* @__PURE__ */ __name(() => {
328
+ return this.tag.currentTime;
329
+ }, "getPosition"),
330
+ getDuration: /* @__PURE__ */ __name(() => {
331
+ return this.tag.duration;
332
+ }, "getDuration"),
333
+ setPosition: /* @__PURE__ */ __name((pos) => {
334
+ this.tag.pause();
335
+ this.tag.currentTime = Math.max(0, Math.min(this.tag.duration, pos));
336
+ if (this.playing) {
337
+ this.tag.play();
338
+ }
339
+ }, "setPosition")
340
+ };
341
+ }
342
+ /**
343
+ * Wake up audio (for autoplay policy)
344
+ */
345
+ wakeUp() {
346
+ if (this.playing) {
347
+ this.tag.play();
348
+ }
349
+ }
350
+ /**
351
+ * Stop music
352
+ */
353
+ stop() {
354
+ this.playing = false;
355
+ this.tag.pause();
356
+ this.audio.removePlaying(this);
357
+ }
358
+ };
359
+
360
+ // src/devices/sound.ts
361
+ var import_diagnostics = require("@al8b/diagnostics");
362
+ var Sound = class _Sound {
363
+ static {
364
+ __name(this, "Sound");
365
+ }
366
+ ready = 0;
367
+ buffer;
368
+ name = "";
369
+ url;
370
+ audio;
371
+ constructor(audio, url) {
372
+ this.audio = audio;
373
+ if (url instanceof AudioBuffer) {
374
+ this.buffer = url;
375
+ this.url = "";
376
+ this.ready = 1;
377
+ } else {
378
+ this.url = url;
379
+ this.loadSound(url);
380
+ }
381
+ }
382
+ /**
383
+ * Load sound from URL
384
+ */
385
+ loadSound(url) {
386
+ const request = new XMLHttpRequest();
387
+ request.open("GET", url, true);
388
+ request.responseType = "arraybuffer";
389
+ request.onload = () => {
390
+ this.audio.context.decodeAudioData(request.response, (buffer) => {
391
+ this.buffer = buffer;
392
+ this.ready = 1;
393
+ }, (err) => {
394
+ (0, import_diagnostics.reportRuntimeError)(this.audio?.runtime?.listener, import_diagnostics.APIErrorCode.E7016, {
395
+ error: `Audio decoding failed: ${String(err)}`
396
+ });
397
+ });
398
+ };
399
+ request.onerror = () => {
400
+ (0, import_diagnostics.reportRuntimeError)(this.audio?.runtime?.listener, import_diagnostics.APIErrorCode.E7016, {
401
+ error: `Failed to load sound: ${url}`
402
+ });
403
+ };
404
+ request.send();
405
+ }
406
+ /**
407
+ * Play sound with volume, pitch, pan, and loop
408
+ */
409
+ play(volume = 1, pitch = 1, pan = 0, loopit = false) {
410
+ if (!this.buffer) return {
411
+ stop: /* @__PURE__ */ __name(() => {
412
+ }, "stop"),
413
+ finished: true
414
+ };
415
+ const context = this.audio.context;
416
+ const source = context.createBufferSource();
417
+ source.playbackRate.value = pitch;
418
+ source.buffer = this.buffer;
419
+ if (loopit) source.loop = true;
420
+ const gain = context.createGain();
421
+ gain.gain.value = volume;
422
+ const panner = context.createPanner();
423
+ panner.panningModel = "equalpower";
424
+ panner.setPan = (p) => {
425
+ panner.setPosition(p, 0, 1 - Math.abs(p));
426
+ };
427
+ panner.setPan(pan);
428
+ source.connect(gain);
429
+ gain.connect(panner);
430
+ panner.connect(context.destination);
431
+ source.start();
432
+ let playing = null;
433
+ if (loopit) {
434
+ playing = {
435
+ stop: /* @__PURE__ */ __name(() => {
436
+ source.stop();
437
+ }, "stop")
438
+ };
439
+ this.audio.addPlaying(playing);
440
+ }
441
+ const res = {
442
+ stop: /* @__PURE__ */ __name(() => {
443
+ source.stop();
444
+ if (playing) this.audio.removePlaying(playing);
445
+ return 1;
446
+ }, "stop"),
447
+ setVolume: /* @__PURE__ */ __name((v) => {
448
+ gain.gain.value = Math.max(0, Math.min(1, v));
449
+ }, "setVolume"),
450
+ setPitch: /* @__PURE__ */ __name((p) => {
451
+ source.playbackRate.value = Math.max(1e-3, Math.min(1e3, p));
452
+ }, "setPitch"),
453
+ setPan: /* @__PURE__ */ __name((p) => {
454
+ panner.setPan(Math.max(-1, Math.min(1, p)));
455
+ }, "setPan"),
456
+ getDuration: /* @__PURE__ */ __name(() => {
457
+ return source.buffer ? source.buffer.duration : 0;
458
+ }, "getDuration"),
459
+ finished: false
460
+ };
461
+ source.onended = () => {
462
+ res.finished = true;
463
+ };
464
+ return res;
465
+ }
466
+ /**
467
+ * Create MicroSound class for procedural sound generation
468
+ */
469
+ static createSoundClass(audiocore) {
470
+ return class MicroSound {
471
+ static {
472
+ __name(this, "MicroSound");
473
+ }
474
+ static classname = "Sound";
475
+ channels;
476
+ length;
477
+ sampleRate;
478
+ sound;
479
+ buffer;
480
+ constructor(channels, length, sampleRate = 44100) {
481
+ channels = channels === 1 ? 1 : 2;
482
+ if (!(length > 1 && length < 44100 * 1e3)) {
483
+ length = 44100;
484
+ }
485
+ if (!(sampleRate >= 8e3 && sampleRate <= 96e3)) {
486
+ sampleRate = 44100;
487
+ }
488
+ this.channels = channels;
489
+ this.length = length;
490
+ this.sampleRate = sampleRate;
491
+ this.buffer = audiocore.context.createBuffer(channels, length, sampleRate);
492
+ this.sound = new _Sound(audiocore, this.buffer);
493
+ }
494
+ /**
495
+ * Play the sound
496
+ */
497
+ play(volume, pitch, pan, loopit) {
498
+ return this.sound.play(volume, pitch, pan, loopit);
499
+ }
500
+ /**
501
+ * Write sample value to buffer
502
+ */
503
+ write(channel, position, value) {
504
+ if (channel === 0) {
505
+ const ch1 = this.buffer.getChannelData(0);
506
+ ch1[position] = value;
507
+ } else if (this.channels === 2) {
508
+ const ch2 = this.buffer.getChannelData(1);
509
+ ch2[position] = value;
510
+ }
511
+ }
512
+ /**
513
+ * Read sample value from buffer
514
+ */
515
+ read(channel, position) {
516
+ if (channel === 0) {
517
+ const ch1 = this.buffer.getChannelData(0);
518
+ return ch1[position];
519
+ } else if (this.channels === 2) {
520
+ const ch2 = this.buffer.getChannelData(1);
521
+ return ch2[position];
522
+ }
523
+ return 0;
524
+ }
525
+ };
526
+ }
527
+ };
528
+ // Annotate the CommonJS export names for ESM import in node:
529
+ 0 && (module.exports = {
530
+ Beeper,
531
+ Music,
532
+ Sound
533
+ });
534
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/devices/index.ts","../../src/constants.ts","../../src/devices/beeper.ts","../../src/devices/music.ts","../../src/devices/sound.ts"],"sourcesContent":["export { Beeper } from \"./beeper\";\nexport { Music } from \"./music\";\nexport { Sound } from \"./sound\";\n","/** A4 reference frequency in Hz (concert pitch) */\nexport const A4_FREQUENCY = 440;\n\n/** Ratio between adjacent semitones in equal temperament */\nexport const SEMITONE_RATIO = 2 ** (1 / 12);\n\n/** MIDI note number for A4 */\nexport const A4_MIDI_NOTE = 69;\n","/**\n * Beeper - Procedural sound generation from text sequences\n * Converts music notation strings into beep sequences\n * Example: \"square tempo 120 C4 D4 E4 F4\"\n */\nimport { A4_FREQUENCY, A4_MIDI_NOTE, SEMITONE_RATIO } from \"../constants\";\nexport class Beeper {\n\tprivate audio: any;\n\tprivate notes: Record<string | number, number> = {};\n\tprivate plainNotes: Record<string, number> = {};\n\tprivate currentOctave = 5;\n\tprivate currentDuration = 0.5;\n\tprivate currentVolume = 0.5;\n\tprivate currentSpan = 1;\n\tprivate currentWaveform = \"square\";\n\n\tconstructor(audio: any) {\n\t\tthis.audio = audio;\n\t\tthis.initializeNotes();\n\t}\n\n\t/**\n\t * Initialize note mappings\n\t */\n\tprivate initializeNotes(): void {\n\t\tconst noteNames = [\n\t\t\t[\"C\", \"DO\"],\n\t\t\t[\"C#\", \"DO#\", \"Db\", \"REb\"],\n\t\t\t[\"D\", \"RE\"],\n\t\t\t[\"D#\", \"RE#\", \"Eb\", \"MIb\"],\n\t\t\t[\"E\", \"MI\"],\n\t\t\t[\"F\", \"FA\"],\n\t\t\t[\"F#\", \"FA#\", \"Gb\", \"SOLb\"],\n\t\t\t[\"G\", \"SOL\"],\n\t\t\t[\"G#\", \"SOL#\", \"Ab\", \"LAb\"],\n\t\t\t[\"A\", \"LA\"],\n\t\t\t[\"A#\", \"LA#\", \"Bb\", \"SIb\"],\n\t\t\t[\"B\", \"SI\"],\n\t\t];\n\n\t\tfor (let i = 0; i <= 127; i++) {\n\t\t\tthis.notes[i] = i;\n\t\t\tconst oct = Math.floor(i / 12) - 1;\n\n\t\t\tfor (const n of noteNames[i % 12]) {\n\t\t\t\tthis.notes[n + oct] = i;\n\t\t\t}\n\n\t\t\tif (oct === -1) {\n\t\t\t\tfor (const n of noteNames[i % 12]) {\n\t\t\t\t\tthis.plainNotes[n] = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Parse and play beep sequence\n\t */\n\tpublic beep(input: string): void {\n\t\tlet status: string = \"normal\";\n\t\tconst sequence: any[] = [];\n\t\tconst loops: any[] = [];\n\t\tlet note: number | undefined;\n\n\t\tconst parsed = input.split(\" \");\n\n\t\tfor (const t of parsed) {\n\t\t\tif (t === \"\") continue;\n\n\t\t\tswitch (status) {\n\t\t\t\tcase \"normal\":\n\t\t\t\t\tif (this.notes[t] !== undefined) {\n\t\t\t\t\t\t// Full note with octave (e.g., \"C4\")\n\t\t\t\t\t\tnote = this.notes[t];\n\t\t\t\t\t\tthis.currentOctave = Math.floor(note / 12);\n\t\t\t\t\t\tsequence.push({\n\t\t\t\t\t\t\tfrequency: A4_FREQUENCY * SEMITONE_RATIO ** (note - A4_MIDI_NOTE),\n\t\t\t\t\t\t\tvolume: this.currentVolume,\n\t\t\t\t\t\t\tspan: this.currentSpan,\n\t\t\t\t\t\t\tduration: this.currentDuration,\n\t\t\t\t\t\t\twaveform: this.currentWaveform,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (this.plainNotes[t] !== undefined) {\n\t\t\t\t\t\t// Note without octave (e.g., \"C\")\n\t\t\t\t\t\tnote = this.plainNotes[t] + this.currentOctave * 12;\n\t\t\t\t\t\tsequence.push({\n\t\t\t\t\t\t\tfrequency: A4_FREQUENCY * SEMITONE_RATIO ** (note - A4_MIDI_NOTE),\n\t\t\t\t\t\t\tvolume: this.currentVolume,\n\t\t\t\t\t\t\tspan: this.currentSpan,\n\t\t\t\t\t\t\tduration: this.currentDuration,\n\t\t\t\t\t\t\twaveform: this.currentWaveform,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if ([\"square\", \"sine\", \"saw\", \"noise\"].includes(t)) {\n\t\t\t\t\t\t// Waveform\n\t\t\t\t\t\tthis.currentWaveform = t;\n\t\t\t\t\t} else if ([\"tempo\", \"duration\", \"volume\", \"span\", \"loop\", \"to\"].includes(t)) {\n\t\t\t\t\t\t// Commands\n\t\t\t\t\t\tstatus = t;\n\t\t\t\t\t} else if (t === \"-\") {\n\t\t\t\t\t\t// Rest/silence\n\t\t\t\t\t\tsequence.push({\n\t\t\t\t\t\t\tfrequency: A4_FREQUENCY,\n\t\t\t\t\t\t\tvolume: 0,\n\t\t\t\t\t\t\tspan: this.currentSpan,\n\t\t\t\t\t\t\tduration: this.currentDuration,\n\t\t\t\t\t\t\twaveform: this.currentWaveform,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (t === \"end\") {\n\t\t\t\t\t\t// End loop\n\t\t\t\t\t\tif (loops.length > 0 && sequence.length > 0) {\n\t\t\t\t\t\t\tsequence.push({\n\t\t\t\t\t\t\t\tfrequency: A4_FREQUENCY,\n\t\t\t\t\t\t\t\tvolume: 0,\n\t\t\t\t\t\t\t\tspan: this.currentSpan,\n\t\t\t\t\t\t\t\tduration: 0,\n\t\t\t\t\t\t\t\twaveform: this.currentWaveform,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst lop = loops.splice(loops.length - 1, 1)[0];\n\t\t\t\t\t\t\tsequence[sequence.length - 1].loopto = lop.start;\n\t\t\t\t\t\t\tsequence[sequence.length - 1].repeats = lop.repeats;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"tempo\": {\n\t\t\t\t\tstatus = \"normal\";\n\t\t\t\t\tconst tempo = Number.parseFloat(t);\n\t\t\t\t\tif (!Number.isNaN(tempo) && tempo > 0) {\n\t\t\t\t\t\tthis.currentDuration = 60 / tempo;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"duration\": {\n\t\t\t\t\tstatus = \"normal\";\n\t\t\t\t\tconst duration = Number.parseFloat(t);\n\t\t\t\t\tif (!Number.isNaN(duration) && duration > 0) {\n\t\t\t\t\t\tthis.currentDuration = duration / 1000;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"volume\": {\n\t\t\t\t\tstatus = \"normal\";\n\t\t\t\t\tconst volume = Number.parseFloat(t);\n\t\t\t\t\tif (!Number.isNaN(volume)) {\n\t\t\t\t\t\tthis.currentVolume = volume / 100;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"span\": {\n\t\t\t\t\tstatus = \"normal\";\n\t\t\t\t\tconst span = Number.parseFloat(t);\n\t\t\t\t\tif (!Number.isNaN(span)) {\n\t\t\t\t\t\tthis.currentSpan = span / 100;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"loop\": {\n\t\t\t\t\tstatus = \"normal\";\n\t\t\t\t\tloops.push({\n\t\t\t\t\t\tstart: sequence.length,\n\t\t\t\t\t});\n\t\t\t\t\tconst repeats = Number.parseFloat(t);\n\t\t\t\t\tif (!Number.isNaN(repeats)) {\n\t\t\t\t\t\tloops[loops.length - 1].repeats = repeats;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"to\":\n\t\t\t\t\tstatus = \"normal\";\n\t\t\t\t\tif (note !== undefined) {\n\t\t\t\t\t\tlet n: number | undefined;\n\n\t\t\t\t\t\tif (this.notes[t] !== undefined) {\n\t\t\t\t\t\t\tn = this.notes[t];\n\t\t\t\t\t\t} else if (this.plainNotes[t] !== undefined) {\n\t\t\t\t\t\t\tn = this.plainNotes[t] + this.currentOctave * 12;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (n !== undefined && n !== note) {\n\t\t\t\t\t\t\t// Generate slide from note to n\n\t\t\t\t\t\t\tconst step = n > note ? 1 : -1;\n\t\t\t\t\t\t\tfor (let i = note + step; step > 0 ? i <= n : i >= n; i += step) {\n\t\t\t\t\t\t\t\tsequence.push({\n\t\t\t\t\t\t\t\t\tfrequency: A4_FREQUENCY * SEMITONE_RATIO ** (i - A4_MIDI_NOTE),\n\t\t\t\t\t\t\t\t\tvolume: this.currentVolume,\n\t\t\t\t\t\t\t\t\tspan: this.currentSpan,\n\t\t\t\t\t\t\t\t\tduration: this.currentDuration,\n\t\t\t\t\t\t\t\t\twaveform: this.currentWaveform,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnote = n;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Close any remaining loops\n\t\tif (loops.length > 0 && sequence.length > 0) {\n\t\t\tconst lop = loops.splice(loops.length - 1, 1)[0];\n\t\t\tsequence.push({\n\t\t\t\tfrequency: A4_FREQUENCY,\n\t\t\t\tvolume: 0,\n\t\t\t\tspan: this.currentSpan,\n\t\t\t\tduration: 0,\n\t\t\t\twaveform: this.currentWaveform,\n\t\t\t});\n\n\t\t\tsequence[sequence.length - 1].loopto = lop.start;\n\t\t\tsequence[sequence.length - 1].repeats = lop.repeats;\n\t\t}\n\n\t\tthis.audio.addBeeps(sequence);\n\t}\n}\n","/**\n * Music - Music streaming and playback using HTML5 Audio\n * L8B Music class for LootiScript\n */\nexport class Music {\n\tpublic ready: number = 1;\n\tpublic name: string = \"\";\n\tpublic url: string;\n\tpublic tag: HTMLAudioElement;\n\tpublic playing: boolean = false;\n\tprivate audio: any;\n\n\tconstructor(audio: any, url: string) {\n\t\tthis.audio = audio;\n\t\tthis.url = url;\n\t\tthis.tag = new Audio(this.url);\n\t\tthis.ready = 1;\n\t}\n\n\t/**\n\t * Play music with volume and loop (HTML5 Audio implementation)\n\t */\n\tpublic play(volume: number = 1, loopit: boolean = false): any {\n\t\tthis.playing = true;\n\t\tthis.tag.loop = !!loopit;\n\t\tthis.tag.volume = Math.max(0, Math.min(1, volume));\n\n\t\tif (this.audio.isStarted()) {\n\t\t\tthis.tag.play();\n\t\t} else {\n\t\t\tthis.audio.addToWakeUpList(this);\n\t\t}\n\n\t\tthis.audio.addPlaying(this);\n\n\t\treturn {\n\t\t\tplay: () => {\n\t\t\t\treturn this.tag.play();\n\t\t\t},\n\t\t\tstop: () => {\n\t\t\t\tthis.playing = false;\n\t\t\t\tthis.tag.pause();\n\t\t\t\tthis.audio.removePlaying(this);\n\t\t\t},\n\t\t\tsetVolume: (v: number) => {\n\t\t\t\tthis.tag.volume = Math.max(0, Math.min(1, v));\n\t\t\t},\n\t\t\tgetPosition: () => {\n\t\t\t\treturn this.tag.currentTime;\n\t\t\t},\n\t\t\tgetDuration: () => {\n\t\t\t\treturn this.tag.duration;\n\t\t\t},\n\t\t\tsetPosition: (pos: number) => {\n\t\t\t\tthis.tag.pause();\n\t\t\t\tthis.tag.currentTime = Math.max(0, Math.min(this.tag.duration, pos));\n\t\t\t\tif (this.playing) {\n\t\t\t\t\tthis.tag.play();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Wake up audio (for autoplay policy)\n\t */\n\tpublic wakeUp(): void {\n\t\tif (this.playing) {\n\t\t\tthis.tag.play();\n\t\t}\n\t}\n\n\t/**\n\t * Stop music\n\t */\n\tpublic stop(): void {\n\t\tthis.playing = false;\n\t\tthis.tag.pause();\n\t\tthis.audio.removePlaying(this);\n\t}\n}\n","/**\n * Sound - Sound effect playback\n * Handles loading and playing audio buffers\n */\nimport { APIErrorCode, reportRuntimeError } from \"@al8b/diagnostics\";\n\nexport class Sound {\n\tpublic ready: number = 0;\n\tpublic buffer?: AudioBuffer;\n\tpublic name: string = \"\";\n\tpublic url: string;\n\tprivate audio: any;\n\n\tconstructor(audio: any, url: string | AudioBuffer) {\n\t\tthis.audio = audio;\n\n\t\tif (url instanceof AudioBuffer) {\n\t\t\tthis.buffer = url;\n\t\t\tthis.url = \"\";\n\t\t\tthis.ready = 1;\n\t\t} else {\n\t\t\tthis.url = url;\n\t\t\tthis.loadSound(url);\n\t\t}\n\t}\n\n\t/**\n\t * Load sound from URL\n\t */\n\tprivate loadSound(url: string): void {\n\t\tconst request = new XMLHttpRequest();\n\t\trequest.open(\"GET\", url, true);\n\t\trequest.responseType = \"arraybuffer\";\n\n\t\trequest.onload = () => {\n\t\t\tthis.audio.context.decodeAudioData(\n\t\t\t\trequest.response,\n\t\t\t\t(buffer: AudioBuffer) => {\n\t\t\t\t\tthis.buffer = buffer;\n\t\t\t\t\tthis.ready = 1;\n\t\t\t\t},\n\t\t\t\t(err: any) => {\n\t\t\t\t\treportRuntimeError(this.audio?.runtime?.listener, APIErrorCode.E7016, {\n\t\t\t\t\t\terror: `Audio decoding failed: ${String(err)}`,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\trequest.onerror = () => {\n\t\t\treportRuntimeError(this.audio?.runtime?.listener, APIErrorCode.E7016, {\n\t\t\t\terror: `Failed to load sound: ${url}`,\n\t\t\t});\n\t\t};\n\n\t\trequest.send();\n\t}\n\n\t/**\n\t * Play sound with volume, pitch, pan, and loop\n\t */\n\tpublic play(volume: number = 1, pitch: number = 1, pan: number = 0, loopit: boolean = false): any {\n\t\tif (!this.buffer)\n\t\t\treturn {\n\t\t\t\tstop: () => {},\n\t\t\t\tfinished: true,\n\t\t\t};\n\n\t\tconst context = this.audio.context;\n\n\t\t// Create source\n\t\tconst source = context.createBufferSource();\n\t\tsource.playbackRate.value = pitch;\n\t\tsource.buffer = this.buffer;\n\t\tif (loopit) source.loop = true;\n\n\t\t// Create gain node\n\t\tconst gain = context.createGain();\n\t\tgain.gain.value = volume;\n\n\t\t// Create panner\n\t\tconst panner: any = context.createPanner();\n\t\tpanner.panningModel = \"equalpower\";\n\t\tpanner.setPan = (p: number) => {\n\t\t\tpanner.setPosition(p, 0, 1 - Math.abs(p));\n\t\t};\n\t\tpanner.setPan(pan);\n\n\t\t// Connect nodes\n\t\tsource.connect(gain);\n\t\tgain.connect(panner);\n\t\tpanner.connect(context.destination);\n\n\t\t// Start playback\n\t\tsource.start();\n\n\t\t// Track playing sounds for looping\n\t\tlet playing: any = null;\n\t\tif (loopit) {\n\t\t\tplaying = {\n\t\t\t\tstop: () => {\n\t\t\t\t\tsource.stop();\n\t\t\t\t},\n\t\t\t};\n\t\t\tthis.audio.addPlaying(playing);\n\t\t}\n\n\t\t// Return control interface\n\t\tconst res = {\n\t\t\tstop: () => {\n\t\t\t\tsource.stop();\n\t\t\t\tif (playing) this.audio.removePlaying(playing);\n\t\t\t\treturn 1;\n\t\t\t},\n\t\t\tsetVolume: (v: number) => {\n\t\t\t\tgain.gain.value = Math.max(0, Math.min(1, v));\n\t\t\t},\n\t\t\tsetPitch: (p: number) => {\n\t\t\t\tsource.playbackRate.value = Math.max(0.001, Math.min(1000, p));\n\t\t\t},\n\t\t\tsetPan: (p: number) => {\n\t\t\t\tpanner.setPan(Math.max(-1, Math.min(1, p)));\n\t\t\t},\n\t\t\tgetDuration: () => {\n\t\t\t\treturn source.buffer ? source.buffer.duration : 0;\n\t\t\t},\n\t\t\tfinished: false,\n\t\t};\n\n\t\tsource.onended = () => {\n\t\t\tres.finished = true;\n\t\t};\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Create MicroSound class for procedural sound generation\n\t */\n\tpublic static createSoundClass(audiocore: any): any {\n\t\treturn class MicroSound {\n\t\t\tpublic static classname = \"Sound\";\n\t\t\tpublic channels: number;\n\t\t\tpublic length: number;\n\t\t\tpublic sampleRate: number;\n\t\t\tprivate sound: Sound;\n\t\t\tprivate buffer: AudioBuffer;\n\n\t\t\tconstructor(channels: number, length: number, sampleRate: number = 44100) {\n\t\t\t\t// Validate parameters\n\t\t\t\tchannels = channels === 1 ? 1 : 2;\n\t\t\t\tif (!(length > 1 && length < 44100 * 1000)) {\n\t\t\t\t\tlength = 44100;\n\t\t\t\t}\n\t\t\t\tif (!(sampleRate >= 8000 && sampleRate <= 96000)) {\n\t\t\t\t\tsampleRate = 44100;\n\t\t\t\t}\n\n\t\t\t\tthis.channels = channels;\n\t\t\t\tthis.length = length;\n\t\t\t\tthis.sampleRate = sampleRate;\n\n\t\t\t\t// Create audio buffer\n\t\t\t\tthis.buffer = audiocore.context.createBuffer(channels, length, sampleRate);\n\t\t\t\tthis.sound = new Sound(audiocore, this.buffer);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Play the sound\n\t\t\t */\n\t\t\tpublic play(volume?: number, pitch?: number, pan?: number, loopit?: boolean): any {\n\t\t\t\treturn this.sound.play(volume, pitch, pan, loopit);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Write sample value to buffer\n\t\t\t */\n\t\t\tpublic write(channel: number, position: number, value: number): void {\n\t\t\t\tif (channel === 0) {\n\t\t\t\t\tconst ch1 = this.buffer.getChannelData(0);\n\t\t\t\t\tch1[position] = value;\n\t\t\t\t} else if (this.channels === 2) {\n\t\t\t\t\tconst ch2 = this.buffer.getChannelData(1);\n\t\t\t\t\tch2[position] = value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Read sample value from buffer\n\t\t\t */\n\t\t\tpublic read(channel: number, position: number): number {\n\t\t\t\tif (channel === 0) {\n\t\t\t\t\tconst ch1 = this.buffer.getChannelData(0);\n\t\t\t\t\treturn ch1[position];\n\t\t\t\t} else if (this.channels === 2) {\n\t\t\t\t\tconst ch2 = this.buffer.getChannelData(1);\n\t\t\t\t\treturn ch2[position];\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACCO,IAAMA,eAAe;AAGrB,IAAMC,iBAAiB,MAAM,IAAI;AAGjC,IAAMC,eAAe;;;ACDrB,IAAMC,SAAN,MAAMA;EANb,OAMaA;;;EACJC;EACAC,QAAyC,CAAC;EAC1CC,aAAqC,CAAC;EACtCC,gBAAgB;EAChBC,kBAAkB;EAClBC,gBAAgB;EAChBC,cAAc;EACdC,kBAAkB;EAE1B,YAAYP,OAAY;AACvB,SAAKA,QAAQA;AACb,SAAKQ,gBAAe;EACrB;;;;EAKQA,kBAAwB;AAC/B,UAAMC,YAAY;MACjB;QAAC;QAAK;;MACN;QAAC;QAAM;QAAO;QAAM;;MACpB;QAAC;QAAK;;MACN;QAAC;QAAM;QAAO;QAAM;;MACpB;QAAC;QAAK;;MACN;QAAC;QAAK;;MACN;QAAC;QAAM;QAAO;QAAM;;MACpB;QAAC;QAAK;;MACN;QAAC;QAAM;QAAQ;QAAM;;MACrB;QAAC;QAAK;;MACN;QAAC;QAAM;QAAO;QAAM;;MACpB;QAAC;QAAK;;;AAGP,aAASC,IAAI,GAAG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B,gBAAMU,MAAM,KAAK3E,OAAO0E,eAAe,CAAA;AACvCC,cAAIH,QAAAA,IAAYtC;QACjB;MACD;;;;MAKO0C,KAAKL,SAAiBC,UAA0B;AACtD,YAAID,YAAY,GAAG;AAClB,gBAAME,MAAM,KAAKzE,OAAO0E,eAAe,CAAA;AACvC,iBAAOD,IAAID,QAAAA;QACZ,WAAW,KAAKP,aAAa,GAAG;AAC/B,gBAAMU,MAAM,KAAK3E,OAAO0E,eAAe,CAAA;AACvC,iBAAOC,IAAIH,QAAAA;QACZ;AACA,eAAO;MACR;IACD;EACD;AACD;","names":["A4_FREQUENCY","SEMITONE_RATIO","A4_MIDI_NOTE","Beeper","audio","notes","plainNotes","currentOctave","currentDuration","currentVolume","currentSpan","currentWaveform","initializeNotes","noteNames","i","oct","Math","floor","n","beep","input","status","sequence","loops","note","parsed","split","t","undefined","push","frequency","A4_FREQUENCY","SEMITONE_RATIO","A4_MIDI_NOTE","volume","span","duration","waveform","includes","length","lop","splice","loopto","start","repeats","tempo","Number","parseFloat","isNaN","step","addBeeps","Music","ready","name","url","tag","playing","audio","Audio","play","volume","loopit","loop","Math","max","min","isStarted","addToWakeUpList","addPlaying","stop","pause","removePlaying","setVolume","v","getPosition","currentTime","getDuration","duration","setPosition","pos","wakeUp","Sound","ready","buffer","name","url","audio","AudioBuffer","loadSound","request","XMLHttpRequest","open","responseType","onload","context","decodeAudioData","response","err","reportRuntimeError","runtime","listener","APIErrorCode","E7016","error","String","onerror","send","play","volume","pitch","pan","loopit","stop","finished","source","createBufferSource","playbackRate","value","loop","gain","createGain","panner","createPanner","panningModel","setPan","p","setPosition","Math","abs","connect","destination","start","playing","addPlaying","res","removePlaying","setVolume","v","max","min","setPitch","getDuration","duration","onended","createSoundClass","audiocore","MicroSound","classname","channels","length","sampleRate","sound","createBuffer","write","channel","position","ch1","getChannelData","ch2","read"]}