kordweb 0.5.5 → 0.5.6

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 (5) hide show
  1. package/README.md +39 -1
  2. package/klib.d.ts +371 -101
  3. package/klib.js +559 -323
  4. package/klib_bg.wasm +0 -0
  5. package/package.json +1 -1
package/klib.js CHANGED
@@ -1,6 +1,26 @@
1
1
  const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined));
2
2
  let wasm;
3
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
+
4
24
  const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
5
25
 
6
26
  cachedTextDecoder.decode();
@@ -18,12 +38,6 @@ function getStringFromWasm0(ptr, len) {
18
38
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19
39
  }
20
40
 
21
- const heap = new Array(128).fill(undefined);
22
-
23
- heap.push(undefined, null, true, false);
24
-
25
- let heap_next = heap.length;
26
-
27
41
  function addHeapObject(obj) {
28
42
  if (heap_next === heap.length) heap.push(heap.length + 1);
29
43
  const idx = heap_next;
@@ -33,18 +47,81 @@ function addHeapObject(obj) {
33
47
  return idx;
34
48
  }
35
49
 
36
- function getObject(idx) { return heap[idx]; }
50
+ function isLikeNone(x) {
51
+ return x === undefined || x === null;
52
+ }
37
53
 
38
- function dropObject(idx) {
39
- if (idx < 132) return;
40
- heap[idx] = heap_next;
41
- heap_next = idx;
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;
42
61
  }
43
62
 
44
- function takeObject(idx) {
45
- const ret = getObject(idx);
46
- dropObject(idx);
47
- return ret;
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;
48
125
  }
49
126
 
50
127
  function debugString(val) {
@@ -112,70 +189,6 @@ function debugString(val) {
112
189
  return className;
113
190
  }
114
191
 
115
- let WASM_VECTOR_LEN = 0;
116
-
117
- const cachedTextEncoder = new TextEncoder('utf-8');
118
-
119
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
120
- ? function (arg, view) {
121
- return cachedTextEncoder.encodeInto(arg, view);
122
- }
123
- : function (arg, view) {
124
- const buf = cachedTextEncoder.encode(arg);
125
- view.set(buf);
126
- return {
127
- read: arg.length,
128
- written: buf.length
129
- };
130
- });
131
-
132
- function passStringToWasm0(arg, malloc, realloc) {
133
-
134
- if (realloc === undefined) {
135
- const buf = cachedTextEncoder.encode(arg);
136
- const ptr = malloc(buf.length);
137
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
138
- WASM_VECTOR_LEN = buf.length;
139
- return ptr;
140
- }
141
-
142
- let len = arg.length;
143
- let ptr = malloc(len);
144
-
145
- const mem = getUint8Memory0();
146
-
147
- let offset = 0;
148
-
149
- for (; offset < len; offset++) {
150
- const code = arg.charCodeAt(offset);
151
- if (code > 0x7F) break;
152
- mem[ptr + offset] = code;
153
- }
154
-
155
- if (offset !== len) {
156
- if (offset !== 0) {
157
- arg = arg.slice(offset);
158
- }
159
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
160
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
161
- const ret = encodeString(arg, view);
162
-
163
- offset += ret.written;
164
- }
165
-
166
- WASM_VECTOR_LEN = offset;
167
- return ptr;
168
- }
169
-
170
- let cachedInt32Memory0 = null;
171
-
172
- function getInt32Memory0() {
173
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
174
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
175
- }
176
- return cachedInt32Memory0;
177
- }
178
-
179
192
  const CLOSURE_DTORS = new FinalizationRegistry(state => {
180
193
  wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b)
181
194
  });
@@ -204,14 +217,21 @@ function makeMutClosure(arg0, arg1, dtor, f) {
204
217
  CLOSURE_DTORS.register(real, state, state);
205
218
  return real;
206
219
  }
