kordweb 0.5.13 → 0.5.15

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 (4) hide show
  1. package/klib.d.ts +65 -58
  2. package/klib.js +126 -139
  3. package/klib_bg.wasm +0 -0
  4. package/package.json +1 -1
package/klib.d.ts CHANGED
@@ -58,6 +58,59 @@ export enum KordExtension {
58
58
  Add13 = 10,
59
59
  }
60
60
  /**
61
+ * The chord modifiers.
62
+ */
63
+ export enum KordModifier {
64
+ /**
65
+ * Minor modifier.
66
+ */
67
+ Minor = 0,
68
+ /**
69
+ * Flat 5 modifier.
70
+ */
71
+ Flat5 = 1,
72
+ /**
73
+ * Sharp 5 modifier.
74
+ */
75
+ Augmented5 = 2,
76
+ /**
77
+ * Major 7 modifier.
78
+ */
79
+ Major7 = 3,
80
+ /**
81
+ * Dominant 7 modifier.
82
+ */
83
+ Dominant7 = 4,
84
+ /**
85
+ * Dominant 9 modifier.
86
+ */
87
+ Dominant9 = 5,
88
+ /**
89
+ * Dominant 11 modifier.
90
+ */
91
+ Dominant11 = 6,
92
+ /**
93
+ * Dominant 13 modifier.
94
+ */
95
+ Dominant13 = 7,
96
+ /**
97
+ * Flat 9 modifier.
98
+ */
99
+ Flat9 = 8,
100
+ /**
101
+ * Sharp 9 modifier.
102
+ */
103
+ Sharp9 = 9,
104
+ /**
105
+ * Sharp 11 modifier.
106
+ */
107
+ Sharp11 = 10,
108
+ /**
109
+ * Diminished modifier.
110
+ */
111
+ Diminished = 11,
112
+ }
113
+ /**
61
114
  * An enum representing the interval between two notes.
62
115
  */
