kordweb 0.5.18 → 0.6.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/klib.js CHANGED
@@ -1,1697 +1,4 @@
1
- const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined));
2
- let wasm;
3
-
4
- const heap = new Array(128).fill(undefined);
5
-
6
- heap.push(undefined, null, true, false);
7
-
8
- function getObject(idx) { return heap[idx]; }
9
-
10
- let heap_next = heap.length;
11
-
12
- function dropObject(idx) {
13
- if (idx < 132) return;
14
- heap[idx] = heap_next;
15
- heap_next = idx;
16
- }
17
-
18
- function takeObject(idx) {
19
- const ret = getObject(idx);
20
- dropObject(idx);
21
- return ret;
22
- }
23
-
24
- const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
25
-
26
- cachedTextDecoder.decode();
27
-
28
- let cachedUint8Memory0 = null;
29
-
30
- function getUint8Memory0() {
31
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
32
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
33
- }
34
- return cachedUint8Memory0;
35
- }
36
-
37
- function getStringFromWasm0(ptr, len) {
38
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
39
- }
40
-
41
- function addHeapObject(obj) {
42
- if (heap_next === heap.length) heap.push(heap.length + 1);
43
- const idx = heap_next;
44
- heap_next = heap[idx];
45
-
46
- heap[idx] = obj;
47
- return idx;
48
- }
49
-
50
- function isLikeNone(x) {
51
- return x === undefined || x === null;
52
- }
53
-
54
- let cachedFloat64Memory0 = null;
55
-
56
- function getFloat64Memory0() {
57
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
58
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
59
- }
60
- return cachedFloat64Memory0;
61
- }
62
-
63
- let cachedInt32Memory0 = null;
64
-
65
- function getInt32Memory0() {
66
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
67
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
68
- }
69
- return cachedInt32Memory0;
70
- }
71
-
72
- let WASM_VECTOR_LEN = 0;
73
-
74
- const cachedTextEncoder = new TextEncoder('utf-8');
75
-
76
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
77
- ? function (arg, view) {
78
- return cachedTextEncoder.encodeInto(arg, view);
79
- }
80
- : function (arg, view) {
81
- const buf = cachedTextEncoder.encode(arg);
82
- view.set(buf);
83
- return {
84
- read: arg.length,
85
- written: buf.length
86
- };
87
- });
88
-
89
- function passStringToWasm0(arg, malloc, realloc) {
90
-
91
- if (realloc === undefined) {
92
- const buf = cachedTextEncoder.encode(arg);
93
- const ptr = malloc(buf.length);
94
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
95
- WASM_VECTOR_LEN = buf.length;
96
- return ptr;
97
- }
98
-
99
- let len = arg.length;
100
- let ptr = malloc(len);
101
-
102
- const mem = getUint8Memory0();
103
-
104
- let offset = 0;
105
-
106
- for (; offset < len; offset++) {
107
- const code = arg.charCodeAt(offset);
108
- if (code > 0x7F) break;
109
- mem[ptr + offset] = code;
110
- }
111
-
112
- if (offset !== len) {
113
- if (offset !== 0) {
114
- arg = arg.slice(offset);
115
- }
116
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
117
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
118
- const ret = encodeString(arg, view);
119
-
120
- offset += ret.written;
121
- }
122
-
123
- WASM_VECTOR_LEN = offset;
124
- return ptr;
125
- }
126
-
127
- function debugString(val) {
128
- // primitive types
129
- const type = typeof val;
130
- if (type == 'number' || type == 'boolean' || val == null) {
131
- return `${val}`;
132
- }
133
- if (type == 'string') {
134
- return `"${val}"`;
135
- }
136
- if (type == 'symbol') {
137
- const description = val.description;
138
- if (description == null) {
139
- return 'Symbol';
140
- } else {
141
- return `Symbol(${description})`;
142
- }
143
- }
144
- if (type == 'function') {
145
- const name = val.name;
146
- if (typeof name == 'string' && name.length > 0) {
147
- return `Function(${name})`;
148
- } else {
149
- return 'Function';
150
- }
151
- }
152
- // objects
153
- if (Array.isArray(val)) {
154
- const length = val.length;
155
- let debug = '[';
156
- if (length > 0) {
157
- debug += debugString(val[0]);
158
- }
159
- for(let i = 1; i < length; i++) {
160
- debug += ', ' + debugString(val[i]);
161
- }
162
- debug += ']';
163
- return debug;
164
- }
165
- // Test for built-in
166
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
167
- let className;
168
- if (builtInMatches.length > 1) {
169
- className = builtInMatches[1];
170
- } else {
171
- // Failed to match the standard '[object ClassName]'
172
- return toString.call(val);
173
- }
174
- if (className == 'Object') {
175
- // we're a user defined class or Object
176
- // JSON.stringify avoids problems with cycles, and is generally much
177
- // easier than looping through ownProperties of `val`.
178
- try {
179
- return 'Object(' + JSON.stringify(val) + ')';
180
- } catch (_) {
181
- return 'Object';
182
- }
183
- }
184
- // errors
185
- if (val instanceof Error) {
186
- return `${val.name}: ${val.message}\n${val.stack}`;
187
- }
188
- // TODO we could test for more things here, like `Set`s and `Map`s.
189
- return className;
190
- }
191
-
192
- const CLOSURE_DTORS = new FinalizationRegistry(state => {
193
- wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b)
194
- });
195
-
196
- function makeMutClosure(arg0, arg1, dtor, f) {
197
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
198
- const real = (...args) => {
199
- // First up with a closure we increment the internal reference
200
- // count. This ensures that the Rust closure environment won't
201
- // be deallocated while we're invoking it.
202
- state.cnt++;
203
- const a = state.a;
204
- state.a = 0;
205
- try {
206
- return f(a, state.b, ...args);
207
- } finally {
208
- if (--state.cnt === 0) {
209
- wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
210
- CLOSURE_DTORS.unregister(state)
211
- } else {
212
- state.a = a;
213
- }
214
- }
215
- };
216
- real.original = state;
217
- CLOSURE_DTORS.register(real, state, state);
218
- return real;
219
- }
220
- function __wbg_adapter_24(arg0, arg1, arg2) {
221
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hec2c25870f800c50(arg0, arg1, addHeapObject(arg2));
222
- }
223
-
224
- function __wbg_adapter_27(arg0, arg1) {
225
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9e22d4681ba69550(arg0, arg1);
226
- }
227
-
228
- function __wbg_adapter_30(arg0, arg1) {
229
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb7e49a16010dc737(arg0, arg1);
230
- }
231
-
232
- /**
233
- * The main entrypoint which sets up global state.
234
- */
235
- export function main() {
236
- wasm.main();
237
- }
238
-
239
- let cachedFloat32Memory0 = null;
240
-
241
- function getFloat32Memory0() {
242
- if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) {
243
- cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer);
244
- }
245
- return cachedFloat32Memory0;
246
- }
247
-
248
- function passArrayF32ToWasm0(arg, malloc) {
249
- const ptr = malloc(arg.length * 4);
250
- getFloat32Memory0().set(arg, ptr / 4);
251
- WASM_VECTOR_LEN = arg.length;
252
- return ptr;
253
- }
254
-
255
- function _assertClass(instance, klass) {
256
- if (!(instance instanceof klass)) {
257
- throw new Error(`expected instance of ${klass.name}`);
258
- }
259
- return instance.ptr;
260
- }
261
-
262
- function handleError(f, args) {
263
- try {
264
- return f.apply(this, args);
265
- } catch (e) {
266
- wasm.__wbindgen_exn_store(addHeapObject(e));
267
- }
268
- }
269
-
270
- function getArrayF32FromWasm0(ptr, len) {
271
- return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len);
272
- }
273
- function __wbg_adapter_159(arg0, arg1, arg2, arg3) {
274
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h1ea5665e5f896f58(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
275
- }
276
-
277
- /**
278
- * An enum representing the extension of a chord.
279
- *
280
- * Extensions are not really "special" in the sense that they do not change how the
281
- * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
282
- * and the chord is still interpreted as a major chord.
283
- */
284
- export const KordExtension = Object.freeze({
285
- /**
286
- * Sus2 extension.
287
- */
288
- Sus2:0,"0":"Sus2",
289
- /**
290
- * Sus4 extension.
291
- */
292
- Sus4:1,"1":"Sus4",
293
- /**
294
- * Flat 11 extension.
295
- */
296
- Flat11:2,"2":"Flat11",
297
- /**
298
- * Flat 13 extension.
299
- */
300
- Flat13:3,"3":"Flat13",
301
- /**
302
- * Sharp 13 extension.
303
- */
304
- Sharp13:4,"4":"Sharp13",
305
- /**
306
- * Add2 extension.
307
- */
308
- Add2:5,"5":"Add2",
309
- /**
310
- * Add4 extension.
311
- */
312
- Add4:6,"6":"Add4",
313
- /**
314
- * Add6 extension.
315
- */
316
- Add6:7,"7":"Add6",
317
- /**
318
- * Add9 extension.
319
- */
320
- Add9:8,"8":"Add9",
321
- /**
322
- * Add11 extension.
323
- */
324
- Add11:9,"9":"Add11",
325
- /**
326
- * Add13 extension.
327
- */
328
- Add13:10,"10":"Add13", });
329
- /**
330
- * An enum representing the interval between two notes.
331
- */
332
- export const KordInterval = Object.freeze({
333
- /**
334
- * A perfect unison interval.
335
- */
336
- PerfectUnison:0,"0":"PerfectUnison",
337
- /**
338
- * A diminished second interval.
339
- */
340
- DiminishedSecond:1,"1":"DiminishedSecond",
341
- /**
342
- * An augmented unison interval.
343
- */
344
- AugmentedUnison:2,"2":"AugmentedUnison",
345
- /**
346
- * A minor second interval.
347
- */
348
- MinorSecond:3,"3":"MinorSecond",
349
- /**
350
- * A major second interval.
351
- */
352
- MajorSecond:4,"4":"MajorSecond",
353
- /**
354
- * A diminished third interval.
355
- */
356
- DiminishedThird:5,"5":"DiminishedThird",
357
- /**
358
- * An augmented second interval.
359
- */
360
- AugmentedSecond:6,"6":"AugmentedSecond",
361
- /**
362
- * A minor third interval.
363
- */
364
- MinorThird:7,"7":"MinorThird",
365
- /**
366
- * A major third interval.
367
- */
368
- MajorThird:8,"8":"MajorThird",
369
- /**
370
- * A diminished fourth interval.
371
- */
372
- DiminishedFourth:9,"9":"DiminishedFourth",
373
- /**
374
- * An augmented third interval.
375
- */
376
- AugmentedThird:10,"10":"AugmentedThird",
377
- /**
378
- * A perfect fourth interval.
379
- */
380
- PerfectFourth:11,"11":"PerfectFourth",
381
- /**
382
- * An augmented fourth interval.
383
- */
384
- AugmentedFourth:12,"12":"AugmentedFourth",
385
- /**
386
- * A diminished fifth interval.
387
- */
388
- DiminishedFifth:13,"13":"DiminishedFifth",
389
- /**
390
- * A perfect fifth interval.
391
- */
392
- PerfectFifth:14,"14":"PerfectFifth",
393
- /**
394
- * A diminished sixth interval.
395
- */
396
- DiminishedSixth:15,"15":"DiminishedSixth",
397
- /**
398
- * An augmented fifth interval.
399
- */
400
- AugmentedFifth:16,"16":"AugmentedFifth",
401
- /**
402
- * A minor sixth interval.
403
- */
404
- MinorSixth:17,"17":"MinorSixth",
405
- /**
406
- * A major sixth interval.
407
- */
408
- MajorSixth:18,"18":"MajorSixth",
409
- /**
410
- * A diminished seventh interval.
411
- */
412
- DiminishedSeventh:19,"19":"DiminishedSeventh",
413
- /**
414
- * An augmented sixth interval.
415
- */
416
- AugmentedSixth:20,"20":"AugmentedSixth",
417
- /**
418
- * A minor seventh interval.
419
- */
420
- MinorSeventh:21,"21":"MinorSeventh",
421
- /**
422
- * A major seventh interval.
423
- */
424
- MajorSeventh:22,"22":"MajorSeventh",
425
- /**
426
- * A diminished octave interval.
427
- */
428
- DiminishedOctave:23,"23":"DiminishedOctave",
429
- /**
430
- * An augmented seventh interval.
431
- */
432
- AugmentedSeventh:24,"24":"AugmentedSeventh",
433
- /**
434
- * A perfect octave interval.
435
- */
436
- PerfectOctave:25,"25":"PerfectOctave",
437
- /**
438
- * An minor ninth interval.
439
- */
440
- MinorNinth:26,"26":"MinorNinth",
441
- /**
442
- * A major ninth interval.
443
- */
444
- MajorNinth:27,"27":"MajorNinth",
445
- /**
446
- * An augmented ninth interval.
447
- */
448
- AugmentedNinth:28,"28":"AugmentedNinth",
449
- /**
450
- * A diminished eleventh interval.
451
- */
452
- DiminishedEleventh:29,"29":"DiminishedEleventh",
453
- /**
454
- * A perfect eleventh interval.
455
- */
456
- PerfectEleventh:30,"30":"PerfectEleventh",
457
- /**
458
- * An augmented eleventh interval.
459
- */
460
- AugmentedEleventh:31,"31":"AugmentedEleventh",
461
- /**
462
- * A minor thirteenth interval.
463
- */
464
- MinorThirteenth:32,"32":"MinorThirteenth",
465
- /**
466
- * A major thirteenth interval.
467
- */
468
- MajorThirteenth:33,"33":"MajorThirteenth",
469
- /**
470
- * An augmented thirteenth interval.
471
- */
472
- AugmentedThirteenth:34,"34":"AugmentedThirteenth",
473
- /**
474
- * A perfect octave and perfect fifth interval.
475
- */
476
- PerfectOctaveAndPerfectFifth:35,"35":"PerfectOctaveAndPerfectFifth",
477
- /**
478
- * Two perfect octaves.
479
- */
480
- TwoPerfectOctaves:36,"36":"TwoPerfectOctaves",
481
- /**
482
- * Two perfect octaves and a major third.
483
- */
484
- TwoPerfectOctavesAndMajorThird:37,"37":"TwoPerfectOctavesAndMajorThird",
485
- /**
486
- * Two perfect octaves and a perfect fifth.
487
- */
488
- TwoPerfectOctavesAndPerfectFifth:38,"38":"TwoPerfectOctavesAndPerfectFifth",
489
- /**
490
- * Two perfect octaves and a minor sixth.
491
- */
492
- TwoPerfectOctavesAndMinorSeventh:39,"39":"TwoPerfectOctavesAndMinorSeventh",
493
- /**
494
- * Three perfect octaves.
495
- */
496
- ThreePerfectOctaves:40,"40":"ThreePerfectOctaves",
497
- /**
498
- * Three perfect octaves and a major second.
499
- */
500
- ThreePerfectOctavesAndMajorSecond:41,"41":"ThreePerfectOctavesAndMajorSecond",
501
- /**
502
- * Three perfect octaves and a major third.
503
- */
504
- ThreePerfectOctavesAndMajorThird:42,"42":"ThreePerfectOctavesAndMajorThird",
505
- /**
506
- * Three perfect octaves and an augmented fourth.
507
- */
508
- ThreePerfectOctavesAndAugmentedFourth:43,"43":"ThreePerfectOctavesAndAugmentedFourth",
509
- /**
510
- * Three perfect octaves and a perfect fifth.
511
- */
512
- ThreePerfectOctavesAndPerfectFifth:44,"44":"ThreePerfectOctavesAndPerfectFifth",
513
- /**
514
- * Three perfect octaves and a minor sixth.
515
- */
516
- ThreePerfectOctavesAndMinorSixth:45,"45":"ThreePerfectOctavesAndMinorSixth",
517
- /**
518
- * Three perfect octaves and a minor seventh.
519
- */
520
- ThreePerfectOctavesAndMinorSeventh:46,"46":"ThreePerfectOctavesAndMinorSeventh",
521
- /**
522
- * Three perfect octaves and a major seventh.
523
- */
524
- ThreePerfectOctavesAndMajorSeventh:47,"47":"ThreePerfectOctavesAndMajorSeventh", });
525
- /**
526
- * The chord modifiers.
527
- */
528
- export const KordModifier = Object.freeze({
529
- /**
530
- * Minor modifier.
531
- */
532
- Minor:0,"0":"Minor",
533
- /**
534
- * Flat 5 modifier.
535
- */
536
- Flat5:1,"1":"Flat5",
537
- /**
538
- * Sharp 5 modifier.
539
- */
540
- Augmented5:2,"2":"Augmented5",
541
- /**
542
- * Major 7 modifier.
543
- */
544
- Major7:3,"3":"Major7",
545
- /**
546
- * Dominant 7 modifier.
547
- */
548
- Dominant7:4,"4":"Dominant7",
549
- /**
550
- * Dominant 9 modifier.
551
- */
552
- Dominant9:5,"5":"Dominant9",
553
- /**
554
- * Dominant 11 modifier.
555
- */
556
- Dominant11:6,"6":"Dominant11",
557
- /**
558
- * Dominant 13 modifier.
559
- */
560
- Dominant13:7,"7":"Dominant13",
561
- /**
562
- * Flat 9 modifier.
563
- */
564
- Flat9:8,"8":"Flat9",
565
- /**
566
- * Sharp 9 modifier.
567
- */
568
- Sharp9:9,"9":"Sharp9",
569
- /**
570
- * Sharp 11 modifier.
571
- */
572
- Sharp11:10,"10":"Sharp11",
573
- /**
574
- * Diminished modifier.
575
- */
576
- Diminished:11,"11":"Diminished", });
577
-
578
- const KordChordFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordchord_free(ptr));
579
- /**
580
- * The [`Chord`] wrapper.
581
- */
582
- export class KordChord {
583
-
584
- static __wrap(ptr) {
585
- const obj = Object.create(KordChord.prototype);
586
- obj.ptr = ptr;
587
- KordChordFinalization.register(obj, obj.ptr, obj);
588
- return obj;
589
- }
590
-
591
- __destroy_into_raw() {
592
- const ptr = this.ptr;
593
- this.ptr = 0;
594
- KordChordFinalization.unregister(this);
595
- return ptr;
596
- }
597
-
598
- free() {
599
- const ptr = this.__destroy_into_raw();
600
- wasm.__wbg_kordchord_free(ptr);
601
- }
602
- /**
603
- * Creates a new [`Chord`] from a frequency.
604
- * @param {string} name
605
- * @returns {KordChord}
606
- */
607
- static parse(name) {
608
- try {
609
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
610
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
611
- const len0 = WASM_VECTOR_LEN;
612
- wasm.kordchord_parse(retptr, ptr0, len0);
613
- var r0 = getInt32Memory0()[retptr / 4 + 0];
614
- var r1 = getInt32Memory0()[retptr / 4 + 1];
615
- var r2 = getInt32Memory0()[retptr / 4 + 2];
616
- if (r2) {
617
- throw takeObject(r1);
618
- }
619
- return KordChord.__wrap(r0);
620
- } finally {
621
- wasm.__wbindgen_add_to_stack_pointer(16);
622
- }
623
- }
624
- /**
625
- * Creates a new [`Chord`] from a set of [`Note`]s.
626
- *
627
- * The [`Note`]s should be represented as a space-separated string.
628
- * E.g., `C E G`.
629
- * @param {string} notes
630
- * @returns {Array<any>}
631
- */
632
- static fromNotesString(notes) {
633
- try {
634
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
635
- const ptr0 = passStringToWasm0(notes, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
636
- const len0 = WASM_VECTOR_LEN;
637
- wasm.kordchord_fromNotesString(retptr, ptr0, len0);
638
- var r0 = getInt32Memory0()[retptr / 4 + 0];
639
- var r1 = getInt32Memory0()[retptr / 4 + 1];
640
- var r2 = getInt32Memory0()[retptr / 4 + 2];
641
- if (r2) {
642
- throw takeObject(r1);
643
- }
644
- return takeObject(r0);
645
- } finally {
646
- wasm.__wbindgen_add_to_stack_pointer(16);
647
- }
648
- }
649
- /**
650
- * Creates a new [`Chord`] from a set of [`Note`]s.
651
- * @param {Array<any>} notes
652
- * @returns {Array<any>}
653
- */
654
- static fromNotes(notes) {
655
- try {
656
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
657
- wasm.kordchord_fromNotes(retptr, addHeapObject(notes));
658
- var r0 = getInt32Memory0()[retptr / 4 + 0];
659
- var r1 = getInt32Memory0()[retptr / 4 + 1];
660
- var r2 = getInt32Memory0()[retptr / 4 + 2];
661
- if (r2) {
662
- throw takeObject(r1);
663
- }
664
- return takeObject(r0);
665
- } finally {
666
- wasm.__wbindgen_add_to_stack_pointer(16);
667
- }
668
- }
669
- /**
670
- * Returns the [`Chord`]'s friendly name.
671
- * @returns {string}
672
- */
673
- name() {
674
- try {
675
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
676
- wasm.kordchord_name(retptr, this.ptr);
677
- var r0 = getInt32Memory0()[retptr / 4 + 0];
678
- var r1 = getInt32Memory0()[retptr / 4 + 1];
679
- return getStringFromWasm0(r0, r1);
680
- } finally {
681
- wasm.__wbindgen_add_to_stack_pointer(16);
682
- wasm.__wbindgen_free(r0, r1);
683
- }
684
- }
685
- /**
686
- * Returns the [`Chord`]'s precise name.
687
- * @returns {string}
688
- */
689
- preciseName() {
690
- try {
691
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
692
- wasm.kordchord_preciseName(retptr, this.ptr);
693
- var r0 = getInt32Memory0()[retptr / 4 + 0];
694
- var r1 = getInt32Memory0()[retptr / 4 + 1];
695
- return getStringFromWasm0(r0, r1);
696
- } finally {
697
- wasm.__wbindgen_add_to_stack_pointer(16);
698
- wasm.__wbindgen_free(r0, r1);
699
- }
700
- }
701
- /**
702
- * Returns the [`Chord`] as a string (same as `precise_name`).
703
- * @returns {string}
704
- */
705
- toString() {
706
- try {
707
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
708
- wasm.kordchord_preciseName(retptr, this.ptr);
709
- var r0 = getInt32Memory0()[retptr / 4 + 0];
710
- var r1 = getInt32Memory0()[retptr / 4 + 1];
711
- return getStringFromWasm0(r0, r1);
712
- } finally {
713
- wasm.__wbindgen_add_to_stack_pointer(16);
714
- wasm.__wbindgen_free(r0, r1);
715
- }
716
- }
717
- /**
718
- * Returns the [`Chord`]'s description.
719
- * @returns {string}
720
- */
721
- description() {
722
- try {
723
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
724
- wasm.kordchord_description(retptr, this.ptr);
725
- var r0 = getInt32Memory0()[retptr / 4 + 0];
726
- var r1 = getInt32Memory0()[retptr / 4 + 1];
727
- return getStringFromWasm0(r0, r1);
728
- } finally {
729
- wasm.__wbindgen_add_to_stack_pointer(16);
730
- wasm.__wbindgen_free(r0, r1);
731
- }
732
- }
733
- /**
734
- * Returns the [`Chord`]'s display text.
735
- * @returns {string}
736
- */
737
- display() {
738
- try {
739
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
740
- wasm.kordchord_display(retptr, this.ptr);
741
- var r0 = getInt32Memory0()[retptr / 4 + 0];
742
- var r1 = getInt32Memory0()[retptr / 4 + 1];
743
- return getStringFromWasm0(r0, r1);
744
- } finally {
745
- wasm.__wbindgen_add_to_stack_pointer(16);
746
- wasm.__wbindgen_free(r0, r1);
747
- }
748
- }
749
- /**
750
- * Returns the [`Chord`]'s root note.
751
- * @returns {string}
752
- */
753
- root() {
754
- try {
755
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
756
- wasm.kordchord_root(retptr, this.ptr);
757
- var r0 = getInt32Memory0()[retptr / 4 + 0];
758
- var r1 = getInt32Memory0()[retptr / 4 + 1];
759
- return getStringFromWasm0(r0, r1);
760
- } finally {
761
- wasm.__wbindgen_add_to_stack_pointer(16);
762
- wasm.__wbindgen_free(r0, r1);
763
- }
764
- }
765
- /**
766
- * Returns the [`Chord`]'s slash note.
767
- * @returns {string}
768
- */
769
- slash() {
770
- try {
771
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
772
- wasm.kordchord_slash(retptr, this.ptr);
773
- var r0 = getInt32Memory0()[retptr / 4 + 0];
774
- var r1 = getInt32Memory0()[retptr / 4 + 1];
775
- return getStringFromWasm0(r0, r1);
776
- } finally {
777
- wasm.__wbindgen_add_to_stack_pointer(16);
778
- wasm.__wbindgen_free(r0, r1);
779
- }
780
- }
781
- /**
782
- * Returns the [`Chord`]'s inversion.
783
- * @returns {number}
784
- */
785
- inversion() {
786
- const ret = wasm.kordchord_inversion(this.ptr);
787
- return ret;
788
- }
789
- /**
790
- * Returns whether or not the [`Chord`] is "crunchy".
791
- * @returns {boolean}
792
- */
793
- isCrunchy() {
794
- const ret = wasm.kordchord_isCrunchy(this.ptr);
795
- return ret !== 0;
796
- }
797
- /**
798
- * Returns the [`Chord`]'s chord tones.
799
- * @returns {Array<any>}
800
- */
801
- chord() {
802
- const ret = wasm.kordchord_chord(this.ptr);
803
- return takeObject(ret);
804
- }
805
- /**
806
- * Returns the [`Chord`]'s chord tones as a string.
807
- * @returns {string}
808
- */
809
- chordString() {
810
- try {
811
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
812
- wasm.kordchord_chordString(retptr, this.ptr);
813
- var r0 = getInt32Memory0()[retptr / 4 + 0];
814
- var r1 = getInt32Memory0()[retptr / 4 + 1];
815
- return getStringFromWasm0(r0, r1);
816
- } finally {
817
- wasm.__wbindgen_add_to_stack_pointer(16);
818
- wasm.__wbindgen_free(r0, r1);
819
- }
820
- }
821
- /**
822
- * Returns the [`Chord`]'s scale tones.
823
- * @returns {Array<any>}
824
- */
825
- scale() {
826
- const ret = wasm.kordchord_scale(this.ptr);
827
- return takeObject(ret);
828
- }
829
- /**
830
- * Returns the [`Chord`]'s scale tones as a string.
831
- * @returns {string}
832
- */
833
- scaleString() {
834
- try {
835
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
836
- wasm.kordchord_scaleString(retptr, this.ptr);
837
- var r0 = getInt32Memory0()[retptr / 4 + 0];
838
- var r1 = getInt32Memory0()[retptr / 4 + 1];
839
- return getStringFromWasm0(r0, r1);
840
- } finally {
841
- wasm.__wbindgen_add_to_stack_pointer(16);
842
- wasm.__wbindgen_free(r0, r1);
843
- }
844
- }
845
- /**
846
- * Returns the [`Chord`]'s modifiers.
847
- * @returns {Array<any>}
848
- */
849
- modifiers() {
850
- const ret = wasm.kordchord_modifiers(this.ptr);
851
- return takeObject(ret);
852
- }
853
- /**
854
- * Returns the [`Chord`]'s extensions.
855
- * @returns {Array<any>}
856
- */
857
- extensions() {
858
- const ret = wasm.kordchord_extensions(this.ptr);
859
- return takeObject(ret);
860
- }
861
- /**
862
- * Returns a new [`Chord`] with the inversion set to the provided value.
863
- * @param {number} inversion
864
- * @returns {KordChord}
865
- */
866
- withInversion(inversion) {
867
- const ret = wasm.kordchord_withInversion(this.ptr, inversion);
868
- return KordChord.__wrap(ret);
869
- }
870
- /**
871
- * Returns a new [`Chord`] with the slash set to the provided value.
872
- * @param {KordNote} slash
873
- * @returns {KordChord}
874
- */
875
- withSlash(slash) {
876
- _assertClass(slash, KordNote);
877
- const ret = wasm.kordchord_withSlash(this.ptr, slash.ptr);
878
- return KordChord.__wrap(ret);
879
- }
880
- /**
881
- * Returns a new [`Chord`] with the octave of the root set to the provided value.
882
- * @param {number} octave
883
- * @returns {KordChord}
884
- */
885
- withOctave(octave) {
886
- try {
887
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
888
- wasm.kordchord_withOctave(retptr, this.ptr, octave);
889
- var r0 = getInt32Memory0()[retptr / 4 + 0];
890
- var r1 = getInt32Memory0()[retptr / 4 + 1];
891
- var r2 = getInt32Memory0()[retptr / 4 + 2];
892
- if (r2) {
893
- throw takeObject(r1);
894
- }
895
- return KordChord.__wrap(r0);
896
- } finally {
897
- wasm.__wbindgen_add_to_stack_pointer(16);
898
- }
899
- }
900
- /**
901
- * Returns a new [`Chord`] with the "crunchiness" set to the provided value.
902
- * @param {boolean} is_crunchy
903
- * @returns {KordChord}
904
- */
905
- withCrunchy(is_crunchy) {
906
- const ret = wasm.kordchord_withCrunchy(this.ptr, is_crunchy);
907
- return KordChord.__wrap(ret);
908
- }
909
- /**
910
- * Plays the [`Chord`].
911
- * @param {number} delay
912
- * @param {number} length
913
- * @param {number} fade_in
914
- * @returns {Promise<void>}
915
- */
916
- play(delay, length, fade_in) {
917
- const ret = wasm.kordchord_play(this.ptr, delay, length, fade_in);
918
- return takeObject(ret);
919
- }
920
- /**
921
- * Returns the clone of the [`Chord`].
922
- * @returns {KordChord}
923
- */
924
- copy() {
925
- const ret = wasm.kordchord_copy(this.ptr);
926
- return KordChord.__wrap(ret);
927
- }
928
- /**
929
- * Returns a new [`Chord`] with the `minor` modifier.
930
- * @returns {KordChord}
931
- */
932
- minor() {
933
- const ret = wasm.kordchord_minor(this.ptr);
934
- return KordChord.__wrap(ret);
935
- }
936
- /**
937
- * Returns a new [`Chord`] with the `flat5` modifier.
938
- * @returns {KordChord}
939
- */
940
- flat5() {
941
- const ret = wasm.kordchord_flat5(this.ptr);
942
- return KordChord.__wrap(ret);
943
- }
944
- /**
945
- * Returns a new [`Chord`] with the `augmented` modifier.
946
- * @returns {KordChord}
947
- */
948
- aug() {
949
- const ret = wasm.kordchord_aug(this.ptr);
950
- return KordChord.__wrap(ret);
951
- }
952
- /**
953
- * Returns a new [`Chord`] with the `maj7` modifier.
954
- * @returns {KordChord}
955
- */
956
- maj7() {
957
- const ret = wasm.kordchord_maj7(this.ptr);
958
- return KordChord.__wrap(ret);
959
- }
960
- /**
961
- * Returns a new [`Chord`] with the `dom7` modifier.
962
- * @returns {KordChord}
963
- */
964
- seven() {
965
- const ret = wasm.kordchord_seven(this.ptr);
966
- return KordChord.__wrap(ret);
967
- }
968
- /**
969
- * Returns a new [`Chord`] with the `dom9` modifier.
970
- * @returns {KordChord}
971
- */
972
- nine() {
973
- const ret = wasm.kordchord_nine(this.ptr);
974
- return KordChord.__wrap(ret);
975
- }
976
- /**
977
- * Returns a new [`Chord`] with the `dom11` modifier.
978
- * @returns {KordChord}
979
- */
980
- eleven() {
981
- const ret = wasm.kordchord_eleven(this.ptr);
982
- return KordChord.__wrap(ret);
983
- }
984
- /**
985
- * Returns a new [`Chord`] with the `dom13` modifier.
986
- * @returns {KordChord}
987
- */
988
- thirteen() {
989
- const ret = wasm.kordchord_thirteen(this.ptr);
990
- return KordChord.__wrap(ret);
991
- }
992
- /**
993
- * Returns a new [`Chord`] with the `flat9` modifier.
994
- * @returns {KordChord}
995
- */
996
- flat9() {
997
- const ret = wasm.kordchord_flat9(this.ptr);
998
- return KordChord.__wrap(ret);
999
- }
1000
- /**
1001
- * Returns a new [`Chord`] with the `sharp9` modifier.
1002
- * @returns {KordChord}
1003
- */
1004
- sharp9() {
1005
- const ret = wasm.kordchord_sharp9(this.ptr);
1006
- return KordChord.__wrap(ret);
1007
- }
1008
- /**
1009
- * Returns a new [`Chord`] with the `sharp11` modifier.
1010
- * @returns {KordChord}
1011
- */
1012
- sharp11() {
1013
- const ret = wasm.kordchord_sharp11(this.ptr);
1014
- return KordChord.__wrap(ret);
1015
- }
1016
- /**
1017
- * Returns a new [`Chord`] with the `dim` modifier.
1018
- * @returns {KordChord}
1019
- */
1020
- dim() {
1021
- const ret = wasm.kordchord_dim(this.ptr);
1022
- return KordChord.__wrap(ret);
1023
- }
1024
- /**
1025
- * Returns a new [`Chord`] with the `halfDim` modifier.
1026
- * @returns {KordChord}
1027
- */
1028
- halfDim() {
1029
- const ret = wasm.kordchord_halfDim(this.ptr);
1030
- return KordChord.__wrap(ret);
1031
- }
1032
- /**
1033
- * Returns a new [`Chord`] with the `sus2` extension.
1034
- * @returns {KordChord}
1035
- */
1036
- sus2() {
1037
- const ret = wasm.kordchord_sus2(this.ptr);
1038
- return KordChord.__wrap(ret);
1039
- }
1040
- /**
1041
- * Returns a new [`Chord`] with the `sus4` extension.
1042
- * @returns {KordChord}
1043
- */
1044
- sus4() {
1045
- const ret = wasm.kordchord_sus4(this.ptr);
1046
- return KordChord.__wrap(ret);
1047
- }
1048
- /**
1049
- * Returns a new [`Chord`] with the `flat11` extension.
1050
- * @returns {KordChord}
1051
- */
1052
- flat11() {
1053
- const ret = wasm.kordchord_flat11(this.ptr);
1054
- return KordChord.__wrap(ret);
1055
- }
1056
- /**
1057
- * Returns a new [`Chord`] with the `flat13` extension.
1058
- * @returns {KordChord}
1059
- */
1060
- flat13() {
1061
- const ret = wasm.kordchord_flat13(this.ptr);
1062
- return KordChord.__wrap(ret);
1063
- }
1064
- /**
1065
- * Returns a new [`Chord`] with the `sharp13` extension.
1066
- * @returns {KordChord}
1067
- */
1068
- sharp13() {
1069
- const ret = wasm.kordchord_sharp13(this.ptr);
1070
- return KordChord.__wrap(ret);
1071
- }
1072
- /**
1073
- * Returns a new [`Chord`] with the `add2` extension.
1074
- * @returns {KordChord}
1075
- */
1076
- add2() {
1077
- const ret = wasm.kordchord_add2(this.ptr);
1078
- return KordChord.__wrap(ret);
1079
- }
1080
- /**
1081
- * Returns a new [`Chord`] with the `add4` extension.
1082
- * @returns {KordChord}
1083
- */
1084
- add4() {
1085
- const ret = wasm.kordchord_add4(this.ptr);
1086
- return KordChord.__wrap(ret);
1087
- }
1088
- /**
1089
- * Returns a new [`Chord`] with the `add6` extension.
1090
- * @returns {KordChord}
1091
- */
1092
- add6() {
1093
- const ret = wasm.kordchord_add6(this.ptr);
1094
- return KordChord.__wrap(ret);
1095
- }
1096
- /**
1097
- * Returns a new [`Chord`] with the `add9` extension.
1098
- * @returns {KordChord}
1099
- */
1100
- add9() {
1101
- const ret = wasm.kordchord_add9(this.ptr);
1102
- return KordChord.__wrap(ret);
1103
- }
1104
- /**
1105
- * Returns a new [`Chord`] with the `add11` extension.
1106
- * @returns {KordChord}
1107
- */
1108
- add11() {
1109
- const ret = wasm.kordchord_add11(this.ptr);
1110
- return KordChord.__wrap(ret);
1111
- }
1112
- /**
1113
- * Returns a new [`Chord`] with the `add13` extension.
1114
- * @returns {KordChord}
1115
- */
1116
- add13() {
1117
- const ret = wasm.kordchord_add13(this.ptr);
1118
- return KordChord.__wrap(ret);
1119
- }
1120
- }
1121
-
1122
- const KordNoteFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordnote_free(ptr));
1123
- /**
1124
- * The [`Note`] wrapper.
1125
- */
1126
- export class KordNote {
1127
-
1128
- static __wrap(ptr) {
1129
- const obj = Object.create(KordNote.prototype);
1130
- obj.ptr = ptr;
1131
- KordNoteFinalization.register(obj, obj.ptr, obj);
1132
- return obj;
1133
- }
1134
-
1135
- __destroy_into_raw() {
1136
- const ptr = this.ptr;
1137
- this.ptr = 0;
1138
- KordNoteFinalization.unregister(this);
1139
- return ptr;
1140
- }
1141
-
1142
- free() {
1143
- const ptr = this.__destroy_into_raw();
1144
- wasm.__wbg_kordnote_free(ptr);
1145
- }
1146
- /**
1147
- * Creates a new [`Note`] from a frequency.
1148
- * @param {string} name
1149
- * @returns {KordNote}
1150
- */
1151
- static parse(name) {
1152
- try {
1153
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1154
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1155
- const len0 = WASM_VECTOR_LEN;
1156
- wasm.kordnote_parse(retptr, ptr0, len0);
1157
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1158
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1159
- var r2 = getInt32Memory0()[retptr / 4 + 2];
1160
- if (r2) {
1161
- throw takeObject(r1);
1162
- }
1163
- return KordNote.__wrap(r0);
1164
- } finally {
1165
- wasm.__wbindgen_add_to_stack_pointer(16);
1166
- }
1167
- }
1168
- /**
1169
- * Returns [`Note`]s from audio data.
1170
- * @param {Float32Array} data
1171
- * @param {number} length_in_seconds
1172
- * @returns {Array<any>}
1173
- */
1174
- static fromAudio(data, length_in_seconds) {
1175
- try {
1176
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1177
- const ptr0 = passArrayF32ToWasm0(data, wasm.__wbindgen_malloc);
1178
- const len0 = WASM_VECTOR_LEN;
1179
- wasm.kordnote_fromAudio(retptr, ptr0, len0, length_in_seconds);
1180
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1181
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1182
- var r2 = getInt32Memory0()[retptr / 4 + 2];
1183
- if (r2) {
1184
- throw takeObject(r1);
1185
- }
1186
- return takeObject(r0);
1187
- } finally {
1188
- wasm.__wbindgen_add_to_stack_pointer(16);
1189
- }
1190
- }
1191
- /**
1192
- * Returns [`Note`]s from audio data using the ML inference algorithm.
1193
- * @param {Float32Array} data
1194
- * @param {number} length_in_seconds
1195
- * @returns {Array<any>}
1196
- */
1197
- static fromAudioMl(data, length_in_seconds) {
1198
- try {
1199
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1200
- const ptr0 = passArrayF32ToWasm0(data, wasm.__wbindgen_malloc);
1201
- const len0 = WASM_VECTOR_LEN;
1202
- wasm.kordnote_fromAudioMl(retptr, ptr0, len0, length_in_seconds);
1203
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1204
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1205
- var r2 = getInt32Memory0()[retptr / 4 + 2];
1206
- if (r2) {
1207
- throw takeObject(r1);
1208
- }
1209
- return takeObject(r0);
1210
- } finally {
1211
- wasm.__wbindgen_add_to_stack_pointer(16);
1212
- }
1213
- }
1214
- /**
1215
- * Returns the [`Note`]'s friendly name.
1216
- * @returns {string}
1217
- */
1218
- name() {
1219
- try {
1220
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1221
- wasm.kordnote_name(retptr, this.ptr);
1222
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1223
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1224
- return getStringFromWasm0(r0, r1);
1225
- } finally {
1226
- wasm.__wbindgen_add_to_stack_pointer(16);
1227
- wasm.__wbindgen_free(r0, r1);
1228
- }
1229
- }
1230
- /**
1231
- * Returns the [`Note`] represented as a string (same as `name`).
1232
- * @returns {string}
1233
- */
1234
- toString() {
1235
- try {
1236
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1237
- wasm.kordnote_toString(retptr, this.ptr);
1238
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1239
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1240
- return getStringFromWasm0(r0, r1);
1241
- } finally {
1242
- wasm.__wbindgen_add_to_stack_pointer(16);
1243
- wasm.__wbindgen_free(r0, r1);
1244
- }
1245
- }
1246
- /**
1247
- * Returns the [`Note`]'s [`NamedPitch`].
1248
- * @returns {string}
1249
- */
1250
- pitch() {
1251
- try {
1252
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1253
- wasm.kordnote_pitch(retptr, this.ptr);
1254
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1255
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1256
- return getStringFromWasm0(r0, r1);
1257
- } finally {
1258
- wasm.__wbindgen_add_to_stack_pointer(16);
1259
- wasm.__wbindgen_free(r0, r1);
1260
- }
1261
- }
1262
- /**
1263
- * Returns the [`Note`]'s [`Octave`].
1264
- * @returns {number}
1265
- */
1266
- octave() {
1267
- const ret = wasm.kordnote_octave(this.ptr);
1268
- return ret;
1269
- }
1270
- /**
1271
- * Returns the [`Note`]'s frequency.
1272
- * @returns {number}
1273
- */
1274
- frequency() {
1275
- const ret = wasm.kordnote_frequency(this.ptr);
1276
- return ret;
1277
- }
1278
- /**
1279
- * Adds the given interval to the [`Note`], producing a new [`Note`] instance.
1280
- * @param {number} interval
1281
- * @returns {KordNote}
1282
- */
1283
- addInterval(interval) {
1284
- const ret = wasm.kordnote_addInterval(this.ptr, interval);
1285
- return KordNote.__wrap(ret);
1286
- }
1287
- /**
1288
- * Subtracts the given interval from the [`Note`], producing a new [`Note`] instance.
1289
- * @param {number} interval
1290
- * @returns {KordNote}
1291
- */
1292
- subInterval(interval) {
1293
- const ret = wasm.kordnote_subInterval(this.ptr, interval);
1294
- return KordNote.__wrap(ret);
1295
- }
1296
- /**
1297
- * Computes the [`Interval`] distance between the [`Note`] and the given [`Note`].
1298
- * @param {KordNote} other
1299
- * @returns {number}
1300
- */
1301
- distanceTo(other) {
1302
- _assertClass(other, KordNote);
1303
- var ptr0 = other.__destroy_into_raw();
1304
- const ret = wasm.kordnote_distanceTo(this.ptr, ptr0);
1305
- return ret >>> 0;
1306
- }
1307
- /**
1308
- * Returns the primary (first 13) harmonic series of the [`Note`].
1309
- * @returns {Array<any>}
1310
- */
1311
- harmonicSeries() {
1312
- const ret = wasm.kordnote_harmonicSeries(this.ptr);
1313
- return takeObject(ret);
1314
- }
1315
- /**
1316
- * Returns the clone of the [`Note`].
1317
- * @returns {KordNote}
1318
- */
1319
- copy() {
1320
- const ret = wasm.kordnote_copy(this.ptr);
1321
- return KordNote.__wrap(ret);
1322
- }
1323
- }
1324
-
1325
- const KordPlaybackHandleFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordplaybackhandle_free(ptr));
1326
- /**
1327
- * A handle to a [`Chord`] playback.
1328
- *
1329
- * Should be dropped to stop the playback, or after playback is finished.
1330
- */
1331
- export class KordPlaybackHandle {
1332
-
1333
- __destroy_into_raw() {
1334
- const ptr = this.ptr;
1335
- this.ptr = 0;
1336
- KordPlaybackHandleFinalization.unregister(this);
1337
- return ptr;
1338
- }
1339
-
1340
- free() {
1341
- const ptr = this.__destroy_into_raw();
1342
- wasm.__wbg_kordplaybackhandle_free(ptr);
1343
- }
1344
- }
1345
-
1346
- async function load(module, imports) {
1347
- if (typeof Response === 'function' && module instanceof Response) {
1348
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1349
- try {
1350
- return await WebAssembly.instantiateStreaming(module, imports);
1351
-
1352
- } catch (e) {
1353
- if (module.headers.get('Content-Type') != 'application/wasm') {
1354
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1355
-
1356
- } else {
1357
- throw e;
1358
- }
1359
- }
1360
- }
1361
-
1362
- const bytes = await module.arrayBuffer();
1363
- return await WebAssembly.instantiate(bytes, imports);
1364
-
1365
- } else {
1366
- const instance = await WebAssembly.instantiate(module, imports);
1367
-
1368
- if (instance instanceof WebAssembly.Instance) {
1369
- return { instance, module };
1370
-
1371
- } else {
1372
- return instance;
1373
- }
1374
- }
1375
- }
1376
-
1377
- function getImports() {
1378
- const imports = {};
1379
- imports.wbg = {};
1380
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1381
- takeObject(arg0);
1382
- };
1383
- imports.wbg.__wbindgen_cb_drop = function(arg0) {
1384
- const obj = takeObject(arg0).original;
1385
- if (obj.cnt-- == 1) {
1386
- obj.a = 0;
1387
- return true;
1388
- }
1389
- const ret = false;
1390
- return ret;
1391
- };
1392
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1393
- const ret = getStringFromWasm0(arg0, arg1);
1394
- return addHeapObject(ret);
1395
- };
1396
- imports.wbg.__wbg_kordchord_new = function(arg0) {
1397
- const ret = KordChord.__wrap(arg0);
1398
- return addHeapObject(ret);
1399
- };
1400
- imports.wbg.__wbg_kordnote_new = function(arg0) {
1401
- const ret = KordNote.__wrap(arg0);
1402
- return addHeapObject(ret);
1403
- };
1404
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
1405
- const obj = getObject(arg1);
1406
- const ret = typeof(obj) === 'number' ? obj : undefined;
1407
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
1408
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
1409
- };
1410
- imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
1411
- const ret = new Error();
1412
- return addHeapObject(ret);
1413
- };
1414
- imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
1415
- const ret = getObject(arg1).stack;
1416
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1417
- const len0 = WASM_VECTOR_LEN;
1418
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1419
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1420
- };
1421
- imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
1422
- try {
1423
- console.error(getStringFromWasm0(arg0, arg1));
1424
- } finally {
1425
- wasm.__wbindgen_free(arg0, arg1);
1426
- }
1427
- };
1428
- imports.wbg.__wbg_clearTimeout_76877dbc010e786d = function(arg0) {
1429
- const ret = clearTimeout(takeObject(arg0));
1430
- return addHeapObject(ret);
1431
- };
1432
- imports.wbg.__wbg_setTimeout_75cb9b6991a4031d = function() { return handleError(function (arg0, arg1) {
1433
- const ret = setTimeout(getObject(arg0), arg1);
1434
- return addHeapObject(ret);
1435
- }, arguments) };
1436
- imports.wbg.__wbindgen_boolean_get = function(arg0) {
1437
- const v = getObject(arg0);
1438
- const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
1439
- return ret;
1440
- };
1441
- imports.wbg.__wbg_instanceof_Window_e266f02eee43b570 = function(arg0) {
1442
- let result;
1443
- try {
1444
- result = getObject(arg0) instanceof Window;
1445
- } catch {
1446
- result = false;
1447
- }
1448
- const ret = result;
1449
- return ret;
1450
- };
1451
- imports.wbg.__wbg_setTimeout_6609c9aa64f32bfc = function() { return handleError(function (arg0, arg1, arg2) {
1452
- const ret = getObject(arg0).setTimeout(getObject(arg1), arg2);
1453
- return ret;
1454
- }, arguments) };
1455
- imports.wbg.__wbg_destination_5dfc354bcf2eb941 = function(arg0) {
1456
- const ret = getObject(arg0).destination;
1457
- return addHeapObject(ret);
1458
- };
1459
- imports.wbg.__wbg_currentTime_d94729a1b5fd59a5 = function(arg0) {
1460
- const ret = getObject(arg0).currentTime;
1461
- return ret;
1462
- };
1463
- imports.wbg.__wbg_newwithcontextoptions_6c6a79a71ed7efa3 = function() { return handleError(function (arg0) {
1464
- const ret = new lAudioContext(getObject(arg0));
1465
- return addHeapObject(ret);
1466
- }, arguments) };
1467
- imports.wbg.__wbg_close_82409a9d656a7c26 = function() { return handleError(function (arg0) {
1468
- const ret = getObject(arg0).close();
1469
- return addHeapObject(ret);
1470
- }, arguments) };
1471
- imports.wbg.__wbg_createBuffer_d142e00390bff447 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1472
- const ret = getObject(arg0).createBuffer(arg1 >>> 0, arg2 >>> 0, arg3);
1473
- return addHeapObject(ret);
1474
- }, arguments) };
1475
- imports.wbg.__wbg_createBufferSource_1473226efd418a08 = function() { return handleError(function (arg0) {
1476
- const ret = getObject(arg0).createBufferSource();
1477
- return addHeapObject(ret);
1478
- }, arguments) };
1479
- imports.wbg.__wbg_resume_72fe7cd3e68b861a = function() { return handleError(function (arg0) {
1480
- const ret = getObject(arg0).resume();
1481
- return addHeapObject(ret);
1482
- }, arguments) };
1483
- imports.wbg.__wbindgen_number_new = function(arg0) {
1484
- const ret = arg0;
1485
- return addHeapObject(ret);
1486
- };
1487
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1488
- const obj = getObject(arg1);
1489
- const ret = typeof(obj) === 'string' ? obj : undefined;
1490
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1491
- var len0 = WASM_VECTOR_LEN;
1492
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1493
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1494
- };
1495
- imports.wbg.__wbg_setbuffer_bad384d1628a8306 = function(arg0, arg1) {
1496
- getObject(arg0).buffer = getObject(arg1);
1497
- };
1498
- imports.wbg.__wbg_setonended_15b13187aec41ac9 = function(arg0, arg1) {
1499
- getObject(arg0).onended = getObject(arg1);
1500
- };
1501
- imports.wbg.__wbg_start_9169e040a16354b9 = function() { return handleError(function (arg0, arg1) {
1502
- getObject(arg0).start(arg1);
1503
- }, arguments) };
1504
- imports.wbg.__wbg_connect_77f2f818a74097e1 = function() { return handleError(function (arg0, arg1) {
1505
- const ret = getObject(arg0).connect(getObject(arg1));
1506
- return addHeapObject(ret);
1507
- }, arguments) };
1508
- imports.wbg.__wbg_copyToChannel_9babe9bf308bffc3 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1509
- getObject(arg0).copyToChannel(getArrayF32FromWasm0(arg1, arg2), arg3);
1510
- }, arguments) };
1511
- imports.wbg.__wbg_get_27fe3dac1c4d0224 = function(arg0, arg1) {
1512
- const ret = getObject(arg0)[arg1 >>> 0];
1513
- return addHeapObject(ret);
1514
- };
1515
- imports.wbg.__wbg_length_e498fbc24f9c1d4f = function(arg0) {
1516
- const ret = getObject(arg0).length;
1517
- return ret;
1518
- };
1519
- imports.wbg.__wbg_new_b525de17f44a8943 = function() {
1520
- const ret = new Array();
1521
- return addHeapObject(ret);
1522
- };
1523
- imports.wbg.__wbg_newnoargs_2b8b6bd7753c76ba = function(arg0, arg1) {
1524
- const ret = new Function(getStringFromWasm0(arg0, arg1));
1525
- return addHeapObject(ret);
1526
- };
1527
- imports.wbg.__wbg_get_baf4855f9a986186 = function() { return handleError(function (arg0, arg1) {
1528
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
1529
- return addHeapObject(ret);
1530
- }, arguments) };
1531
- imports.wbg.__wbg_call_95d1ea488d03e4e8 = function() { return handleError(function (arg0, arg1) {
1532
- const ret = getObject(arg0).call(getObject(arg1));
1533
- return addHeapObject(ret);
1534
- }, arguments) };
1535
- imports.wbg.__wbg_new_f9876326328f45ed = function() {
1536
- const ret = new Object();
1537
- return addHeapObject(ret);
1538
- };
1539
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1540
- const ret = getObject(arg0);
1541
- return addHeapObject(ret);
1542
- };
1543
- imports.wbg.__wbg_self_e7c1f827057f6584 = function() { return handleError(function () {
1544
- const ret = self.self;
1545
- return addHeapObject(ret);
1546
- }, arguments) };
1547
- imports.wbg.__wbg_window_a09ec664e14b1b81 = function() { return handleError(function () {
1548
- const ret = window.window;
1549
- return addHeapObject(ret);
1550
- }, arguments) };
1551
- imports.wbg.__wbg_globalThis_87cbb8506fecf3a9 = function() { return handleError(function () {
1552
- const ret = globalThis.globalThis;
1553
- return addHeapObject(ret);
1554
- }, arguments) };
1555
- imports.wbg.__wbg_global_c85a9259e621f3db = function() { return handleError(function () {
1556
- const ret = global.global;
1557
- return addHeapObject(ret);
1558
- }, arguments) };
1559
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
1560
- const ret = getObject(arg0) === undefined;
1561
- return ret;
1562
- };
1563
- imports.wbg.__wbg_eval_be0434aab6074e1e = function() { return handleError(function (arg0, arg1) {
1564
- const ret = eval(getStringFromWasm0(arg0, arg1));
1565
- return addHeapObject(ret);
1566
- }, arguments) };
1567
- imports.wbg.__wbg_push_49c286f04dd3bf59 = function(arg0, arg1) {
1568
- const ret = getObject(arg0).push(getObject(arg1));
1569
- return ret;
1570
- };
1571
- imports.wbg.__wbg_call_9495de66fdbe016b = function() { return handleError(function (arg0, arg1, arg2) {
1572
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1573
- return addHeapObject(ret);
1574
- }, arguments) };
1575
- imports.wbg.__wbg_name_4e66d4cfa3e9270a = function(arg0) {
1576
- const ret = getObject(arg0).name;
1577
- return addHeapObject(ret);
1578
- };
1579
- imports.wbg.__wbg_instanceof_Object_f5a826c4da0d4a94 = function(arg0) {
1580
- let result;
1581
- try {
1582
- result = getObject(arg0) instanceof Object;
1583
- } catch {
1584
- result = false;
1585
- }
1586
- const ret = result;
1587
- return ret;
1588
- };
1589
- imports.wbg.__wbg_constructor_0c9828c8a7cf1dc6 = function(arg0) {
1590
- const ret = getObject(arg0).constructor;
1591
- return addHeapObject(ret);
1592
- };
1593
- imports.wbg.__wbg_new_9d3a9ce4282a18a8 = function(arg0, arg1) {
1594
- try {
1595
- var state0 = {a: arg0, b: arg1};
1596
- var cb0 = (arg0, arg1) => {
1597
- const a = state0.a;
1598
- state0.a = 0;
1599
- try {
1600
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1601
- } finally {
1602
- state0.a = a;
1603
- }
1604
- };
1605
- const ret = new Promise(cb0);
1606
- return addHeapObject(ret);
1607
- } finally {
1608
- state0.a = state0.b = 0;
1609
- }
1610
- };
1611
- imports.wbg.__wbg_resolve_fd40f858d9db1a04 = function(arg0) {
1612
- const ret = Promise.resolve(getObject(arg0));
1613
- return addHeapObject(ret);
1614
- };
1615
- imports.wbg.__wbg_then_ec5db6d509eb475f = function(arg0, arg1) {
1616
- const ret = getObject(arg0).then(getObject(arg1));
1617
- return addHeapObject(ret);
1618
- };
1619
- imports.wbg.__wbg_set_6aa458a4ebdb65cb = function() { return handleError(function (arg0, arg1, arg2) {
1620
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1621
- return ret;
1622
- }, arguments) };
1623
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
1624
- const ret = debugString(getObject(arg1));
1625
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1626
- const len0 = WASM_VECTOR_LEN;
1627
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1628
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1629
- };
1630
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1631
- throw new Error(getStringFromWasm0(arg0, arg1));
1632
- };
1633
- imports.wbg.__wbindgen_closure_wrapper1086 = function(arg0, arg1, arg2) {
1634
- const ret = makeMutClosure(arg0, arg1, 469, __wbg_adapter_24);
1635
- return addHeapObject(ret);
1636
- };
1637
- imports.wbg.__wbindgen_closure_wrapper1143 = function(arg0, arg1, arg2) {
1638
- const ret = makeMutClosure(arg0, arg1, 506, __wbg_adapter_27);
1639
- return addHeapObject(ret);
1640
- };
1641
- imports.wbg.__wbindgen_closure_wrapper1432 = function(arg0, arg1, arg2) {
1642
- const ret = makeMutClosure(arg0, arg1, 656, __wbg_adapter_30);
1643
- return addHeapObject(ret);
1644
- };
1645
-
1646
- return imports;
1647
- }
1648
-
1649
- function initMemory(imports, maybe_memory) {
1650
-
1651
- }
1652
-
1653
- function finalizeInit(instance, module) {
1654
- wasm = instance.exports;
1655
- init.__wbindgen_wasm_module = module;
1656
- cachedFloat32Memory0 = null;
1657
- cachedFloat64Memory0 = null;
1658
- cachedInt32Memory0 = null;
1659
- cachedUint8Memory0 = null;
1660
-
1661
- wasm.__wbindgen_start();
1662
- return wasm;
1663
- }
1664
-
1665
- function initSync(module) {
1666
- const imports = getImports();
1667
-
1668
- initMemory(imports);
1669
-
1670
- if (!(module instanceof WebAssembly.Module)) {
1671
- module = new WebAssembly.Module(module);
1672
- }
1673
-
1674
- const instance = new WebAssembly.Instance(module, imports);
1675
-
1676
- return finalizeInit(instance, module);
1677
- }
1678
-
1679
- async function init(input) {
1680
- if (typeof input === 'undefined') {
1681
- input = new URL('klib_bg.wasm', import.meta.url);
1682
- }
1683
- const imports = getImports();
1684
-
1685
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
1686
- input = fetch(input);
1687
- }
1688
-
1689
- initMemory(imports);
1690
-
1691
- const { instance, module } = await load(await input, imports);
1692
-
1693
- return finalizeInit(instance, module);
1694
- }
1695
-
1696
- export { initSync }
1697
- export default init;
1
+ import * as wasm from "./klib_bg.wasm";
2
+ import { __wbg_set_wasm } from "./klib_bg.js";
3
+ __wbg_set_wasm(wasm);
4
+ export * from "./klib_bg.js";