207
- function __wbg_adapter_20(arg0, arg1, arg2) {
220
+ function __wbg_adapter_24(arg0, arg1, arg2) {
208
221
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h747aa41a80ad2697(arg0, arg1, addHeapObject(arg2));
209
222
  }
210
223
 
211
- function __wbg_adapter_23(arg0, arg1) {
224
+ function __wbg_adapter_27(arg0, arg1) {
212
225
  wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__heeae151cfd26f044(arg0, arg1);
213
226
  }
214
227
 
228
+ /**
229
+ * The main entrypoint which sets up global state.
230
+ */
231
+ export function main() {
232
+ wasm.main();
233
+ }
234
+
215
235
  let cachedFloat32Memory0 = null;
216
236
 
217
237
  function getFloat32Memory0() {
@@ -246,10 +266,311 @@ function handleError(f, args) {
246
266
  function getArrayF32FromWasm0(ptr, len) {
247
267
  return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len);
248
268
  }
249
- function __wbg_adapter_111(arg0, arg1, arg2, arg3) {
269
+ function __wbg_adapter_125(arg0, arg1, arg2, arg3) {
250
270
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h768f6593dd414d73(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
251
271
  }
252
272
 
273
+ /**
274
+ * An enum representing the interval between two notes.
275
+ */
276
+ export const KordInterval = Object.freeze({
277
+ /**
278
+ * A perfect unison interval.
279
+ */
280
+ PerfectUnison:0,"0":"PerfectUnison",
281
+ /**
282
+ * A diminished second interval.
283
+ */
284
+ DiminishedSecond:1,"1":"DiminishedSecond",
285
+ /**
286
+ * An augmented unison interval.
287
+ */
288
+ AugmentedUnison:2,"2":"AugmentedUnison",
289
+ /**
290
+ * A minor second interval.
291
+ */
292
+ MinorSecond:3,"3":"MinorSecond",
293
+ /**
294
+ * A major second interval.
295
+ */
296
+ MajorSecond:4,"4":"MajorSecond",
297
+ /**
298
+ * A diminished third interval.
299
+ */
300
+ DiminishedThird:5,"5":"DiminishedThird",
301
+ /**
302
+ * An augmented second interval.
303
+ */
304
+ AugmentedSecond:6,"6":"AugmentedSecond",
305
+ /**
306
+ * A minor third interval.
307
+ */
308
+ MinorThird:7,"7":"MinorThird",
309
+ /**
310
+ * A major third interval.
311
+ */
312
+ MajorThird:8,"8":"MajorThird",
313
+ /**
314
+ * A diminished fourth interval.
315
+ */
316
+ DiminishedFourth:9,"9":"DiminishedFourth",
317
+ /**
318
+ * An augmented third interval.
319
+ */
320
+ AugmentedThird:10,"10":"AugmentedThird",
321
+ /**
322
+ * A perfect fourth interval.
323
+ */
324
+ PerfectFourth:11,"11":"PerfectFourth",
325
+ /**
326
+ * An augmented fourth interval.
327
+ */
328
+ AugmentedFourth:12,"12":"AugmentedFourth",
329
+ /**
330
+ * A diminished fifth interval.
331
+ */
332
+ DiminishedFifth:13,"13":"DiminishedFifth",
333
+ /**
334
+ * A perfect fifth interval.
335
+ */
336
+ PerfectFifth:14,"14":"PerfectFifth",
337
+ /**
338
+ * A diminished sixth interval.
339
+ */
340
+ DiminishedSixth:15,"15":"DiminishedSixth",
341
+ /**
342
+ * An augmented fifth interval.
343
+ */
344
+ AugmentedFifth:16,"16":"AugmentedFifth",
345
+ /**
346
+ * A minor sixth interval.
347
+ */
348
+ MinorSixth:17,"17":"MinorSixth",
349
+ /**
350
+ * A major sixth interval.
351
+ */
352
+ MajorSixth:18,"18":"MajorSixth",
353
+ /**
354
+ * A diminished seventh interval.
355
+ */
356
+ DiminishedSeventh:19,"19":"DiminishedSeventh",
357
+ /**
358
+ * An augmented sixth interval.
359
+ */
360
+ AugmentedSixth:20,"20":"AugmentedSixth",
361
+ /**
362
+ * A minor seventh interval.
363
+ */
364
+ MinorSeventh:21,"21":"MinorSeventh",
365
+ /**
366
+ * A major seventh interval.
367
+ */
368
+ MajorSeventh:22,"22":"MajorSeventh",
369
+ /**
370
+ * A diminished octave interval.
371
+ */
372
+ DiminishedOctave:23,"23":"DiminishedOctave",
373
+ /**
374
+ * An augmented seventh interval.
375
+ */
376
+ AugmentedSeventh:24,"24":"AugmentedSeventh",
377
+ /**
378
+ * A perfect octave interval.
379
+ */
380
+ PerfectOctave:25,"25":"PerfectOctave",
381
+ /**
382
+ * An minor ninth interval.
383
+ */
384
+ MinorNinth:26,"26":"MinorNinth",
385
+ /**
386
+ * A major ninth interval.
387
+ */
388
+ MajorNinth:27,"27":"MajorNinth",
389
+ /**
390
+ * An augmented ninth interval.
391
+ */
392
+ AugmentedNinth:28,"28":"AugmentedNinth",
393
+ /**
394
+ * A diminished eleventh interval.
395
+ */
396
+ DiminishedEleventh:29,"29":"DiminishedEleventh",
397
+ /**
398
+ * A perfect eleventh interval.
399
+ */
400
+ PerfectEleventh:30,"30":"PerfectEleventh",
401
+ /**
402
+ * An augmented eleventh interval.
403
+ */
404
+ AugmentedEleventh:31,"31":"AugmentedEleventh",
405
+ /**
406
+ * A minor thirteenth interval.
407
+ */
408
+ MinorThirteenth:32,"32":"MinorThirteenth",
409
+ /**
410
+ * A major thirteenth interval.
411
+ */
412
+ MajorThirteenth:33,"33":"MajorThirteenth",
413
+ /**
414
+ * An augmented thirteenth interval.
415
+ */
416
+ AugmentedThirteenth:34,"34":"AugmentedThirteenth",
417
+ /**
418
+ * A perfect octave and perfect fifth interval.
419
+ */
420
+ PerfectOctaveAndPerfectFifth:35,"35":"PerfectOctaveAndPerfectFifth",
421
+ /**
422
+ * Two perfect octaves.
423
+ */
424
+ TwoPerfectOctaves:36,"36":"TwoPerfectOctaves",
425
+ /**
426
+ * Two perfect octaves and a major third.
427
+ */
428
+ TwoPerfectOctavesAndMajorThird:37,"37":"TwoPerfectOctavesAndMajorThird",
429
+ /**
430
+ * Two perfect octaves and a perfect fifth.
431
+ */
432
+ TwoPerfectOctavesAndPerfectFifth:38,"38":"TwoPerfectOctavesAndPerfectFifth",
433
+ /**
434
+ * Two perfect octaves and a minor sixth.
435
+ */
436
+ TwoPerfectOctavesAndMinorSeventh:39,"39":"TwoPerfectOctavesAndMinorSeventh",
437
+ /**
438
+ * Three perfect octaves.
439
+ */
440
+ ThreePerfectOctaves:40,"40":"ThreePerfectOctaves",
441
+ /**
442
+ * Three perfect octaves and a major second.
443
+ */
444
+ ThreePerfectOctavesAndMajorSecond:41,"41":"ThreePerfectOctavesAndMajorSecond",
445
+ /**
446
+ * Three perfect octaves and a major third.
447
+ */
448
+ ThreePerfectOctavesAndMajorThird:42,"42":"ThreePerfectOctavesAndMajorThird",
449
+ /**
450
+ * Three perfect octaves and an augmented fourth.
451
+ */
452
+ ThreePerfectOctavesAndAugmentedFourth:43,"43":"ThreePerfectOctavesAndAugmentedFourth",
453
+ /**
454
+ * Three perfect octaves and a perfect fifth.
455
+ */
456
+ ThreePerfectOctavesAndPerfectFifth:44,"44":"ThreePerfectOctavesAndPerfectFifth",
457
+ /**
458
+ * Three perfect octaves and a minor sixth.
459
+ */
460
+ ThreePerfectOctavesAndMinorSixth:45,"45":"ThreePerfectOctavesAndMinorSixth",
461
+ /**
462
+ * Three perfect octaves and a minor seventh.
463
+ */
464
+ ThreePerfectOctavesAndMinorSeventh:46,"46":"ThreePerfectOctavesAndMinorSeventh",
465
+ /**
466
+ * Three perfect octaves and a major seventh.
467
+ */
468
+ ThreePerfectOctavesAndMajorSeventh:47,"47":"ThreePerfectOctavesAndMajorSeventh", });
469
+ /**
470
+ * The chord modifiers.
471
+ */
472
+ export const KordModifier = Object.freeze({
473
+ /**
474
+ * Minor modifier.
475
+ */
476
+ Minor:0,"0":"Minor",
477
+ /**
478
+ * Flat 5 modifier.
479
+ */
480
+ Flat5:1,"1":"Flat5",
481
+ /**
482
+ * Sharp 5 modifier.
483
+ */
484
+ Augmented5:2,"2":"Augmented5",
485
+ /**
486
+ * Major 7 modifier.
487
+ */
488
+ Major7:3,"3":"Major7",
489
+ /**
490
+ * Dominant 7 modifier.
491
+ */
492
+ Dominant7:4,"4":"Dominant7",
493
+ /**
494
+ * Dominant 9 modifier.
495
+ */
496
+ Dominant9:5,"5":"Dominant9",
497
+ /**
498
+ * Dominant 11 modifier.
499
+ */
500
+ Dominant11:6,"6":"Dominant11",
501
+ /**
502
+ * Dominant 13 modifier.
503
+ */
504
+ Dominant13:7,"7":"Dominant13",
505
+ /**
506
+ * Flat 9 modifier.
507
+ */
508
+ Flat9:8,"8":"Flat9",
509
+ /**
510
+ * Sharp 9 modifier.
511
+ */
512
+ Sharp9:9,"9":"Sharp9",
513
+ /**
514
+ * Sharp 11 modifier.
515
+ */
516
+ Sharp11:10,"10":"Sharp11",
517
+ /**
518
+ * Diminished modifier.
519
+ */
520
+ Diminished:11,"11":"Diminished", });
521
+ /**
522
+ * An enum representing the extension of a chord.
523
+ *
524
+ * Extensions are not really "special" in the sense that they do not change how the
525
+ * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
526
+ * and the chord is still interpreted as a major chord.
527
+ */
528
+ export const KordExtension = Object.freeze({
529
+ /**
530
+ * Sus2 extension.
531
+ */
532
+ Sus2:0,"0":"Sus2",
533
+ /**
534
+ * Sus4 extension.
535
+ */
536
+ Sus4:1,"1":"Sus4",
537
+ /**
538
+ * Flat 11 extension.
539
+ */
540
+ Flat11:2,"2":"Flat11",
541
+ /**
542
+ * Flat 13 extension.
543
+ */
544
+ Flat13:3,"3":"Flat13",
545
+ /**
546
+ * Sharp 13 extension.
547
+ */
548
+ Sharp13:4,"4":"Sharp13",
549
+ /**
550
+ * Add2 extension.
551
+ */
552
+ Add2:5,"5":"Add2",
553
+ /**
554
+ * Add4 extension.
555
+ */
556
+ Add4:6,"6":"Add4",
557
+ /**
558
+ * Add6 extension.
559
+ */
560
+ Add6:7,"7":"Add6",
561
+ /**
562
+ * Add9 extension.
563
+ */
564
+ Add9:8,"8":"Add9",
565
+ /**
566
+ * Add11 extension.
567
+ */
568
+ Add11:9,"9":"Add11",
569
+ /**
570
+ * Add13 extension.
571
+ */
572
+ Add13:10,"10":"Add13", });
573
+
253
574
  const KordChordFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordchord_free(ptr));
254
575
  /**
255
576
  * The [`Chord`] wrapper.
@@ -302,7 +623,7 @@ export class KordChord {
302
623
  * The [`Note`]s should be represented as a space-separated string.
303
624
  * E.g., `C E G`.
304
625
  * @param {string} notes
305
- * @returns {KordChords}
626
+ * @returns {Array<any>}
306
627
  */
307
628
  static fromNotesString(notes) {
308
629
  try {
@@ -316,29 +637,27 @@ export class KordChord {
316
637
  if (r2) {
317
638
  throw takeObject(r1);
318
639
  }
319
- return KordChords.__wrap(r0);
640
+ return takeObject(r0);
320
641
  } finally {
321
642
  wasm.__wbindgen_add_to_stack_pointer(16);
322
643
  }
323
644
  }
324
645
  /**
325
646
  * Creates a new [`Chord`] from a set of [`Note`]s.
326
- * @param {KordNotes} notes
327
- * @returns {KordChords}
647
+ * @param {Array<any>} notes
648
+ * @returns {Array<any>}
328
649
  */
329
650
  static fromNotes(notes) {
330
651
  try {
331
652
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
332
- _assertClass(notes, KordNotes);
333
- var ptr0 = notes.__destroy_into_raw();
334
- wasm.kordchord_fromNotes(retptr, ptr0);
653
+ wasm.kordchord_fromNotes(retptr, addHeapObject(notes));
335
654
  var r0 = getInt32Memory0()[retptr / 4 + 0];
336
655
  var r1 = getInt32Memory0()[retptr / 4 + 1];
337
656
  var r2 = getInt32Memory0()[retptr / 4 + 2];
338
657
  if (r2) {
339
658
  throw takeObject(r1);
340
659
  }
341
- return KordChords.__wrap(r0);
660
+ return takeObject(r0);
342
661
  } finally {
343
662
  wasm.__wbindgen_add_to_stack_pointer(16);
344
663
  }
@@ -473,11 +792,11 @@ export class KordChord {
473
792
  }
474
793
  /**
475
794
  * Returns the [`Chord`]'s chord tones.
476
- * @returns {KordNotes}
795
+ * @returns {Array<any>}
477
796
  */
478
797
  chord() {
479
798
  const ret = wasm.kordchord_chord(this.ptr);
480
- return KordNotes.__wrap(ret);
799
+ return takeObject(ret);
481
800
  }
482
801
  /**
483
802
  * Returns the [`Chord`]'s chord tones as a string.
@@ -497,11 +816,11 @@ export class KordChord {
497
816
  }
498
817
  /**
499
818
  * Returns the [`Chord`]'s scale tones.
500
- * @returns {KordNotes}
819
+ * @returns {Array<any>}
501
820
  */
502
821
  scale() {
503
822
  const ret = wasm.kordchord_scale(this.ptr);
504
- return KordNotes.__wrap(ret);
823
+ return takeObject(ret);
505
824
  }
506
825
  /**
507
826
  * Returns the [`Chord`]'s scale tones as a string.
@@ -520,135 +839,87 @@ export class KordChord {
520
839
  }
521
840
  }
522
841
  /**
523
- * Plays the [`Chord`].
524
- * @param {number} delay
525
- * @param {number} length
526
- * @param {number} fade_in
527
- * @returns {Promise<void>}
842
+ * Returns the [`Chord`]'s modifiers.
843
+ * @returns {Array<any>}
528
844
  */
529
- play(delay, length, fade_in) {
530
- const ret = wasm.kordchord_play(this.ptr, delay, length, fade_in);
845
+ modifiers() {
846
+ const ret = wasm.kordchord_modifiers(this.ptr);
531
847
  return takeObject(ret);
532
848
  }
533
- }
534
-
535
- const KordChordsFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordchords_free(ptr));
536
- /**
537
- * The [`Chord`]s wrapper.
538
- */
539
- export class KordChords {
540
-
541
- static __wrap(ptr) {
542
- const obj = Object.create(KordChords.prototype);
543
- obj.ptr = ptr;
544
- KordChordsFinalization.register(obj, obj.ptr, obj);
545
- return obj;
546
- }
547
-
548
- __destroy_into_raw() {
549
- const ptr = this.ptr;
550
- this.ptr = 0;
551
- KordChordsFinalization.unregister(this);
552
- return ptr;
553
- }
554
-
555
- free() {
556
- const ptr = this.__destroy_into_raw();
557
- wasm.__wbg_kordchords_free(ptr);
849
+ /**
850
+ * Returns the [`Chord`]'s extensions.
851
+ * @returns {Array<any>}
852
+ */
853
+ extensions() {
854
+ const ret = wasm.kordchord_extensions(this.ptr);
855
+ return takeObject(ret);
558
856
  }
559
857
  /**
560
- * Gets an item from the collection.
561
- * @param {number} index
562
- * @returns {KordChord | undefined}
858
+ * Returns a new [`Chord`] with the inversion set to the provided value.
859
+ * @param {number} inversion
860
+ * @returns {KordChord}
563
861
  */
564
- get(index) {
565
- const ret = wasm.kordchords_get(this.ptr, index);
566
- return ret === 0 ? undefined : KordChord.__wrap(ret);
862
+ withInversion(inversion) {
863
+ const ret = wasm.kordchord_withInversion(this.ptr, inversion);
864
+ return KordChord.__wrap(ret);
567
865
  }
568
866
  /**
569
- * Returns the number of items in the collection.
570
- * @returns {number}
867
+ * Returns a new [`Chord`] with the slash set to the provided value.
868
+ * @param {KordNote} slash
869
+ * @returns {KordChord}
571
870
  */
572
- get length() {
573
- const ret = wasm.kordchords_length(this.ptr);
574
- return ret >>> 0;
871
+ withSlash(slash) {
872
+ _assertClass(slash, KordNote);
873
+ const ret = wasm.kordchord_withSlash(this.ptr, slash.ptr);
874
+ return KordChord.__wrap(ret);
575
875
  }
576
876
  /**
577
- * Returns the [`Chord`]s as a space-separated string.
578
- * @returns {string}
877
+ * Returns a new [`Chord`] with the octave of the root set to the provided value.
878
+ * @param {number} octave
879
+ * @returns {KordChord}
579
880
  */
580
- toString() {
881
+ withOctave(octave) {
581
882
  try {
582
883
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
583
- wasm.kordchords_toString(retptr, this.ptr);
884
+ wasm.kordchord_withOctave(retptr, this.ptr, octave);
584
885
  var r0 = getInt32Memory0()[retptr / 4 + 0];
585
886
  var r1 = getInt32Memory0()[retptr / 4 + 1];
586
- return getStringFromWasm0(r0, r1);
887
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
888
+ if (r2) {
889
+ throw takeObject(r1);
890
+ }
891
+ return KordChord.__wrap(r0);
587
892
  } finally {
588
893
  wasm.__wbindgen_add_to_stack_pointer(16);
589
- wasm.__wbindgen_free(r0, r1);
590
894
  }
591
895
  }
592
896
  /**
593
- * Returns the [`Chord`]s as an iterator.
594
- * @returns {KordChordsIterator}
897
+ * Returns a new [`Chord`] with the "crunchiness" to the provided value.
898
+ * @param {boolean} is_crunchy
899
+ * @returns {KordChord}
595
900
  */
596
- iterator() {
597
- const ret = wasm.kordchords_iterator(this.ptr);
598
- return KordChordsIterator.__wrap(ret);
901
+ withCrunchy(is_crunchy) {
902
+ const ret = wasm.kordchord_withCrunchy(this.ptr, is_crunchy);
903
+ return KordChord.__wrap(ret);
599
904
  }
600
905
  /**
601
- * Returns the [`Chord`]s as an array.
602
- * @returns {Array<any>}
906
+ * Plays the [`Chord`].
907
+ * @param {number} delay
908
+ * @param {number} length
909
+ * @param {number} fade_in
910
+ * @returns {Promise<void>}
603
911
  */
604
- toArray() {
605
- const ret = wasm.kordchords_toArray(this.ptr);
912
+ play(delay, length, fade_in) {
913
+ const ret = wasm.kordchord_play(this.ptr, delay, length, fade_in);
606
914
  return takeObject(ret);
607
915
  }
608
- }
609
-
610
- const KordChordsIteratorFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordchordsiterator_free(ptr));
611
- /**
612
- * The [`Chord`]s iterator.
613
- */
614
- export class KordChordsIterator {
615
-
616
- static __wrap(ptr) {
617
- const obj = Object.create(KordChordsIterator.prototype);
618
- obj.ptr = ptr;
619
- KordChordsIteratorFinalization.register(obj, obj.ptr, obj);
620
- return obj;
621
- }
622
-
623
- __destroy_into_raw() {
624
- const ptr = this.ptr;
625
- this.ptr = 0;
626
- KordChordsIteratorFinalization.unregister(this);
627
- return ptr;
628
- }
629
-
630
- free() {
631
- const ptr = this.__destroy_into_raw();
632
- wasm.__wbg_kordchordsiterator_free(ptr);
633
- }
634
916
  /**
635
- * Gets the next item in the collection.
636
- * @returns {any}
917
+ * Returns the clone of the [`Chord`].
918
+ * @returns {KordChord}
637
919
  */
638
- next() {
639
- try {
640
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
641
- wasm.kordchordsiterator_next(retptr, this.ptr);
642
- var r0 = getInt32Memory0()[retptr / 4 + 0];
643
- var r1 = getInt32Memory0()[retptr / 4 + 1];
644
- var r2 = getInt32Memory0()[retptr / 4 + 2];
645
- if (r2) {
646
- throw takeObject(r1);
647
- }
648
- return takeObject(r0);
649
- } finally {
650
- wasm.__wbindgen_add_to_stack_pointer(16);
651
- }
920
+ copy() {
921
+ const ret = wasm.kordchord_copy(this.ptr);
922
+ return KordChord.__wrap(ret);
652
923
  }
653
924
  }
654
925
 
@@ -702,7 +973,7 @@ export class KordNote {
702
973
  * Returns [`Note`]s from audio data.
703
974
  * @param {Float32Array} data
704
975
  * @param {number} length_in_seconds
705
- * @returns {KordNotes}
976
+ * @returns {Array<any>}
706
977
  */
707
978
  static fromAudio(data, length_in_seconds) {
708
979
  try {
@@ -716,7 +987,7 @@ export class KordNote {
716
987
  if (r2) {
717
988
  throw takeObject(r1);
718
989
  }
719
- return KordNotes.__wrap(r0);
990
+ return takeObject(r0);
720
991
  } finally {
721
992
  wasm.__wbindgen_add_to_stack_pointer(16);
722
993
  }
@@ -725,7 +996,7 @@ export class KordNote {
725
996
  * Returns [`Note`]s from audio data using the ML inference algorithm.
726
997
  * @param {Float32Array} data
727
998
  * @param {number} length_in_seconds
728
- * @returns {KordNotes}
999
+ * @returns {Array<any>}
729
1000
  */
730
1001
  static fromAudioMl(data, length_in_seconds) {
731
1002
  try {
@@ -739,7 +1010,7 @@ export class KordNote {
739
1010
  if (r2) {
740
1011
  throw takeObject(r1);
741
1012
  }
742
- return KordNotes.__wrap(r0);
1013
+ return takeObject(r0);
743
1014
  } finally {
744
1015
  wasm.__wbindgen_add_to_stack_pointer(16);
745
1016
  }
@@ -808,126 +1079,36 @@ export class KordNote {
808
1079
  const ret = wasm.kordnote_frequency(this.ptr);
809
1080
  return ret;
810
1081
  }
811
- }
812
-
813
- const KordNotesFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordnotes_free(ptr));
814
- /**
815
- * The [`Note`]s wrapper.
816
- */
817
- export class KordNotes {
818
-
819
- static __wrap(ptr) {
820
- const obj = Object.create(KordNotes.prototype);
821
- obj.ptr = ptr;
822
- KordNotesFinalization.register(obj, obj.ptr, obj);
823
- return obj;
824
- }
825
-
826
- __destroy_into_raw() {
827
- const ptr = this.ptr;
828
- this.ptr = 0;
829
- KordNotesFinalization.unregister(this);
830
- return ptr;
831
- }
832
-
833
- free() {
834
- const ptr = this.__destroy_into_raw();
835
- wasm.__wbg_kordnotes_free(ptr);
836
- }
837
- /**
838
- * Gets an item from the collection.
839
- * @param {number} index
840
- * @returns {KordNote | undefined}
841
- */
842
- get(index) {
843
- const ret = wasm.kordnotes_get(this.ptr, index);
844
- return ret === 0 ? undefined : KordNote.__wrap(ret);
845
- }
846
- /**
847
- * Returns the number of items in the collection.
848
- * @returns {number}
849
- */
850
- get length() {
851
- const ret = wasm.kordchords_length(this.ptr);
852
- return ret >>> 0;
853
- }
854
- /**
855
- * Returns the [`Note`]s as a space-separated string.
856
- * @returns {string}
857
- */
858
- toString() {
859
- try {
860
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
861
- wasm.kordnotes_toString(retptr, this.ptr);
862
- var r0 = getInt32Memory0()[retptr / 4 + 0];
863
- var r1 = getInt32Memory0()[retptr / 4 + 1];
864
- return getStringFromWasm0(r0, r1);
865
- } finally {
866
- wasm.__wbindgen_add_to_stack_pointer(16);
867
- wasm.__wbindgen_free(r0, r1);
868
- }
869
- }
870
- /**
871
- * Returns the [`Note`]s as an iterator.
872
- * @returns {KordNotesIterator}
873
- */
874
- iterator() {
875
- const ret = wasm.kordnotes_iterator(this.ptr);
876
- return KordNotesIterator.__wrap(ret);
877
- }
878
- /**
879
- * Returns the [`Note`]s as an array.
880
- * @returns {Array<any>}
881
- */
882
- toArray() {
883
- const ret = wasm.kordnotes_toArray(this.ptr);
884
- return takeObject(ret);
885
- }
886
- }
887
-
888
- const KordNotesIteratorFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordnotesiterator_free(ptr));
889
- /**
890
- * The [`Note`]s iterator.
891
- */
892
- export class KordNotesIterator {
893
-
894
- static __wrap(ptr) {
895
- const obj = Object.create(KordNotesIterator.prototype);
896
- obj.ptr = ptr;
897
- KordNotesIteratorFinalization.register(obj, obj.ptr, obj);
898
- return obj;
899
- }
900
-
901
- __destroy_into_raw() {
902
- const ptr = this.ptr;
903
- this.ptr = 0;
904
- KordNotesIteratorFinalization.unregister(this);
905
- return ptr;
906
- }
907
-
908
- free() {
909
- const ptr = this.__destroy_into_raw();
910
- wasm.__wbg_kordnotesiterator_free(ptr);
911
- }
912
1082
  /**
913
- * Gets the next item in the collection.
914
- * @returns {any}
1083
+ * Adds the given interval to the [`Note`].
1084
+ *
1085
+ * Clones the underlying note before mutation, producing a _new_ [`KordNote`].
1086
+ * @param {number} interval
1087
+ * @returns {KordNote}
915
1088
  */
916
- next() {
1089
+ addInterval(interval) {
917
1090
  try {
918
1091
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
919
- wasm.kordnotesiterator_next(retptr, this.ptr);
1092
+ wasm.kordnote_addInterval(retptr, this.ptr, interval);
920
1093
  var r0 = getInt32Memory0()[retptr / 4 + 0];
921
1094
  var r1 = getInt32Memory0()[retptr / 4 + 1];
922
1095
  var r2 = getInt32Memory0()[retptr / 4 + 2];
923
1096
  if (r2) {
924
1097
  throw takeObject(r1);
925
1098
  }
926
- return takeObject(r0);
1099
+ return KordNote.__wrap(r0);
927
1100
  } finally {
928
1101
  wasm.__wbindgen_add_to_stack_pointer(16);
929
1102
  }
930
1103
  }
1104
+ /**
1105
+ * Returns the clone of the [`Note`].
1106
+ * @returns {KordNote}
1107
+ */
1108
+ copy() {
1109
+ const ret = wasm.kordnote_copy(this.ptr);
1110
+ return KordNote.__wrap(ret);
1111
+ }
931
1112
  }
932
1113
 
933
1114
  async function load(module, imports) {
@@ -964,20 +1145,26 @@ async function load(module, imports) {
964
1145
  function getImports() {
965
1146
  const imports = {};
966
1147
  imports.wbg = {};
1148
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1149
+ takeObject(arg0);
1150
+ };
1151
+ imports.wbg.__wbg_kordchord_new = function(arg0) {
1152
+ const ret = KordChord.__wrap(arg0);
1153
+ return addHeapObject(ret);
1154
+ };
967
1155
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
968
1156
  const ret = getStringFromWasm0(arg0, arg1);
969
1157
  return addHeapObject(ret);
970
1158
  };
971
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
972
- takeObject(arg0);
973
- };
974
1159
  imports.wbg.__wbg_kordnote_new = function(arg0) {
975
1160
  const ret = KordNote.__wrap(arg0);
976
1161
  return addHeapObject(ret);
977
1162
  };
978
- imports.wbg.__wbg_kordchord_new = function(arg0) {
979
- const ret = KordChord.__wrap(arg0);
980
- return addHeapObject(ret);
1163
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
1164
+ const obj = getObject(arg1);
1165
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1166
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
1167
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
981
1168
  };
982
1169
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
983
1170
  const obj = takeObject(arg0).original;
@@ -988,6 +1175,24 @@ function getImports() {
988
1175
  const ret = false;
989
1176
  return ret;
990
1177
  };
1178
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
1179
+ const ret = new Error();
1180
+ return addHeapObject(ret);
1181
+ };
1182
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
1183
+ const ret = getObject(arg1).stack;
1184
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1185
+ const len0 = WASM_VECTOR_LEN;
1186
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1187
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1188
+ };
1189
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
1190
+ try {
1191
+ console.error(getStringFromWasm0(arg0, arg1));
1192
+ } finally {
1193
+ wasm.__wbindgen_free(arg0, arg1);
1194
+ }
1195
+ };
991
1196
  imports.wbg.__wbindgen_boolean_get = function(arg0) {
992
1197
  const v = getObject(arg0);
993
1198
  const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
@@ -1039,6 +1244,14 @@ function getImports() {
1039
1244
  const ret = arg0;
1040
1245
  return addHeapObject(ret);
1041
1246
  };
1247
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1248
+ const obj = getObject(arg1);
1249
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1250
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1251
+ var len0 = WASM_VECTOR_LEN;
1252
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1253
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1254
+ };
1042
1255
  imports.wbg.__wbg_setbuffer_bad384d1628a8306 = function(arg0, arg1) {
1043
1256
  getObject(arg0).buffer = getObject(arg1);
1044
1257
  };
@@ -1055,6 +1268,14 @@ function getImports() {
1055
1268
  imports.wbg.__wbg_copyToChannel_9babe9bf308bffc3 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1056
1269
  getObject(arg0).copyToChannel(getArrayF32FromWasm0(arg1, arg2), arg3);
1057
1270
  }, arguments) };
1271
+ imports.wbg.__wbg_get_27fe3dac1c4d0224 = function(arg0, arg1) {
1272
+ const ret = getObject(arg0)[arg1 >>> 0];
1273
+ return addHeapObject(ret);
1274
+ };
1275
+ imports.wbg.__wbg_length_e498fbc24f9c1d4f = function(arg0) {
1276
+ const ret = getObject(arg0).length;
1277
+ return ret;
1278
+ };
1058
1279
  imports.wbg.__wbg_new_b525de17f44a8943 = function() {
1059
1280
  const ret = new Array();
1060
1281
  return addHeapObject(ret);
@@ -1063,6 +1284,10 @@ function getImports() {
1063
1284
  const ret = new Function(getStringFromWasm0(arg0, arg1));
1064
1285
  return addHeapObject(ret);
1065
1286
  };
1287
+ imports.wbg.__wbg_get_baf4855f9a986186 = function() { return handleError(function (arg0, arg1) {
1288
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1289
+ return addHeapObject(ret);
1290
+ }, arguments) };
1066
1291
  imports.wbg.__wbg_call_95d1ea488d03e4e8 = function() { return handleError(function (arg0, arg1) {
1067
1292
  const ret = getObject(arg0).call(getObject(arg1));
1068
1293
  return addHeapObject(ret);
@@ -1099,10 +1324,6 @@ function getImports() {
1099
1324
  const ret = eval(getStringFromWasm0(arg0, arg1));
1100
1325
  return addHeapObject(ret);
1101
1326
  }, arguments) };
1102
- imports.wbg.__wbg_of_defbc28e6c20f48f = function(arg0, arg1) {
1103
- const ret = Array.of(getObject(arg0), getObject(arg1));
1104
- return addHeapObject(ret);
1105
- };
1106
1327
  imports.wbg.__wbg_push_49c286f04dd3bf59 = function(arg0, arg1) {
1107
1328
  const ret = getObject(arg0).push(getObject(arg1));
1108
1329
  return ret;
@@ -1111,10 +1332,24 @@ function getImports() {
1111
1332
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1112
1333
  return addHeapObject(ret);
1113
1334
  }, arguments) };
1114
- imports.wbg.__wbg_fromEntries_47a432d7604fc06a = function() { return handleError(function (arg0) {
1115
- const ret = Object.fromEntries(getObject(arg0));
1335
+ imports.wbg.__wbg_name_4e66d4cfa3e9270a = function(arg0) {
1336
+ const ret = getObject(arg0).name;
1116
1337
  return addHeapObject(ret);
1117
- }, arguments) };
1338
+ };
1339
+ imports.wbg.__wbg_instanceof_Object_f5a826c4da0d4a94 = function(arg0) {
1340
+ let result;
1341
+ try {
1342
+ result = getObject(arg0) instanceof Object;
1343
+ } catch {
1344
+ result = false;
1345
+ }
1346
+ const ret = result;
1347
+ return ret;
1348
+ };
1349
+ imports.wbg.__wbg_constructor_0c9828c8a7cf1dc6 = function(arg0) {
1350
+ const ret = getObject(arg0).constructor;
1351
+ return addHeapObject(ret);
1352
+ };
1118
1353
  imports.wbg.__wbg_new_9d3a9ce4282a18a8 = function(arg0, arg1) {
1119
1354
  try {
1120
1355
  var state0 = {a: arg0, b: arg1};
@@ -1122,7 +1357,7 @@ function getImports() {
1122
1357
  const a = state0.a;
1123
1358
  state0.a = 0;
1124
1359
  try {
1125
- return __wbg_adapter_111(a, state0.b, arg0, arg1);
1360
+ return __wbg_adapter_125(a, state0.b, arg0, arg1);
1126
1361
  } finally {
1127
1362
  state0.a = a;
1128
1363
  }
@@ -1155,12 +1390,12 @@ function getImports() {
1155
1390
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1156
1391
  throw new Error(getStringFromWasm0(arg0, arg1));
1157
1392
  };
1158
- imports.wbg.__wbindgen_closure_wrapper1037 = function(arg0, arg1, arg2) {
1159
- const ret = makeMutClosure(arg0, arg1, 468, __wbg_adapter_20);
1393
+ imports.wbg.__wbindgen_closure_wrapper1041 = function(arg0, arg1, arg2) {
1394
+ const ret = makeMutClosure(arg0, arg1, 469, __wbg_adapter_24);
1160
1395
  return addHeapObject(ret);
1161
1396
  };
1162
- imports.wbg.__wbindgen_closure_wrapper1337 = function(arg0, arg1, arg2) {
1163
- const ret = makeMutClosure(arg0, arg1, 588, __wbg_adapter_23);
1397
+ imports.wbg.__wbindgen_closure_wrapper1368 = function(arg0, arg1, arg2) {
1398
+ const ret = makeMutClosure(arg0, arg1, 606, __wbg_adapter_27);
1164
1399
  return addHeapObject(ret);
1165
1400
  };
1166
1401
 
@@ -1175,10 +1410,11 @@ function finalizeInit(instance, module) {
1175
1410
  wasm = instance.exports;
1176
1411
  init.__wbindgen_wasm_module = module;
1177
1412
  cachedFloat32Memory0 = null;
1413
+ cachedFloat64Memory0 = null;
1178
1414
  cachedInt32Memory0 = null;
1179
1415
  cachedUint8Memory0 = null;
1180
1416
 
1181
-
1417
+ wasm.__wbindgen_start();
1182
1418
  return wasm;
1183
1419
  }
1184
1420