kordweb 0.5.11 → 0.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -231,7 +231,7 @@ chord.chordString(); // C4 E4 G4 Bb5 D#5
231
231
  KordChord.parse('C7b9').withOctave(2).chord().map(n => n.name()); // [ 'C2', 'D♭2', 'E2', 'G2', 'B♭2' ]
232
232
 
233
233
  // Build chords.
234
- KordChord.parse('C').min().seven().chord().map(n => n.name()); // [ 'C4', 'Eb4', 'G4', 'Bb4' ]
234
+ KordChord.parse('C').minor().seven().chord().map(n => n.name()); // [ 'C4', 'Eb4', 'G4', 'Bb4' ]
235
235
  ```
236
236
 
237
237
  ## Feature Flags
package/klib.d.ts CHANGED
@@ -5,6 +5,59 @@
5
5
  */
6
6
  export function main(): void;
7
7
  /**
8
+ * An enum representing the extension of a chord.
9
+ *
10
+ * Extensions are not really "special" in the sense that they do not change how the
11
+ * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
12
+ * and the chord is still interpreted as a major chord.
13
+ */
14
+ export enum KordExtension {
15
+ /**
16
+ * Sus2 extension.
17
+ */
18
+ Sus2 = 0,
19
+ /**
20
+ * Sus4 extension.
21
+ */
22
+ Sus4 = 1,
23
+ /**
24
+ * Flat 11 extension.
25
+ */
26
+ Flat11 = 2,
27
+ /**
28
+ * Flat 13 extension.
29
+ */
30
+ Flat13 = 3,
31
+ /**
32
+ * Sharp 13 extension.
33
+ */
34
+ Sharp13 = 4,
35
+ /**
36
+ * Add2 extension.
37
+ */
38
+ Add2 = 5,
39
+ /**
40
+ * Add4 extension.
41
+ */
42
+ Add4 = 6,
43
+ /**
44
+ * Add6 extension.
45
+ */
46
+ Add6 = 7,
47
+ /**
48
+ * Add9 extension.
49
+ */
50
+ Add9 = 8,
51
+ /**
52
+ * Add11 extension.
53
+ */
54
+ Add11 = 9,
55
+ /**
56
+ * Add13 extension.
57
+ */
58
+ Add13 = 10,
59
+ }
60
+ /**
8
61
  * An enum representing the interval between two notes.
9
62
  */
10
63
  export enum KordInterval {
@@ -202,59 +255,6 @@ export enum KordInterval {
202
255
  ThreePerfectOctavesAndMajorSeventh = 47,
203
256
  }
204
257
  /**
205
- * An enum representing the extension of a chord.
206
- *
207
- * Extensions are not really "special" in the sense that they do not change how the
208
- * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
209
- * and the chord is still interpreted as a major chord.
210
- */
211
- export enum KordExtension {
212
- /**
213
- * Sus2 extension.
214
- */
215
- Sus2 = 0,
216
- /**
217
- * Sus4 extension.
218
- */
219
- Sus4 = 1,
220
- /**
221
- * Flat 11 extension.
222
- */
223
- Flat11 = 2,
224
- /**
225
- * Flat 13 extension.
226
- */
227
- Flat13 = 3,
228
- /**
229
- * Sharp 13 extension.
230
- */
231
- Sharp13 = 4,
232
- /**
233
- * Add2 extension.
234
- */
235
- Add2 = 5,
236
- /**
237
- * Add4 extension.
238
- */
239
- Add4 = 6,
240
- /**
241
- * Add6 extension.
242
- */
243
- Add6 = 7,
244
- /**
245
- * Add9 extension.
246
- */
247
- Add9 = 8,
248
- /**
249
- * Add11 extension.
250
- */
251
- Add11 = 9,
252
- /**
253
- * Add13 extension.
254
- */
255
- Add13 = 10,
256
- }
257
- /**
258
258
  * The chord modifiers.
259
259
  */
260
260
  export enum KordModifier {
@@ -617,14 +617,24 @@ export class KordNote {
617
617
  */
618
618
  frequency(): number;
619
619
  /**
620
- * Adds the given interval to the [`Note`].
621
- *
622
- * Clones the underlying note before mutation, producing a _new_ [`KordNote`].
620
+ * Adds the given interval to the [`Note`], producing a new [`Note`] instance.
623
621
  * @param {number} interval
624
622
  * @returns {KordNote}
625
623
  */
626
624
  addInterval(interval: number): KordNote;
627
625
  /**
626
+ * Subtracts the given interval from the [`Note`], producing a new [`Note`] instance.
627
+ * @param {number} interval
628
+ * @returns {KordNote}
629
+ */
630
+ subInterval(interval: number): KordNote;
631
+ /**
632
+ * Computes the [`Interval`] distance between the [`Note`] and the given [`Note`].
633
+ * @param {KordNote} other
634
+ * @returns {number}
635
+ */
636
+ distanceTo(other: KordNote): number;
637
+ /**
628
638
  * Returns the primary (first 13) harmonic series of the [`Note`].
629
639
  * @returns {Array<any>}
630
640
  */
@@ -649,7 +659,9 @@ export interface InitOutput {
649
659
  readonly kordnote_pitch: (a: number, b: number) => void;
650
660
  readonly kordnote_octave: (a: number) => number;
651
661
  readonly kordnote_frequency: (a: number) => number;
652
- readonly kordnote_addInterval: (a: number, b: number, c: number) => void;
662
+ readonly kordnote_addInterval: (a: number, b: number) => number;
663
+ readonly kordnote_subInterval: (a: number, b: number) => number;
664
+ readonly kordnote_distanceTo: (a: number, b: number) => number;
653
665
  readonly kordnote_harmonicSeries: (a: number) => number;
654
666
  readonly kordnote_copy: (a: number) => number;
655
667
  readonly __wbg_kordchord_free: (a: number) => void;
package/klib.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { sleep } from './snippets/kord-b47e0f234bbe2c8c/inline0.js';
2
+
1
3
  const lAudioContext = (typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : undefined));
2
4
  let wasm;
3
5
 
@@ -266,10 +268,62 @@ function handleError(f, args) {
266
268
  function getArrayF32FromWasm0(ptr, len) {
267
269
  return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len);
268
270
  }
269
- function __wbg_adapter_150(arg0, arg1, arg2, arg3) {
271
+ function __wbg_adapter_154(arg0, arg1, arg2, arg3) {
270
272
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h2d4abc1ddedd8c19(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
271
273
  }
272
274
 
275
+ /**
276
+ * An enum representing the extension of a chord.
277
+ *
278
+ * Extensions are not really "special" in the sense that they do not change how the
279
+ * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
280
+ * and the chord is still interpreted as a major chord.
281
+ */
282
+ export const KordExtension = Object.freeze({
283
+ /**
284
+ * Sus2 extension.
285
+ */
286
+ Sus2:0,"0":"Sus2",
287
+ /**
288
+ * Sus4 extension.
289
+ */
290
+ Sus4:1,"1":"Sus4",
291
+ /**
292
+ * Flat 11 extension.
293
+ */
294
+ Flat11:2,"2":"Flat11",
295
+ /**
296
+ * Flat 13 extension.
297
+ */
298
+ Flat13:3,"3":"Flat13",
299
+ /**
300
+ * Sharp 13 extension.
301
+ */
302
+ Sharp13:4,"4":"Sharp13",
303
+ /**
304
+ * Add2 extension.
305
+ */
306
+ Add2:5,"5":"Add2",
307
+ /**
308
+ * Add4 extension.
309
+ */
310
+ Add4:6,"6":"Add4",
311
+ /**
312
+ * Add6 extension.
313
+ */
314
+ Add6:7,"7":"Add6",
315
+ /**
316
+ * Add9 extension.
317
+ */
318
+ Add9:8,"8":"Add9",
319
+ /**
320
+ * Add11 extension.
321
+ */
322
+ Add11:9,"9":"Add11",
323
+ /**
324
+ * Add13 extension.
325
+ */
326
+ Add13:10,"10":"Add13", });
273
327
  /**
274
328
  * An enum representing the interval between two notes.
275
329
  */
@@ -467,58 +521,6 @@ ThreePerfectOctavesAndMinorSeventh:46,"46":"ThreePerfectOctavesAndMinorSeventh",
467
521
  */
468
522
  ThreePerfectOctavesAndMajorSeventh:47,"47":"ThreePerfectOctavesAndMajorSeventh", });
469
523
  /**
470
- * An enum representing the extension of a chord.
471
- *
472
- * Extensions are not really "special" in the sense that they do not change how the
473
- * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
474
- * and the chord is still interpreted as a major chord.
475
- */
476
- export const KordExtension = Object.freeze({
477
- /**
478
- * Sus2 extension.
479
- */
480
- Sus2:0,"0":"Sus2",
481
- /**
482
- * Sus4 extension.
483
- */
484
- Sus4:1,"1":"Sus4",
485
- /**
486
- * Flat 11 extension.
487
- */
488
- Flat11:2,"2":"Flat11",
489
- /**
490
- * Flat 13 extension.
491
- */
492
- Flat13:3,"3":"Flat13",
493
- /**
494
- * Sharp 13 extension.
495
- */
496
- Sharp13:4,"4":"Sharp13",
497
- /**
498
- * Add2 extension.
499
- */
500
- Add2:5,"5":"Add2",
501
- /**
502
- * Add4 extension.
503
- */
504
- Add4:6,"6":"Add4",
505
- /**
506
- * Add6 extension.
507
- */
508
- Add6:7,"7":"Add6",
509
- /**
510
- * Add9 extension.
511
- */
512
- Add9:8,"8":"Add9",
513
- /**
514
- * Add11 extension.
515
- */
516
- Add11:9,"9":"Add11",
517
- /**
518
- * Add13 extension.
519
- */
520
- Add13:10,"10":"Add13", });
521
- /**
522
524
  * The chord modifiers.
523
525
  */
524
526
  export const KordModifier = Object.freeze({
@@ -1272,26 +1274,33 @@ export class KordNote {
1272
1274
  return ret;
1273
1275
  }
1274
1276
  /**
1275
- * Adds the given interval to the [`Note`].
1276
- *
1277
- * Clones the underlying note before mutation, producing a _new_ [`KordNote`].
1277
+ * Adds the given interval to the [`Note`], producing a new [`Note`] instance.
1278
1278
  * @param {number} interval
1279
1279
  * @returns {KordNote}
1280
1280
  */
1281
1281
  addInterval(interval) {
1282
- try {
1283
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1284
- wasm.kordnote_addInterval(retptr, this.ptr, interval);
1285
- var r0 = getInt32Memory0()[retptr / 4 + 0];
1286
- var r1 = getInt32Memory0()[retptr / 4 + 1];
1287
- var r2 = getInt32Memory0()[retptr / 4 + 2];
1288
- if (r2) {
1289
- throw takeObject(r1);
1290
- }
1291
- return KordNote.__wrap(r0);
1292
- } finally {
1293
- wasm.__wbindgen_add_to_stack_pointer(16);
1294
- }
1282
+ const ret = wasm.kordnote_addInterval(this.ptr, interval);
1283
+ return KordNote.__wrap(ret);
1284
+ }
1285
+ /**
1286
+ * Subtracts the given interval from the [`Note`], producing a new [`Note`] instance.
1287
+ * @param {number} interval
1288
+ * @returns {KordNote}
1289
+ */
1290
+ subInterval(interval) {
1291
+ const ret = wasm.kordnote_subInterval(this.ptr, interval);
1292
+ return KordNote.__wrap(ret);
1293
+ }
1294
+ /**
1295
+ * Computes the [`Interval`] distance between the [`Note`] and the given [`Note`].
1296
+ * @param {KordNote} other
1297
+ * @returns {number}
1298
+ */
1299
+ distanceTo(other) {
1300
+ _assertClass(other, KordNote);
1301
+ var ptr0 = other.__destroy_into_raw();
1302
+ const ret = wasm.kordnote_distanceTo(this.ptr, ptr0);
1303
+ return ret >>> 0;
1295
1304
  }
1296
1305
  /**
1297
1306
  * Returns the primary (first 13) harmonic series of the [`Note`].
@@ -1348,18 +1357,22 @@ function getImports() {
1348
1357
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1349
1358
  takeObject(arg0);
1350
1359
  };
1351
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1352
- const ret = getStringFromWasm0(arg0, arg1);
1360
+ imports.wbg.__wbg_sleep_ccf9b55ee0ffaf3a = function(arg0) {
1361
+ const ret = sleep(arg0 >>> 0);
1353
1362
  return addHeapObject(ret);
1354
1363
  };
1355
- imports.wbg.__wbg_kordchord_new = function(arg0) {
1356
- const ret = KordChord.__wrap(arg0);
1364
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1365
+ const ret = getStringFromWasm0(arg0, arg1);
1357
1366
  return addHeapObject(ret);
1358
1367
  };
1359
1368
  imports.wbg.__wbg_kordnote_new = function(arg0) {
1360
1369
  const ret = KordNote.__wrap(arg0);
1361
1370
  return addHeapObject(ret);
1362
1371
  };
1372
+ imports.wbg.__wbg_kordchord_new = function(arg0) {
1373
+ const ret = KordChord.__wrap(arg0);
1374
+ return addHeapObject(ret);
1375
+ };
1363
1376
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
1364
1377
  const obj = takeObject(arg0).original;
1365
1378
  if (obj.cnt-- == 1) {
@@ -1557,7 +1570,7 @@ function getImports() {
1557
1570
  const a = state0.a;
1558
1571
  state0.a = 0;
1559
1572
  try {
1560
- return __wbg_adapter_150(a, state0.b, arg0, arg1);
1573
+ return __wbg_adapter_154(a, state0.b, arg0, arg1);
1561
1574
  } finally {
1562
1575
  state0.a = a;
1563
1576
  }
@@ -1576,6 +1589,10 @@ function getImports() {
1576
1589
  const ret = getObject(arg0).then(getObject(arg1));
1577
1590
  return addHeapObject(ret);
1578
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
+ };
1579
1596
  imports.wbg.__wbg_set_6aa458a4ebdb65cb = function() { return handleError(function (arg0, arg1, arg2) {
1580
1597
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1581
1598
  return ret;
@@ -1590,12 +1607,12 @@ function getImports() {
1590
1607
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1591
1608
  throw new Error(getStringFromWasm0(arg0, arg1));
1592
1609
  };
1593
- imports.wbg.__wbindgen_closure_wrapper1082 = function(arg0, arg1, arg2) {
1594
- const ret = makeMutClosure(arg0, arg1, 475, __wbg_adapter_24);
1610
+ imports.wbg.__wbindgen_closure_wrapper1158 = function(arg0, arg1, arg2) {
1611
+ const ret = makeMutClosure(arg0, arg1, 520, __wbg_adapter_24);
1595
1612
  return addHeapObject(ret);
1596
1613
  };
1597
- imports.wbg.__wbindgen_closure_wrapper1421 = function(arg0, arg1, arg2) {
1598
- const ret = makeMutClosure(arg0, arg1, 656, __wbg_adapter_27);
1614
+ imports.wbg.__wbindgen_closure_wrapper1441 = function(arg0, arg1, arg2) {
1615
+ const ret = makeMutClosure(arg0, arg1, 666, __wbg_adapter_27);
1599
1616
  return addHeapObject(ret);
1600
1617
  };
1601
1618
 
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.11",
7
+ "version": "0.5.13",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",