63
116
  export enum KordInterval {
@@ -255,59 +308,6 @@ export enum KordInterval {
255
308
  ThreePerfectOctavesAndMajorSeventh = 47,
256
309
  }
257
310
  /**
258
- * The chord modifiers.
259
- */
260
- export enum KordModifier {
261
- /**
262
- * Minor modifier.
263
- */
264
- Minor = 0,
265
- /**
266
- * Flat 5 modifier.
267
- */
268
- Flat5 = 1,
269
- /**
270
- * Sharp 5 modifier.
271
- */
272
- Augmented5 = 2,
273
- /**
274
- * Major 7 modifier.
275
- */
276
- Major7 = 3,
277
- /**
278
- * Dominant 7 modifier.
279
- */
280
- Dominant7 = 4,
281
- /**
282
- * Dominant 9 modifier.
283
- */
284
- Dominant9 = 5,
285
- /**
286
- * Dominant 11 modifier.
287
- */
288
- Dominant11 = 6,
289
- /**
290
- * Dominant 13 modifier.
291
- */
292
- Dominant13 = 7,
293
- /**
294
- * Flat 9 modifier.
295
- */
296
- Flat9 = 8,
297
- /**
298
- * Sharp 9 modifier.
299
- */
300
- Sharp9 = 9,
301
- /**
302
- * Sharp 11 modifier.
303
- */
304
- Sharp11 = 10,
305
- /**
306
- * Diminished modifier.
307
- */
308
- Diminished = 11,
309
- }
310
- /**
311
311
  * The [`Chord`] wrapper.
312
312
  */
313
313
  export class KordChord {
@@ -437,9 +437,9 @@ export class KordChord {
437
437
  * @param {number} delay
438
438
  * @param {number} length
439
439
  * @param {number} fade_in
440
- * @returns {Promise<void>}
440
+ * @returns {KordPlaybackHandle}
441
441
  */
442
- play(delay: number, length: number, fade_in: number): Promise<void>;
442
+ play(delay: number, length: number, fade_in: number): KordPlaybackHandle;
443
443
  /**
444
444
  * Returns the clone of the [`Chord`].
445
445
  * @returns {KordChord}
@@ -645,6 +645,14 @@ export class KordNote {
645
645
  */
646
646
  copy(): KordNote;
647
647
  }
648
+ /**
649
+ * A handle to a [`Chord`] playback.
650
+ *
651
+ * Should be dropped to stop the playback, or after playback is finished.
652
+ */
653
+ export class KordPlaybackHandle {
654
+ free(): void;
655
+ }
648
656
 
649
657
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
650
658
 
@@ -686,8 +694,9 @@ export interface InitOutput {
686
694
  readonly kordchord_withSlash: (a: number, b: number) => number;
687
695
  readonly kordchord_withOctave: (a: number, b: number, c: number) => void;
688
696
  readonly kordchord_withCrunchy: (a: number, b: number) => number;
689
- readonly kordchord_play: (a: number, b: number, c: number, d: number) => number;
697
+ readonly kordchord_play: (a: number, b: number, c: number, d: number, e: number) => void;
690
698
  readonly kordchord_copy: (a: number) => number;
699
+ readonly __wbg_kordplaybackhandle_free: (a: number) => void;
691
700
  readonly kordchord_minor: (a: number) => number;
692
701
  readonly kordchord_flat5: (a: number) => number;
693
702
  readonly kordchord_aug: (a: number) => number;
@@ -717,12 +726,10 @@ export interface InitOutput {
717
726
  readonly __wbindgen_malloc: (a: number) => number;
718
727
  readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
719
728
  readonly __wbindgen_export_2: WebAssembly.Table;
720
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4bf4f1a270d9cb63: (a: number, b: number, c: number) => void;
721
729
  readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfb32af8e4ede5824: (a: number, b: number) => void;
722
730
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
723
731
  readonly __wbindgen_free: (a: number, b: number) => void;
724
732
  readonly __wbindgen_exn_store: (a: number) => void;
725
- readonly wasm_bindgen__convert__closures__invoke2_mut__h2d4abc1ddedd8c19: (a: number, b: number, c: number, d: number) => void;
726
733
  readonly __wbindgen_start: () => void;
727
734
  }
728
735
 
package/klib.js CHANGED
@@ -1,28 +1,6 @@
1
- import { sleep } from './snippets/kord-b47e0f234bbe2c8c/inline0.js';
2
-
3
1
  const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined));
4
2
  let wasm;
5
3
 
6
- const heap = new Array(128).fill(undefined);
7
-
8
- heap.push(undefined, null, true, false);
9
-
10
- function getObject(idx) { return heap[idx]; }
11
-
12
- let heap_next = heap.length;
13
-
14
- function dropObject(idx) {
15
- if (idx < 132) return;
16
- heap[idx] = heap_next;
17
- heap_next = idx;
18
- }
19
-
20
- function takeObject(idx) {
21
- const ret = getObject(idx);
22
- dropObject(idx);
23
- return ret;
24
- }
25
-
26
4
  const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
27
5
 
28
6
  cachedTextDecoder.decode();
@@ -40,6 +18,12 @@ function getStringFromWasm0(ptr, len) {
40
18
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
41
19
  }
42
20
 
21
+ const heap = new Array(128).fill(undefined);
22
+
23
+ heap.push(undefined, null, true, false);
24
+
25
+ let heap_next = heap.length;
26
+
43
27
  function addHeapObject(obj) {
44
28
  if (heap_next === heap.length) heap.push(heap.length + 1);
45
29
  const idx = heap_next;
@@ -49,6 +33,20 @@ function addHeapObject(obj) {
49
33
  return idx;
50
34
  }
51
35
 
36
+ function getObject(idx) { return heap[idx]; }
37
+
38
+ function dropObject(idx) {
39
+ if (idx < 132) return;
40
+ heap[idx] = heap_next;
41
+ heap_next = idx;
42
+ }
43
+
44
+ function takeObject(idx) {
45
+ const ret = getObject(idx);
46
+ dropObject(idx);
47
+ return ret;
48
+ }
49
+
52
50
  function isLikeNone(x) {
53
51
  return x === undefined || x === null;
54
52
  }
@@ -219,11 +217,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
219
217
  CLOSURE_DTORS.register(real, state, state);
220
218
  return real;
221
219
  }
222
- function __wbg_adapter_24(arg0, arg1, arg2) {
223
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4bf4f1a270d9cb63(arg0, arg1, addHeapObject(arg2));
224
- }
225
-
226
- function __wbg_adapter_27(arg0, arg1) {
220
+ function __wbg_adapter_24(arg0, arg1) {
227
221
  wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfb32af8e4ede5824(arg0, arg1);
228
222
  }
229
223
 
@@ -268,10 +262,6 @@ function handleError(f, args) {
268
262
  function getArrayF32FromWasm0(ptr, len) {
269
263
  return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len);
270
264
  }
271
- function __wbg_adapter_154(arg0, arg1, arg2, arg3) {
272
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h2d4abc1ddedd8c19(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
273
- }
274
-
275
265
  /**
276
266
  * An enum representing the extension of a chord.
277
267
  *
@@ -325,6 +315,58 @@ Add11:9,"9":"Add11",
325
315
  */
326
316
  Add13:10,"10":"Add13", });
327
317
  /**
318
+ * The chord modifiers.
319
+ */
320
+ export const KordModifier = Object.freeze({
321
+ /**
322
+ * Minor modifier.
323
+ */
324
+ Minor:0,"0":"Minor",
325
+ /**
326
+ * Flat 5 modifier.
327
+ */
328
+ Flat5:1,"1":"Flat5",
329
+ /**
330
+ * Sharp 5 modifier.
331
+ */
332
+ Augmented5:2,"2":"Augmented5",
333
+ /**
334
+ * Major 7 modifier.
335
+ */
336
+ Major7:3,"3":"Major7",
337
+ /**
338
+ * Dominant 7 modifier.
339
+ */
340
+ Dominant7:4,"4":"Dominant7",
341
+ /**
342
+ * Dominant 9 modifier.
343
+ */
344
+ Dominant9:5,"5":"Dominant9",
345
+ /**
346
+ * Dominant 11 modifier.
347
+ */
348
+ Dominant11:6,"6":"Dominant11",
349
+ /**
350
+ * Dominant 13 modifier.
351
+ */
352
+ Dominant13:7,"7":"Dominant13",
353
+ /**
354
+ * Flat 9 modifier.
355
+ */
356
+ Flat9:8,"8":"Flat9",
357
+ /**
358
+ * Sharp 9 modifier.
359
+ */
360
+ Sharp9:9,"9":"Sharp9",
361
+ /**
362
+ * Sharp 11 modifier.
363
+ */
364
+ Sharp11:10,"10":"Sharp11",
365
+ /**
366
+ * Diminished modifier.
367
+ */
368
+ Diminished:11,"11":"Diminished", });
369
+ /**
328
370
  * An enum representing the interval between two notes.
329
371
  */
330
372
  export const KordInterval = Object.freeze({
@@ -520,58 +562,6 @@ ThreePerfectOctavesAndMinorSeventh:46,"46":"ThreePerfectOctavesAndMinorSeventh",
520
562
  * Three perfect octaves and a major seventh.
521
563
  */
522
564
  ThreePerfectOctavesAndMajorSeventh:47,"47":"ThreePerfectOctavesAndMajorSeventh", });
523
- /**
524
- * The chord modifiers.
525
- */
526
- export const KordModifier = Object.freeze({
527
- /**
528
- * Minor modifier.
529
- */
530
- Minor:0,"0":"Minor",
531
- /**
532
- * Flat 5 modifier.
533
- */
534
- Flat5:1,"1":"Flat5",
535
- /**
536
- * Sharp 5 modifier.
537
- */
538
- Augmented5:2,"2":"Augmented5",
539
- /**
540
- * Major 7 modifier.
541
- */
542
- Major7:3,"3":"Major7",
543
- /**
544
- * Dominant 7 modifier.
545
- */
546
- Dominant7:4,"4":"Dominant7",
547
- /**
548
- * Dominant 9 modifier.
549
- */
550
- Dominant9:5,"5":"Dominant9",
551
- /**
552
- * Dominant 11 modifier.
553
- */
554
- Dominant11:6,"6":"Dominant11",
555
- /**
556
- * Dominant 13 modifier.
557
- */
558
- Dominant13:7,"7":"Dominant13",
559
- /**
560
- * Flat 9 modifier.
561
- */
562
- Flat9:8,"8":"Flat9",
563
- /**
564
- * Sharp 9 modifier.
565
- */
566
- Sharp9:9,"9":"Sharp9",
567
- /**
568
- * Sharp 11 modifier.
569
- */
570
- Sharp11:10,"10":"Sharp11",
571
- /**
572
- * Diminished modifier.
573
- */
574
- Diminished:11,"11":"Diminished", });
575
565
 
576
566
  const KordChordFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordchord_free(ptr));
