@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.
- package/README.md +23 -0
- package/dist/constants.d.mts +8 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +37 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +10 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/core/audio-core.d.mts +98 -0
- package/dist/core/audio-core.d.ts +98 -0
- package/dist/core/audio-core.js +664 -0
- package/dist/core/audio-core.js.map +1 -0
- package/dist/core/audio-core.mjs +641 -0
- package/dist/core/audio-core.mjs.map +1 -0
- package/dist/core/audio-worklet.d.mts +3 -0
- package/dist/core/audio-worklet.d.ts +3 -0
- package/dist/core/audio-worklet.js +153 -0
- package/dist/core/audio-worklet.js.map +1 -0
- package/dist/core/audio-worklet.mjs +128 -0
- package/dist/core/audio-worklet.mjs.map +1 -0
- package/dist/core/index.d.mts +2 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +666 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +641 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/devices/beeper.d.mts +21 -0
- package/dist/devices/beeper.d.ts +21 -0
- package/dist/devices/beeper.js +286 -0
- package/dist/devices/beeper.js.map +1 -0
- package/dist/devices/beeper.mjs +261 -0
- package/dist/devices/beeper.mjs.map +1 -0
- package/dist/devices/index.d.mts +3 -0
- package/dist/devices/index.d.ts +3 -0
- package/dist/devices/index.js +534 -0
- package/dist/devices/index.js.map +1 -0
- package/dist/devices/index.mjs +507 -0
- package/dist/devices/index.mjs.map +1 -0
- package/dist/devices/music.d.mts +27 -0
- package/dist/devices/music.d.ts +27 -0
- package/dist/devices/music.js +104 -0
- package/dist/devices/music.js.map +1 -0
- package/dist/devices/music.mjs +81 -0
- package/dist/devices/music.mjs.map +1 -0
- package/dist/devices/sound.d.mts +22 -0
- package/dist/devices/sound.d.ts +22 -0
- package/dist/devices/sound.js +198 -0
- package/dist/devices/sound.js.map +1 -0
- package/dist/devices/sound.mjs +175 -0
- package/dist/devices/sound.mjs.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +916 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +888 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/constants.ts
|
|
5
|
+
var A4_FREQUENCY = 440;
|
|
6
|
+
var SEMITONE_RATIO = 2 ** (1 / 12);
|
|
7
|
+
var A4_MIDI_NOTE = 69;
|
|
8
|
+
|
|
9
|
+
// src/devices/beeper.ts
|
|
10
|
+
var Beeper = class {
|
|
11
|
+
static {
|
|
12
|
+
__name(this, "Beeper");
|
|
13
|
+
}
|
|
14
|
+
audio;
|
|
15
|
+
notes = {};
|
|
16
|
+
plainNotes = {};
|
|
17
|
+
currentOctave = 5;
|
|
18
|
+
currentDuration = 0.5;
|
|
19
|
+
currentVolume = 0.5;
|
|
20
|
+
currentSpan = 1;
|
|
21
|
+
currentWaveform = "square";
|
|
22
|
+
constructor(audio) {
|
|
23
|
+
this.audio = audio;
|
|
24
|
+
this.initializeNotes();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Initialize note mappings
|
|
28
|
+
*/
|
|
29
|
+
initializeNotes() {
|
|
30
|
+
const noteNames = [
|
|
31
|
+
[
|
|
32
|
+
"C",
|
|
33
|
+
"DO"
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"C#",
|
|
37
|
+
"DO#",
|
|
38
|
+
"Db",
|
|
39
|
+
"REb"
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"D",
|
|
43
|
+
"RE"
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
"D#",
|
|
47
|
+
"RE#",
|
|
48
|
+
"Eb",
|
|
49
|
+
"MIb"
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
"E",
|
|
53
|
+
"MI"
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"F",
|
|
57
|
+
"FA"
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
"F#",
|
|
61
|
+
"FA#",
|
|
62
|
+
"Gb",
|
|
63
|
+
"SOLb"
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"G",
|
|
67
|
+
"SOL"
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
"G#",
|
|
71
|
+
"SOL#",
|
|
72
|
+
"Ab",
|
|
73
|
+
"LAb"
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"A",
|
|
77
|
+
"LA"
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"A#",
|
|
81
|
+
"LA#",
|
|
82
|
+
"Bb",
|
|
83
|
+
"SIb"
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
"B",
|
|
87
|
+
"SI"
|
|
88
|
+
]
|
|
89
|
+
];
|
|
90
|
+
for (let i = 0; i <= 127; i++) {
|
|
91
|
+
this.notes[i] = i;
|
|
92
|
+
const oct = Math.floor(i / 12) - 1;
|
|
93
|
+
for (const n of noteNames[i % 12]) {
|
|
94
|
+
this.notes[n + oct] = i;
|
|
95
|
+
}
|
|
96
|
+
if (oct === -1) {
|
|
97
|
+
for (const n of noteNames[i % 12]) {
|
|
98
|
+
this.plainNotes[n] = i;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parse and play beep sequence
|
|
105
|
+
*/
|
|
106
|
+
beep(input) {
|
|
107
|
+
let status = "normal";
|
|
108
|
+
const sequence = [];
|
|
109
|
+
const loops = [];
|
|
110
|
+
let note;
|
|
111
|
+
const parsed = input.split(" ");
|
|
112
|
+
for (const t of parsed) {
|
|
113
|
+
if (t === "") continue;
|
|
114
|
+
switch (status) {
|
|
115
|
+
case "normal":
|
|
116
|
+
if (this.notes[t] !== void 0) {
|
|
117
|
+
note = this.notes[t];
|
|
118
|
+
this.currentOctave = Math.floor(note / 12);
|
|
119
|
+
sequence.push({
|
|
120
|
+
frequency: A4_FREQUENCY * SEMITONE_RATIO ** (note - A4_MIDI_NOTE),
|
|
121
|
+
volume: this.currentVolume,
|
|
122
|
+
span: this.currentSpan,
|
|
123
|
+
duration: this.currentDuration,
|
|
124
|
+
waveform: this.currentWaveform
|
|
125
|
+
});
|
|
126
|
+
} else if (this.plainNotes[t] !== void 0) {
|
|
127
|
+
note = this.plainNotes[t] + this.currentOctave * 12;
|
|
128
|
+
sequence.push({
|
|
129
|
+
frequency: A4_FREQUENCY * SEMITONE_RATIO ** (note - A4_MIDI_NOTE),
|
|
130
|
+
volume: this.currentVolume,
|
|
131
|
+
span: this.currentSpan,
|
|
132
|
+
duration: this.currentDuration,
|
|
133
|
+
waveform: this.currentWaveform
|
|
134
|
+
});
|
|
135
|
+
} else if ([
|
|
136
|
+
"square",
|
|
137
|
+
"sine",
|
|
138
|
+
"saw",
|
|
139
|
+
"noise"
|
|
140
|
+
].includes(t)) {
|
|
141
|
+
this.currentWaveform = t;
|
|
142
|
+
} else if ([
|
|
143
|
+
"tempo",
|
|
144
|
+
"duration",
|
|
145
|
+
"volume",
|
|
146
|
+
"span",
|
|
147
|
+
"loop",
|
|
148
|
+
"to"
|
|
149
|
+
].includes(t)) {
|
|
150
|
+
status = t;
|
|
151
|
+
} else if (t === "-") {
|
|
152
|
+
sequence.push({
|
|
153
|
+
frequency: A4_FREQUENCY,
|
|
154
|
+
volume: 0,
|
|
155
|
+
span: this.currentSpan,
|
|
156
|
+
duration: this.currentDuration,
|
|
157
|
+
waveform: this.currentWaveform
|
|
158
|
+
});
|
|
159
|
+
} else if (t === "end") {
|
|
160
|
+
if (loops.length > 0 && sequence.length > 0) {
|
|
161
|
+
sequence.push({
|
|
162
|
+
frequency: A4_FREQUENCY,
|
|
163
|
+
volume: 0,
|
|
164
|
+
span: this.currentSpan,
|
|
165
|
+
duration: 0,
|
|
166
|
+
waveform: this.currentWaveform
|
|
167
|
+
});
|
|
168
|
+
const lop = loops.splice(loops.length - 1, 1)[0];
|
|
169
|
+
sequence[sequence.length - 1].loopto = lop.start;
|
|
170
|
+
sequence[sequence.length - 1].repeats = lop.repeats;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case "tempo": {
|
|
175
|
+
status = "normal";
|
|
176
|
+
const tempo = Number.parseFloat(t);
|
|
177
|
+
if (!Number.isNaN(tempo) && tempo > 0) {
|
|
178
|
+
this.currentDuration = 60 / tempo;
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "duration": {
|
|
183
|
+
status = "normal";
|
|
184
|
+
const duration = Number.parseFloat(t);
|
|
185
|
+
if (!Number.isNaN(duration) && duration > 0) {
|
|
186
|
+
this.currentDuration = duration / 1e3;
|
|
187
|
+
}
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case "volume": {
|
|
191
|
+
status = "normal";
|
|
192
|
+
const volume = Number.parseFloat(t);
|
|
193
|
+
if (!Number.isNaN(volume)) {
|
|
194
|
+
this.currentVolume = volume / 100;
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "span": {
|
|
199
|
+
status = "normal";
|
|
200
|
+
const span = Number.parseFloat(t);
|
|
201
|
+
if (!Number.isNaN(span)) {
|
|
202
|
+
this.currentSpan = span / 100;
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
case "loop": {
|
|
207
|
+
status = "normal";
|
|
208
|
+
loops.push({
|
|
209
|
+
start: sequence.length
|
|
210
|
+
});
|
|
211
|
+
const repeats = Number.parseFloat(t);
|
|
212
|
+
if (!Number.isNaN(repeats)) {
|
|
213
|
+
loops[loops.length - 1].repeats = repeats;
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case "to":
|
|
218
|
+
status = "normal";
|
|
219
|
+
if (note !== void 0) {
|
|
220
|
+
let n;
|
|
221
|
+
if (this.notes[t] !== void 0) {
|
|
222
|
+
n = this.notes[t];
|
|
223
|
+
} else if (this.plainNotes[t] !== void 0) {
|
|
224
|
+
n = this.plainNotes[t] + this.currentOctave * 12;
|
|
225
|
+
}
|
|
226
|
+
if (n !== void 0 && n !== note) {
|
|
227
|
+
const step = n > note ? 1 : -1;
|
|
228
|
+
for (let i = note + step; step > 0 ? i <= n : i >= n; i += step) {
|
|
229
|
+
sequence.push({
|
|
230
|
+
frequency: A4_FREQUENCY * SEMITONE_RATIO ** (i - A4_MIDI_NOTE),
|
|
231
|
+
volume: this.currentVolume,
|
|
232
|
+
span: this.currentSpan,
|
|
233
|
+
duration: this.currentDuration,
|
|
234
|
+
waveform: this.currentWaveform
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
note = n;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (loops.length > 0 && sequence.length > 0) {
|
|
244
|
+
const lop = loops.splice(loops.length - 1, 1)[0];
|
|
245
|
+
sequence.push({
|
|
246
|
+
frequency: A4_FREQUENCY,
|
|
247
|
+
volume: 0,
|
|
248
|
+
span: this.currentSpan,
|
|
249
|
+
duration: 0,
|
|
250
|
+
waveform: this.currentWaveform
|
|
251
|
+
});
|
|
252
|
+
sequence[sequence.length - 1].loopto = lop.start;
|
|
253
|
+
sequence[sequence.length - 1].repeats = lop.repeats;
|
|
254
|
+
}
|
|
255
|
+
this.audio.addBeeps(sequence);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
export {
|
|
259
|
+
Beeper
|
|
260
|
+
};
|
|
261
|
+
//# sourceMappingURL=beeper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/devices/beeper.ts"],"sourcesContent":["/** 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"],"mappings":";;;;AACO,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;Q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AK1B;gBAChB,CAAA;cACD;AACAa,qBAAON;YACR;UACD;AACA;MACF;IACD;AAGA,QAAIK,MAAMgB,SAAS,KAAKjB,SAASiB,SAAS,GAAG;AAC5C,YAAMC,MAAMjB,MAAMkB,OAAOlB,MAAMgB,SAAS,GAAG,CAAA,EAAG,CAAA;AAC9CjB,eAASO,KAAK;QACbC,WAAWC;QACXG,QAAQ;QACRC,MAAM,KAAKzB;QACX0B,UAAU;QACVC,UAAU,KAAK1B;MAChB,CAAA;AAEAW,eAASA,SAASiB,SAAS,CAAA,EAAGG,SAASF,IAAIG;AAC3CrB,eAASA,SAASiB,SAAS,CAAA,EAAGK,UAAUJ,IAAII;IAC7C;AAEA,SAAKxC,MAAM8C,SAAS5B,QAAAA;EACrB;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"]}
|