kordweb 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,24 +19,24 @@ A music theory binary and library for Rust / JS (via WASM) ([capability playgrou
19
19
  Windows:
20
20
 
21
21
  ```powershell
22
- iwr https://github.com/twitchax/kord/releases/latest/download/kord_x86_64-pc-windows-gnu.zip
23
- Expand-Archive kord_x86_64-pc-windows-gnu.zip -DestinationPath C:\Users\%USERNAME%\AppData\Local\Programs\kord
22
+ $ iwr https://github.com/twitchax/kord/releases/latest/download/kord_x86_64-pc-windows-gnu.zip
23
+ $ Expand-Archive kord_x86_64-pc-windows-gnu.zip -DestinationPath C:\Users\%USERNAME%\AppData\Local\Programs\kord
24
24
  ```
25
25
 
26
26
  Mac OS (Apple Silicon):
27
27
 
28
28
  ```bash
29
- curl -LO https://github.com/twitchax/kord/releases/latest/download/kord_aarch64-apple-darwin.zip
30
- unzip kord_aarch64-apple-darwin.zip -d /usr/local/bin
31
- chmod a+x /usr/local/bin/kord
29
+ $ curl -LO https://github.com/twitchax/kord/releases/latest/download/kord_aarch64-apple-darwin.zip
30
+ $ unzip kord_aarch64-apple-darwin.zip -d /usr/local/bin
31
+ $ chmod a+x /usr/local/bin/kord
32
32
  ```
33
33
 
34
34
  Linux:
35
35
 
36
36
  ```bash
37
- curl -LO https://github.com/twitchax/kord/releases/latest/download/kord_x86_64-unknown-linux-gnu.zip
38
- unzip kord_x86_64-unknown-linux-gnu.zip -d /usr/local/bin
39
- chmod a+x /usr/local/bin/kord
37
+ $ curl -LO https://github.com/twitchax/kord/releases/latest/download/kord_x86_64-unknown-linux-gnu.zip
38
+ $ unzip kord_x86_64-unknown-linux-gnu.zip -d /usr/local/bin
39
+ $ chmod a+x /usr/local/bin/kord
40
40
  ```
41
41
 
42
42
  Cargo:
@@ -51,6 +51,20 @@ NPM:
51
51
  $ npm install --save kordweb
52
52
  ```
53
53
 
54
+ ### Wasmer
55
+
56
+ This has a reduced capability set (no audio input / output), but works well for some of the core use cases.
57
+
58
+ ```bash
59
+ $ wasmer install twitchax/kord
60
+ ```
61
+
62
+ Alternatively, you can use `wasmer run`.
63
+
64
+ ```bash
65
+ $ wasmer run twitchax/kord -- describe Am7
66
+ ```
67
+
54
68
  ### Help Docs
55
69
 
56
70
  ```bash
package/klib.d.ts CHANGED
@@ -1,2 +1,651 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * The chord modifiers.
5
+ */
6
+ export enum KordModifier {
7
+ /**
8
+ * Minor modifier.
9
+ */
10
+ Minor = 0,
11
+ /**
12
+ * Flat 5 modifier.
13
+ */
14
+ Flat5 = 1,
15
+ /**
16
+ * Sharp 5 modifier.
17
+ */
18
+ Augmented5 = 2,
19
+ /**
20
+ * Major 7 modifier.
21
+ */
22
+ Major7 = 3,
23
+ /**
24
+ * Dominant 7 modifier.
25
+ */
26
+ Dominant7 = 4,
27
+ /**
28
+ * Dominant 9 modifier.
29
+ */
30
+ Dominant9 = 5,
31
+ /**
32
+ * Dominant 11 modifier.
33
+ */
34
+ Dominant11 = 6,
35
+ /**
36
+ * Dominant 13 modifier.
37
+ */
38
+ Dominant13 = 7,
39
+ /**
40
+ * Flat 9 modifier.
41
+ */
42
+ Flat9 = 8,
43
+ /**
44
+ * Sharp 9 modifier.
45
+ */
46
+ Sharp9 = 9,
47
+ /**
48
+ * Sharp 11 modifier.
49
+ */
50
+ Sharp11 = 10,
51
+ /**
52
+ * Diminished modifier.
53
+ */
54
+ Diminished = 11,
55
+ }
56
+ /**
57
+ * An enum representing the extension of a chord.
58
+ *
59
+ * Extensions are not really "special" in the sense that they do not change how the
60
+ * chord is interpreted by the system. E.g., an `add2` just adds a 2 to the chord,
61
+ * and the chord is still interpreted as a major chord.
62
+ */
63
+ export enum KordExtension {
64
+ /**
65
+ * Sus2 extension.
66
+ */
67
+ Sus2 = 0,
68
+ /**
69
+ * Sus4 extension.
70
+ */
71
+ Sus4 = 1,
72
+ /**
73
+ * Flat 11 extension.
74
+ */
75
+ Flat11 = 2,
76
+ /**
77
+ * Flat 13 extension.
78
+ */
79
+ Flat13 = 3,
80
+ /**
81
+ * Sharp 13 extension.
82
+ */
83
+ Sharp13 = 4,
84
+ /**
85
+ * Add2 extension.
86
+ */
87
+ Add2 = 5,
88
+ /**
89
+ * Add4 extension.
90
+ */
91
+ Add4 = 6,
92
+ /**
93
+ * Add6 extension.
94
+ */
95
+ Add6 = 7,
96
+ /**
97
+ * Add9 extension.
98
+ */
99
+ Add9 = 8,
100
+ /**
101
+ * Add11 extension.
102
+ */
103
+ Add11 = 9,
104
+ /**
105
+ * Add13 extension.
106
+ */
107
+ Add13 = 10,
108
+ }
109
+ /**
110
+ * An enum representing the interval between two notes.
111
+ */
112
+ export enum KordInterval {
113
+ /**
114
+ * A perfect unison interval.
115
+ */
116
+ PerfectUnison = 0,
117
+ /**
118
+ * A diminished second interval.
119
+ */
120
+ DiminishedSecond = 1,
121
+ /**
122
+ * An augmented unison interval.
123
+ */
124
+ AugmentedUnison = 2,
125
+ /**
126
+ * A minor second interval.
127
+ */
128
+ MinorSecond = 3,
129
+ /**
130
+ * A major second interval.
131
+ */
132
+ MajorSecond = 4,
133
+ /**
134
+ * A diminished third interval.
135
+ */
136
+ DiminishedThird = 5,
137
+ /**
138
+ * An augmented second interval.
139
+ */
140
+ AugmentedSecond = 6,
141
+ /**
142
+ * A minor third interval.
143
+ */
144
+ MinorThird = 7,
145
+ /**
146
+ * A major third interval.
147
+ */
148
+ MajorThird = 8,
149
+ /**
150
+ * A diminished fourth interval.
151
+ */
152
+ DiminishedFourth = 9,
153
+ /**
154
+ * An augmented third interval.
155
+ */
156
+ AugmentedThird = 10,
157
+ /**
158
+ * A perfect fourth interval.
159
+ */
160
+ PerfectFourth = 11,
161
+ /**
162
+ * An augmented fourth interval.
163
+ */
164
+ AugmentedFourth = 12,
165
+ /**
166
+ * A diminished fifth interval.
167
+ */
168
+ DiminishedFifth = 13,
169
+ /**
170
+ * A perfect fifth interval.
171
+ */
172
+ PerfectFifth = 14,
173
+ /**
174
+ * A diminished sixth interval.
175
+ */
176
+ DiminishedSixth = 15,
177
+ /**
178
+ * An augmented fifth interval.
179
+ */
180
+ AugmentedFifth = 16,
181
+ /**
182
+ * A minor sixth interval.
183
+ */
184
+ MinorSixth = 17,
185
+ /**
186
+ * A major sixth interval.
187
+ */
188
+ MajorSixth = 18,
189
+ /**
190
+ * A diminished seventh interval.
191
+ */
192
+ DiminishedSeventh = 19,
193
+ /**
194
+ * An augmented sixth interval.
195
+ */
196
+ AugmentedSixth = 20,
197
+ /**
198
+ * A minor seventh interval.
199
+ */
200
+ MinorSeventh = 21,
201
+ /**
202
+ * A major seventh interval.
203
+ */
204
+ MajorSeventh = 22,
205
+ /**
206
+ * A diminished octave interval.
207
+ */
208
+ DiminishedOctave = 23,
209
+ /**
210
+ * An augmented seventh interval.
211
+ */
212
+ AugmentedSeventh = 24,
213
+ /**
214
+ * A perfect octave interval.
215
+ */
216
+ PerfectOctave = 25,
217
+ /**
218
+ * An minor ninth interval.
219
+ */
220
+ MinorNinth = 26,
221
+ /**
222
+ * A major ninth interval.
223
+ */
224
+ MajorNinth = 27,
225
+ /**
226
+ * An augmented ninth interval.
227
+ */
228
+ AugmentedNinth = 28,
229
+ /**
230
+ * A diminished eleventh interval.
231
+ */
232
+ DiminishedEleventh = 29,
233
+ /**
234
+ * A perfect eleventh interval.
235
+ */
236
+ PerfectEleventh = 30,
237
+ /**
238
+ * An augmented eleventh interval.
239
+ */
240
+ AugmentedEleventh = 31,
241
+ /**
242
+ * A minor thirteenth interval.
243
+ */
244
+ MinorThirteenth = 32,
245
+ /**
246
+ * A major thirteenth interval.
247
+ */
248
+ MajorThirteenth = 33,
249
+ /**
250
+ * An augmented thirteenth interval.
251
+ */
252
+ AugmentedThirteenth = 34,
253
+ /**
254
+ * A perfect octave and perfect fifth interval.
255
+ */
256
+ PerfectOctaveAndPerfectFifth = 35,
257
+ /**
258
+ * Two perfect octaves.
259
+ */
260
+ TwoPerfectOctaves = 36,
261
+ /**
262
+ * Two perfect octaves and a major third.
263
+ */
264
+ TwoPerfectOctavesAndMajorThird = 37,
265
+ /**
266
+ * Two perfect octaves and a perfect fifth.
267
+ */
268
+ TwoPerfectOctavesAndPerfectFifth = 38,
269
+ /**
270
+ * Two perfect octaves and a minor sixth.
271
+ */
272
+ TwoPerfectOctavesAndMinorSeventh = 39,
273
+ /**
274
+ * Three perfect octaves.
275
+ */
276
+ ThreePerfectOctaves = 40,
277
+ /**
278
+ * Three perfect octaves and a major second.
279
+ */
280
+ ThreePerfectOctavesAndMajorSecond = 41,
281
+ /**
282
+ * Three perfect octaves and a major third.
283
+ */
284
+ ThreePerfectOctavesAndMajorThird = 42,
285
+ /**
286
+ * Three perfect octaves and an augmented fourth.
287
+ */
288
+ ThreePerfectOctavesAndAugmentedFourth = 43,
289
+ /**
290
+ * Three perfect octaves and a perfect fifth.
291
+ */
292
+ ThreePerfectOctavesAndPerfectFifth = 44,
293
+ /**
294
+ * Three perfect octaves and a minor sixth.
295
+ */
296
+ ThreePerfectOctavesAndMinorSixth = 45,
297
+ /**
298
+ * Three perfect octaves and a minor seventh.
299
+ */
300
+ ThreePerfectOctavesAndMinorSeventh = 46,
301
+ /**
302
+ * Three perfect octaves and a major seventh.
303
+ */
304
+ ThreePerfectOctavesAndMajorSeventh = 47,
305
+ }
306
+ /**
307
+ * The [`Chord`] wrapper.
308
+ */
309
+ export class KordChord {
310
+ free(): void;
311
+ /**
312
+ * Creates a new [`Chord`] from a frequency.
313
+ * @param {string} name
314
+ * @returns {KordChord}
315
+ */
316
+ static parse(name: string): KordChord;
317
+ /**
318
+ * Creates a new [`Chord`] from a set of [`Note`]s.
319
+ *
320
+ * The [`Note`]s should be represented as a space-separated string.
321
+ * E.g., `C E G`.
322
+ * @param {string} notes
323
+ * @returns {Array<any>}
324
+ */
325
+ static fromNotesString(notes: string): Array<any>;
326
+ /**
327
+ * Creates a new [`Chord`] from a set of [`Note`]s.
328
+ * @param {Array<any>} notes
329
+ * @returns {Array<any>}
330
+ */
331
+ static fromNotes(notes: Array<any>): Array<any>;
332
+ /**
333
+ * Returns the [`Chord`]'s friendly name.
334
+ * @returns {string}
335
+ */
336
+ name(): string;
337
+ /**
338
+ * Returns the [`Chord`]'s precise name.
339
+ * @returns {string}
340
+ */
341
+ preciseName(): string;
342
+ /**
343
+ * Returns the [`Chord`] as a string (same as `precise_name`).
344
+ * @returns {string}
345
+ */
346
+ toString(): string;
347
+ /**
348
+ * Returns the [`Chord`]'s description.
349
+ * @returns {string}
350
+ */
351
+ description(): string;
352
+ /**
353
+ * Returns the [`Chord`]'s display text.
354
+ * @returns {string}
355
+ */
356
+ display(): string;
357
+ /**
358
+ * Returns the [`Chord`]'s root note.
359
+ * @returns {string}
360
+ */
361
+ root(): string;
362
+ /**
363
+ * Returns the [`Chord`]'s slash note.
364
+ * @returns {string}
365
+ */
366
+ slash(): string;
367
+ /**
368
+ * Returns the [`Chord`]'s inversion.
369
+ * @returns {number}
370
+ */
371
+ inversion(): number;
372
+ /**
373
+ * Returns whether or not the [`Chord`] is "crunchy".
374
+ * @returns {boolean}
375
+ */
376
+ isCrunchy(): boolean;
377
+ /**
378
+ * Returns the [`Chord`]'s chord tones.
379
+ * @returns {Array<any>}
380
+ */
381
+ chord(): Array<any>;
382
+ /**
383
+ * Returns the [`Chord`]'s chord tones as a string.
384
+ * @returns {string}
385
+ */
386
+ chordString(): string;
387
+ /**
388
+ * Returns the [`Chord`]'s scale tones.
389
+ * @returns {Array<any>}
390
+ */
391
+ scale(): Array<any>;
392
+ /**
393
+ * Returns the [`Chord`]'s scale tones as a string.
394
+ * @returns {string}
395
+ */
396
+ scaleString(): string;
397
+ /**
398
+ * Returns the [`Chord`]'s modifiers.
399
+ * @returns {Array<any>}
400
+ */
401
+ modifiers(): Array<any>;
402
+ /**
403
+ * Returns the [`Chord`]'s extensions.
404
+ * @returns {Array<any>}
405
+ */
406
+ extensions(): Array<any>;
407
+ /**
408
+ * Returns a new [`Chord`] with the inversion set to the provided value.
409
+ * @param {number} inversion
410
+ * @returns {KordChord}
411
+ */
412
+ withInversion(inversion: number): KordChord;
413
+ /**
414
+ * Returns a new [`Chord`] with the slash set to the provided value.
415
+ * @param {KordNote} slash
416
+ * @returns {KordChord}
417
+ */
418
+ withSlash(slash: KordNote): KordChord;
419
+ /**
420
+ * Returns a new [`Chord`] with the octave of the root set to the provided value.
421
+ * @param {number} octave
422
+ * @returns {KordChord}
423
+ */
424
+ withOctave(octave: number): KordChord;
425
+ /**
426
+ * Returns a new [`Chord`] with the "crunchiness" set to the provided value.
427
+ * @param {boolean} is_crunchy
428
+ * @returns {KordChord}
429
+ */
430
+ withCrunchy(is_crunchy: boolean): KordChord;
431
+ /**
432
+ * Plays the [`Chord`].
433
+ * @param {number} delay
434
+ * @param {number} length
435
+ * @param {number} fade_in
436
+ * @returns {Promise<void>}
437
+ */
438
+ play(delay: number, length: number, fade_in: number): Promise<void>;
439
+ /**
440
+ * Returns the clone of the [`Chord`].
441
+ * @returns {KordChord}
442
+ */
443
+ copy(): KordChord;
444
+ /**
445
+ * Returns a new [`Chord`] with the `minor` modifier.
446
+ * @returns {KordChord}
447
+ */
448
+ minor(): KordChord;
449
+ /**
450
+ * Returns a new [`Chord`] with the `flat5` modifier.
451
+ * @returns {KordChord}
452
+ */
453
+ flat5(): KordChord;
454
+ /**
455
+ * Returns a new [`Chord`] with the `augmented` modifier.
456
+ * @returns {KordChord}
457
+ */
458
+ aug(): KordChord;
459
+ /**
460
+ * Returns a new [`Chord`] with the `maj7` modifier.
461
+ * @returns {KordChord}
462
+ */
463
+ maj7(): KordChord;
464
+ /**
465
+ * Returns a new [`Chord`] with the `dom7` modifier.
466
+ * @returns {KordChord}
467
+ */
468
+ seven(): KordChord;
469
+ /**
470
+ * Returns a new [`Chord`] with the `dom9` modifier.
471
+ * @returns {KordChord}
472
+ */
473
+ nine(): KordChord;
474
+ /**
475
+ * Returns a new [`Chord`] with the `dom11` modifier.
476
+ * @returns {KordChord}
477
+ */
478
+ eleven(): KordChord;
479
+ /**
480
+ * Returns a new [`Chord`] with the `dom13` modifier.
481
+ * @returns {KordChord}
482
+ */
483
+ thirteen(): KordChord;
484
+ /**
485
+ * Returns a new [`Chord`] with the `flat9` modifier.
486
+ * @returns {KordChord}
487
+ */
488
+ flat9(): KordChord;
489
+ /**
490
+ * Returns a new [`Chord`] with the `sharp9` modifier.
491
+ * @returns {KordChord}
492
+ */
493
+ sharp9(): KordChord;
494
+ /**
495
+ * Returns a new [`Chord`] with the `sharp11` modifier.
496
+ * @returns {KordChord}
497
+ */
498
+ sharp11(): KordChord;
499
+ /**
500
+ * Returns a new [`Chord`] with the `dim` modifier.
501
+ * @returns {KordChord}
502
+ */
503
+ dim(): KordChord;
504
+ /**
505
+ * Returns a new [`Chord`] with the `halfDim` modifier.
506
+ * @returns {KordChord}
507
+ */
508
+ halfDim(): KordChord;
509
+ /**
510
+ * Returns a new [`Chord`] with the `sus2` extension.
511
+ * @returns {KordChord}
512
+ */
513
+ sus2(): KordChord;
514
+ /**
515
+ * Returns a new [`Chord`] with the `sus4` extension.
516
+ * @returns {KordChord}
517
+ */
518
+ sus4(): KordChord;
519
+ /**
520
+ * Returns a new [`Chord`] with the `flat11` extension.
521
+ * @returns {KordChord}
522
+ */
523
+ flat11(): KordChord;
524
+ /**
525
+ * Returns a new [`Chord`] with the `flat13` extension.
526
+ * @returns {KordChord}
527
+ */
528
+ flat13(): KordChord;
529
+ /**
530
+ * Returns a new [`Chord`] with the `sharp13` extension.
531
+ * @returns {KordChord}
532
+ */
533
+ sharp13(): KordChord;
534
+ /**
535
+ * Returns a new [`Chord`] with the `add2` extension.
536
+ * @returns {KordChord}
537
+ */
538
+ add2(): KordChord;
539
+ /**
540
+ * Returns a new [`Chord`] with the `add4` extension.
541
+ * @returns {KordChord}
542
+ */
543
+ add4(): KordChord;
544
+ /**
545
+ * Returns a new [`Chord`] with the `add6` extension.
546
+ * @returns {KordChord}
547
+ */
548
+ add6(): KordChord;
549
+ /**
550
+ * Returns a new [`Chord`] with the `add9` extension.
551
+ * @returns {KordChord}
552
+ */
553
+ add9(): KordChord;
554
+ /**
555
+ * Returns a new [`Chord`] with the `add11` extension.
556
+ * @returns {KordChord}
557
+ */
558
+ add11(): KordChord;
559
+ /**
560
+ * Returns a new [`Chord`] with the `add13` extension.
561
+ * @returns {KordChord}
562
+ */
563
+ add13(): KordChord;
564
+ }
565
+ /**
566
+ * The [`Note`] wrapper.
567
+ */
568
+ export class KordNote {
569
+ free(): void;
570
+ /**
571
+ * Creates a new [`Note`] from a frequency.
572
+ * @param {string} name
573
+ * @returns {KordNote}
574
+ */
575
+ static parse(name: string): KordNote;
576
+ /**
577
+ * Returns [`Note`]s from audio data.
578
+ * @param {Float32Array} data
579
+ * @param {number} length_in_seconds
580
+ * @returns {Array<any>}
581
+ */
582
+ static fromAudio(data: Float32Array, length_in_seconds: number): Array<any>;
583
+ /**
584
+ * Returns [`Note`]s from audio data using the ML inference algorithm.
585
+ * @param {Float32Array} data
586
+ * @param {number} length_in_seconds
587
+ * @returns {Array<any>}
588
+ */
589
+ static fromAudioMl(data: Float32Array, length_in_seconds: number): Array<any>;
590
+ /**
591
+ * Returns the [`Note`]'s friendly name.
592
+ * @returns {string}
593
+ */
594
+ name(): string;
595
+ /**
596
+ * Returns the [`Note`] represented as a string (same as `name`).
597
+ * @returns {string}
598
+ */
599
+ toString(): string;
600
+ /**
601
+ * Returns the [`Note`]'s [`NamedPitch`].
602
+ * @returns {string}
603
+ */
604
+ pitch(): string;
605
+ /**
606
+ * Returns the [`Note`]'s [`Octave`].
607
+ * @returns {number}
608
+ */
609
+ octave(): number;
610
+ /**
611
+ * Returns the [`Note`]'s frequency.
612
+ * @returns {number}
613
+ */
614
+ frequency(): number;
615
+ /**
616
+ * Adds the given interval to the [`Note`], producing a new [`Note`] instance.
617
+ * @param {KordInterval} interval
618
+ * @returns {KordNote}
619
+ */
620
+ addInterval(interval: KordInterval): KordNote;
621
+ /**
622
+ * Subtracts the given interval from the [`Note`], producing a new [`Note`] instance.
623
+ * @param {KordInterval} interval
624
+ * @returns {KordNote}
625
+ */
626
+ subInterval(interval: KordInterval): KordNote;
627
+ /**
628
+ * Computes the [`Interval`] distance between the [`Note`] and the given [`Note`].
629
+ * @param {KordNote} other
630
+ * @returns {KordInterval}
631
+ */
632
+ distanceTo(other: KordNote): KordInterval;
633
+ /**
634
+ * Returns the primary (first 13) harmonic series of the [`Note`].
635
+ * @returns {Array<any>}
636
+ */
637
+ harmonicSeries(): Array<any>;
638
+ /**
639
+ * Returns the clone of the [`Note`].
640
+ * @returns {KordNote}
641
+ */
642
+ copy(): KordNote;
643
+ }
644
+ /**
645
+ * A handle to a [`Chord`] playback.
646
+ *
647
+ * Should be dropped to stop the playback, or after playback is finished.
648
+ */
649
+ export class KordPlaybackHandle {
650
+ free(): void;
651
+ }