577
567
  /**
@@ -909,11 +899,22 @@ export class KordChord {
909
899
  * @param {number} delay
910
900
  * @param {number} length
911
901
  * @param {number} fade_in
912
- * @returns {Promise<void>}
902
+ * @returns {KordPlaybackHandle}
913
903
  */
914
904
  play(delay, length, fade_in) {
915
- const ret = wasm.kordchord_play(this.ptr, delay, length, fade_in);
916
- return takeObject(ret);
905
+ try {
906
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
907
+ wasm.kordchord_play(retptr, this.ptr, delay, length, fade_in);
908
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
909
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
910
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
911
+ if (r2) {
912
+ throw takeObject(r1);
913
+ }
914
+ return KordPlaybackHandle.__wrap(r0);
915
+ } finally {
916
+ wasm.__wbindgen_add_to_stack_pointer(16);
917
+ }
917
918
  }
918
919
  /**
919
920
  * Returns the clone of the [`Chord`].
@@ -1320,6 +1321,34 @@ export class KordNote {
1320
1321
  }
1321
1322
  }
1322
1323
 
1324
+ const KordPlaybackHandleFinalization = new FinalizationRegistry(ptr => wasm.__wbg_kordplaybackhandle_free(ptr));
1325
+ /**
1326
+ * A handle to a [`Chord`] playback.
1327
+ *
1328
+ * Should be dropped to stop the playback, or after playback is finished.
1329
+ */
1330
+ export class KordPlaybackHandle {
1331
+
1332
+ static __wrap(ptr) {
1333
+ const obj = Object.create(KordPlaybackHandle.prototype);
1334
+ obj.ptr = ptr;
1335
+ KordPlaybackHandleFinalization.register(obj, obj.ptr, obj);
1336
+ return obj;
1337
+ }
1338
+
1339
+ __destroy_into_raw() {
1340
+ const ptr = this.ptr;
1341
+ this.ptr = 0;
1342
+ KordPlaybackHandleFinalization.unregister(this);
1343
+ return ptr;
1344
+ }
1345
+
1346
+ free() {
1347
+ const ptr = this.__destroy_into_raw();
1348
+ wasm.__wbg_kordplaybackhandle_free(ptr);
1349
+ }
1350
+ }
1351
+
1323
1352
  async function load(module, imports) {
1324
1353
  if (typeof Response === 'function' && module instanceof Response) {
1325
1354
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -1354,17 +1383,13 @@ async function load(module, imports) {
1354
1383
  function getImports() {
1355
1384
  const imports = {};
1356
1385
  imports.wbg = {};
1357
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1358
- takeObject(arg0);
1359
- };
1360
- imports.wbg.__wbg_sleep_ccf9b55ee0ffaf3a = function(arg0) {
1361
- const ret = sleep(arg0 >>> 0);
1362
- return addHeapObject(ret);
1363
- };
1364
1386
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1365
1387
  const ret = getStringFromWasm0(arg0, arg1);
1366
1388
  return addHeapObject(ret);
1367
1389
  };
1390
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1391
+ takeObject(arg0);
1392
+ };
1368
1393
  imports.wbg.__wbg_kordnote_new = function(arg0) {
1369
1394
  const ret = KordNote.__wrap(arg0);
1370
1395
  return addHeapObject(ret);
@@ -1373,6 +1398,12 @@ function getImports() {
1373
1398
  const ret = KordChord.__wrap(arg0);
1374
1399
  return addHeapObject(ret);
1375
1400
  };
1401
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
1402
+ const obj = getObject(arg1);
1403
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1404
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
1405
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
1406
+ };
1376
1407
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
1377
1408
  const obj = takeObject(arg0).original;
1378
1409
  if (obj.cnt-- == 1) {
@@ -1382,12 +1413,6 @@ function getImports() {
1382
1413
  const ret = false;
1383
1414
  return ret;
1384
1415
  };
1385
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
1386
- const obj = getObject(arg1);
1387
- const ret = typeof(obj) === 'number' ? obj : undefined;
1388
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
1389
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
1390
- };
1391
1416
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
1392
1417
  const ret = new Error();
1393
1418
  return addHeapObject(ret);
@@ -1541,10 +1566,6 @@ function getImports() {
1541
1566
  const ret = getObject(arg0).push(getObject(arg1));
1542
1567
  return ret;
1543
1568
  };
1544
- imports.wbg.__wbg_call_9495de66fdbe016b = function() { return handleError(function (arg0, arg1, arg2) {
1545
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1546
- return addHeapObject(ret);
1547
- }, arguments) };
1548
1569
  imports.wbg.__wbg_name_4e66d4cfa3e9270a = function(arg0) {
1549
1570
  const ret = getObject(arg0).name;
1550
1571
  return addHeapObject(ret);
@@ -1563,36 +1584,6 @@ function getImports() {
1563
1584
  const ret = getObject(arg0).constructor;
1564
1585
  return addHeapObject(ret);
1565
1586
  };
1566
- imports.wbg.__wbg_new_9d3a9ce4282a18a8 = function(arg0, arg1) {
1567
- try {
1568
- var state0 = {a: arg0, b: arg1};
1569
- var cb0 = (arg0, arg1) => {
1570
- const a = state0.a;
1571
- state0.a = 0;
1572
- try {
1573
- return __wbg_adapter_154(a, state0.b, arg0, arg1);
1574
- } finally {
1575
- state0.a = a;
1576
- }
1577
- };
1578
- const ret = new Promise(cb0);
1579
- return addHeapObject(ret);
1580
- } finally {
1581
- state0.a = state0.b = 0;
1582
- }
1583
- };
1584
- imports.wbg.__wbg_resolve_fd40f858d9db1a04 = function(arg0) {
1585
- const ret = Promise.resolve(getObject(arg0));
1586
- return addHeapObject(ret);
1587
- };
1588
- imports.wbg.__wbg_then_ec5db6d509eb475f = function(arg0, arg1) {
1589
- const ret = getObject(arg0).then(getObject(arg1));
1590
- return addHeapObject(ret);
1591
- };
1592
- imports.wbg.__wbg_then_f753623316e2873a = function(arg0, arg1, arg2) {
1593
- const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1594
- return addHeapObject(ret);
1595
- };
1596
1587
  imports.wbg.__wbg_set_6aa458a4ebdb65cb = function() { return handleError(function (arg0, arg1, arg2) {
1597
1588
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1598
1589
  return ret;
@@ -1607,12 +1598,8 @@ function getImports() {
1607
1598
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1608
1599
  throw new Error(getStringFromWasm0(arg0, arg1));
1609
1600
  };
1610
- imports.wbg.__wbindgen_closure_wrapper1158 = function(arg0, arg1, arg2) {
1611
- const ret = makeMutClosure(arg0, arg1, 520, __wbg_adapter_24);
1612
- return addHeapObject(ret);
1613
- };
1614
- imports.wbg.__wbindgen_closure_wrapper1441 = function(arg0, arg1, arg2) {
1615
- const ret = makeMutClosure(arg0, arg1, 666, __wbg_adapter_27);
1601
+ imports.wbg.__wbindgen_closure_wrapper1390 = function(arg0, arg1, arg2) {
1602
+ const ret = makeMutClosure(arg0, arg1, 641, __wbg_adapter_24);
1616
1603
  return addHeapObject(ret);
1617
1604
  };
1618
1605
 
package/klib_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Aaron Roney <twitchax@gmail.com>"
5
5
  ],
6
6
  "description": "A tool to easily explore music theory principles.",
7
- "version": "0.5.13",
7
+ "version": "0.5.15",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",