@musodojo/music-theory-data 31.1.0 → 33.0.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.
Files changed (95) hide show
  1. package/README.md +58 -7
  2. package/esm/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/build_message.d.ts.map +1 -1
  3. package/{script/deps/jsr.io/@std/internal/1.0.13 → esm/deps/jsr.io/@std/internal/1.0.14}/diff.d.ts.map +1 -1
  4. package/{script/deps/jsr.io/@std/internal/1.0.13 → esm/deps/jsr.io/@std/internal/1.0.14}/diff_str.d.ts.map +1 -1
  5. package/{script/deps/jsr.io/@std/internal/1.0.13 → esm/deps/jsr.io/@std/internal/1.0.14}/format.d.ts.map +1 -1
  6. package/esm/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/styles.d.ts.map +1 -1
  7. package/esm/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/types.d.ts.map +1 -1
  8. package/esm/src/data/chord-progressions/mod.d.ts +28 -16
  9. package/esm/src/data/chord-progressions/mod.d.ts.map +1 -1
  10. package/esm/src/data/chord-progressions/mod.js +180 -65
  11. package/esm/src/data/chords/mod.d.ts +26 -1
  12. package/esm/src/data/chords/mod.d.ts.map +1 -1
  13. package/esm/src/data/chords/mod.js +70 -1
  14. package/esm/src/data/labels/mod.d.ts +1 -0
  15. package/esm/src/data/labels/mod.d.ts.map +1 -1
  16. package/esm/src/data/labels/mod.js +1 -0
  17. package/esm/src/data/labels/note-label-collections.d.ts +1 -25
  18. package/esm/src/data/labels/note-label-collections.d.ts.map +1 -1
  19. package/esm/src/data/labels/note-label-collections.js +1 -77
  20. package/esm/src/data/labels/note-labels.d.ts +1 -1
  21. package/esm/src/data/labels/note-labels.d.ts.map +1 -1
  22. package/esm/src/data/labels/solfege.d.ts +33 -0
  23. package/esm/src/data/labels/solfege.d.ts.map +1 -0
  24. package/esm/src/data/labels/solfege.js +165 -0
  25. package/esm/src/data/note-collections/augmented-variants.d.ts.map +1 -1
  26. package/esm/src/data/note-collections/augmented-variants.js +3 -2
  27. package/esm/src/data/note-collections/mod.d.ts +15 -0
  28. package/esm/src/data/note-collections/mod.d.ts.map +1 -1
  29. package/esm/src/data/note-collections/mod.js +2 -2
  30. package/esm/src/utils/chord-progressions.d.ts +22 -5
  31. package/esm/src/utils/chord-progressions.d.ts.map +1 -1
  32. package/esm/src/utils/chord-progressions.js +70 -7
  33. package/esm/src/utils/chords.d.ts +7 -1
  34. package/esm/src/utils/chords.d.ts.map +1 -1
  35. package/esm/src/utils/chords.js +18 -1
  36. package/esm/src/utils/conversion-registry.d.ts +40 -20
  37. package/esm/src/utils/conversion-registry.d.ts.map +1 -1
  38. package/esm/src/utils/conversion-registry.js +95 -25
  39. package/esm/src/utils/intervals.d.ts +3 -0
  40. package/esm/src/utils/intervals.d.ts.map +1 -1
  41. package/esm/src/utils/intervals.js +23 -0
  42. package/esm/src/utils/midi.d.ts +7 -0
  43. package/esm/src/utils/midi.d.ts.map +1 -1
  44. package/esm/src/utils/midi.js +16 -0
  45. package/esm/src/utils/note-collections.d.ts +9 -1
  46. package/esm/src/utils/note-collections.d.ts.map +1 -1
  47. package/esm/src/utils/note-collections.js +22 -0
  48. package/esm/tests/solfege.test.d.ts.map +1 -0
  49. package/package.json +1 -1
  50. package/script/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/build_message.d.ts.map +1 -1
  51. package/{esm/deps/jsr.io/@std/internal/1.0.13 → script/deps/jsr.io/@std/internal/1.0.14}/diff.d.ts.map +1 -1
  52. package/{esm/deps/jsr.io/@std/internal/1.0.13 → script/deps/jsr.io/@std/internal/1.0.14}/diff_str.d.ts.map +1 -1
  53. package/{esm/deps/jsr.io/@std/internal/1.0.13 → script/deps/jsr.io/@std/internal/1.0.14}/format.d.ts.map +1 -1
  54. package/script/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/styles.d.ts.map +1 -1
  55. package/script/deps/jsr.io/@std/internal/{1.0.13 → 1.0.14}/types.d.ts.map +1 -1
  56. package/script/src/data/chord-progressions/mod.d.ts +28 -16
  57. package/script/src/data/chord-progressions/mod.d.ts.map +1 -1
  58. package/script/src/data/chord-progressions/mod.js +181 -66
  59. package/script/src/data/chords/mod.d.ts +26 -1
  60. package/script/src/data/chords/mod.d.ts.map +1 -1
  61. package/script/src/data/chords/mod.js +75 -2
  62. package/script/src/data/labels/mod.d.ts +1 -0
  63. package/script/src/data/labels/mod.d.ts.map +1 -1
  64. package/script/src/data/labels/mod.js +1 -0
  65. package/script/src/data/labels/note-label-collections.d.ts +1 -25
  66. package/script/src/data/labels/note-label-collections.d.ts.map +1 -1
  67. package/script/src/data/labels/note-label-collections.js +1 -77
  68. package/script/src/data/labels/note-labels.d.ts +1 -1
  69. package/script/src/data/labels/note-labels.d.ts.map +1 -1
  70. package/script/src/data/labels/solfege.d.ts +33 -0
  71. package/script/src/data/labels/solfege.d.ts.map +1 -0
  72. package/script/src/data/labels/solfege.js +173 -0
  73. package/script/src/data/note-collections/augmented-variants.d.ts.map +1 -1
  74. package/script/src/data/note-collections/augmented-variants.js +3 -2
  75. package/script/src/data/note-collections/mod.d.ts +15 -0
  76. package/script/src/data/note-collections/mod.d.ts.map +1 -1
  77. package/script/src/utils/chord-progressions.d.ts +22 -5
  78. package/script/src/utils/chord-progressions.d.ts.map +1 -1
  79. package/script/src/utils/chord-progressions.js +72 -5
  80. package/script/src/utils/chords.d.ts +7 -1
  81. package/script/src/utils/chords.d.ts.map +1 -1
  82. package/script/src/utils/chords.js +19 -0
  83. package/script/src/utils/conversion-registry.d.ts +40 -20
  84. package/script/src/utils/conversion-registry.d.ts.map +1 -1
  85. package/script/src/utils/conversion-registry.js +98 -26
  86. package/script/src/utils/intervals.d.ts +3 -0
  87. package/script/src/utils/intervals.d.ts.map +1 -1
  88. package/script/src/utils/intervals.js +26 -0
  89. package/script/src/utils/midi.d.ts +7 -0
  90. package/script/src/utils/midi.d.ts.map +1 -1
  91. package/script/src/utils/midi.js +19 -0
  92. package/script/src/utils/note-collections.d.ts +9 -1
  93. package/script/src/utils/note-collections.d.ts.map +1 -1
  94. package/script/src/utils/note-collections.js +25 -0
  95. package/script/tests/solfege.test.d.ts.map +1 -0
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isValidChordProgressionKey = isValidChordProgressionKey;
4
+ exports.getChordProgressionChordDirectRomanSymbol = getChordProgressionChordDirectRomanSymbol;
4
5
  exports.getChordProgressionChordNames = getChordProgressionChordNames;
6
+ exports.getChordProgressionDirectRomanSymbols = getChordProgressionDirectRomanSymbols;
5
7
  exports.getChordProgressionRomanSymbols = getChordProgressionRomanSymbols;
8
+ exports.getChordProgressionDisplayRomanSymbols = getChordProgressionDisplayRomanSymbols;
6
9
  exports.getChordProgressionKeysForTotalBars = getChordProgressionKeysForTotalBars;
10
+ exports.getChordProgressionKeysForCategory = getChordProgressionKeysForCategory;
7
11
  exports.getChordProgressionUniqueChordNames = getChordProgressionUniqueChordNames;
8
12
  exports.getChordProgressionChordChangeReferences = getChordProgressionChordChangeReferences;
9
13
  exports.getChordProgressionUniqueChordReferences = getChordProgressionUniqueChordReferences;
@@ -13,7 +17,10 @@ exports.getChordProgressionTotalDurationInBars = getChordProgressionTotalDuratio
13
17
  const mod_js_1 = require("../data/chord-progressions/mod.js");
14
18
  const mod_js_2 = require("../data/chords/mod.js");
15
19
  const note_names_js_1 = require("./note-names.js");
20
+ const chords_js_1 = require("./chords.js");
16
21
  const BAR_DURATION_EPSILON = 0.000000001;
22
+ const DIATONIC_SCALE_DEGREES = 7;
23
+ const INTERVAL_LABEL_REGEX = /^(𝄫|♭|♮|♯|𝄪)?(\d+)$/;
17
24
  /** Returns whether a string is one of the built-in chord progression keys. */
18
25
  function isValidChordProgressionKey(key) {
19
26
  return Object.prototype.hasOwnProperty.call(mod_js_1.chordProgressions, key);
@@ -26,8 +33,9 @@ function resolveProgression(progressionOrKey) {
26
33
  function createChordProgressionChordReference(chord, chordRootNote) {
27
34
  return {
28
35
  rootNote: chordRootNote,
29
- chordName: chordRootNote + chord.quality,
30
- noteCollectionKey: (0, mod_js_2.getChordQualityNoteCollectionKey)(chord.quality),
36
+ chordName: chordRootNote +
37
+ (0, mod_js_2.getChordCollectionChordSuffix)(chord.chordCollectionKey),
38
+ noteCollectionKey: chord.chordCollectionKey,
31
39
  };
32
40
  }
33
41
  function getResolvedChordProgressionChordReferences(rootNote, progressionOrKey) {
@@ -45,26 +53,85 @@ function getResolvedChordProgressionChordReferences(rootNote, progressionOrKey)
45
53
  }];
46
54
  });
47
55
  }
56
+ function getRomanAccidentalForIntervalLabel(accidental) {
57
+ switch (accidental) {
58
+ case undefined:
59
+ case "":
60
+ case "♮":
61
+ return "";
62
+ case "𝄫":
63
+ case "♭":
64
+ case "♯":
65
+ case "𝄪":
66
+ return accidental;
67
+ default:
68
+ throw new Error(`Invalid chord degree accidental: ${accidental}`);
69
+ }
70
+ }
71
+ /** Returns the direct tonic-relative Roman symbol for a progression chord. */
72
+ function getChordProgressionChordDirectRomanSymbol(chord) {
73
+ const match = chord.degree.match(INTERVAL_LABEL_REGEX);
74
+ if (!match) {
75
+ throw new Error(`Invalid chord degree: ${chord.degree}`);
76
+ }
77
+ const [, rawAccidental, degreeLabel] = match;
78
+ const degree = Number(degreeLabel);
79
+ if (!Number.isInteger(degree) || degree < 1) {
80
+ throw new Error(`Invalid chord degree: ${chord.degree}`);
81
+ }
82
+ const scaleIndex = (degree - 1) % DIATONIC_SCALE_DEGREES;
83
+ const romanSymbol = (0, chords_js_1.getRomanNumeralForScaleIndexAndChordCollectionKey)(scaleIndex, chord.chordCollectionKey);
84
+ if (romanSymbol === undefined) {
85
+ throw new Error(`Unhandled chord collection: ${chord.chordCollectionKey}`);
86
+ }
87
+ const accidental = getRomanAccidentalForIntervalLabel(rawAccidental);
88
+ return `${accidental}${romanSymbol}`;
89
+ }
48
90
  /** Returns the spelled chord names for a progression in the requested root. */
49
91
  function getChordProgressionChordNames(rootNote, progressionOrKey) {
50
92
  const progression = resolveProgression(progressionOrKey);
51
93
  if (!progression)
52
94
  return [];
53
95
  const noteNames = (0, note_names_js_1.getNoteNamesForRootAndIntervals)(rootNote, progression.chords.map((chord) => chord.degree));
54
- return progression.chords.map((chord, index) => noteNames[index] + chord.quality);
96
+ return progression.chords.map((chord, index) => noteNames[index] + (0, mod_js_2.getChordCollectionChordSuffix)(chord.chordCollectionKey));
55
97
  }
56
- /** Returns the roman symbols authored for a chord progression. */
98
+ /**
99
+ * Returns direct tonic-relative Roman symbols derived from each chord's
100
+ * `degree` and `chordCollectionKey`.
101
+ */
102
+ function getChordProgressionDirectRomanSymbols(progressionOrKey) {
103
+ const progression = resolveProgression(progressionOrKey);
104
+ if (!progression)
105
+ return [];
106
+ return progression.chords.map((chord) => getChordProgressionChordDirectRomanSymbol(chord));
107
+ }
108
+ /**
109
+ * Returns Roman symbols suitable for theory display, preferring optional
110
+ * harmonic-function analysis labels when present.
111
+ */
57
112
  function getChordProgressionRomanSymbols(progressionOrKey) {
58
113
  const progression = resolveProgression(progressionOrKey);
59
114
  if (!progression)
60
115
  return [];
61
- return progression.chords.map((chord) => chord.romanSymbol);
116
+ return progression.chords.map((chord) => chord.analysis?.romanSymbol ?? getChordProgressionChordDirectRomanSymbol(chord));
117
+ }
118
+ /**
119
+ * Returns Roman symbols suitable for display, preferring optional
120
+ * harmonic-function analysis labels when present.
121
+ */
122
+ function getChordProgressionDisplayRomanSymbols(progressionOrKey) {
123
+ return getChordProgressionRomanSymbols(progressionOrKey);
62
124
  }
63
125
  /** Returns all built-in chord progression keys with the requested total bar count. */
64
126
  function getChordProgressionKeysForTotalBars(totalBars) {
65
127
  return mod_js_1.chordProgressionBarGroups.find((group) => group.totalBars === totalBars)
66
128
  ?.progressionKeys.slice() ?? [];
67
129
  }
130
+ /** Returns all built-in chord progression keys in the requested musical category. */
131
+ function getChordProgressionKeysForCategory(category) {
132
+ return mod_js_1.chordProgressionCategoryGroups.find((group) => group.category === category)
133
+ ?.progressionKeys.slice() ?? [];
134
+ }
68
135
  /** Returns each distinct chord name in a progression, preserving first-seen order. */
69
136
  function getChordProgressionUniqueChordNames(rootNote, progressionOrKey) {
70
137
  return Array.from(new Set(getChordProgressionChordNames(rootNote, progressionOrKey)));
@@ -1,8 +1,9 @@
1
- import { type NoteCollectionKey } from "../data/note-collections/mod.js";
1
+ import { type ChordCollectionKey, type NoteCollectionKey } from "../data/note-collections/mod.js";
2
2
  import type { ChordQuality, RomanSeventhChord, RomanTriad, SeventhChord, Triad } from "../types/chords";
3
3
  import { type NoteCollectionKeyTransformOptions, type RootAndNoteCollectionKeyTransformOptions } from "./intervals.js";
4
4
  import { type RootNote } from "../data/labels/note-labels.js";
5
5
  export declare function getRomanNumeralForScaleIndexAndChordQuality(scaleIndex: number, quality: ChordQuality): string | undefined;
6
+ export declare function getRomanNumeralForScaleIndexAndChordCollectionKey(scaleIndex: number, chordCollectionKey: ChordCollectionKey): string | undefined;
6
7
  /**
7
8
  * Converts standard triad qualities (e.g., "M", "m") into their corresponding Roman numeral representations
8
9
  * based on their scale degree index.
@@ -19,6 +20,11 @@ export declare function getRomanTriads(triads: Triad[]): RomanTriad[];
19
20
  * @returns An array of string-based Roman numeral seventh chords (e.g., "IM7", "ii7", "vii°7").
20
21
  */
21
22
  export declare function getRomanSeventhChords(sevenths: SeventhChord[]): RomanSeventhChord[];
23
+ /**
24
+ * Checks whether a note collection has authored modal harmony data.
25
+ * Collections without authored harmony intentionally return undefined chord placeholders.
26
+ */
27
+ export declare function hasAuthoredNoteCollectionHarmony(noteCollectionKey: NoteCollectionKey): boolean;
22
28
  /**
23
29
  * Retrieves the triads for a given note collection key.
24
30
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chords.d.ts","sourceRoot":"","sources":["../../../src/src/utils/chords.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,YAAY,EAC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AED;;;;GAIG;AACH,wBAAgB,gDAAgD,CAC9D,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,wCAA6C,GACrD,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,CAYnC"}
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRomanNumeralForScaleIndexAndChordQuality = getRomanNumeralForScaleIndexAndChordQuality;
4
+ exports.getRomanNumeralForScaleIndexAndChordCollectionKey = getRomanNumeralForScaleIndexAndChordCollectionKey;
4
5
  exports.getRomanTriads = getRomanTriads;
5
6
  exports.getRomanSeventhChords = getRomanSeventhChords;
7
+ exports.hasAuthoredNoteCollectionHarmony = hasAuthoredNoteCollectionHarmony;
6
8
  exports.getTriadsForNoteCollectionKey = getTriadsForNoteCollectionKey;
7
9
  exports.getSeventhChordsForNoteCollectionKey = getSeventhChordsForNoteCollectionKey;
8
10
  exports.getRomanTriadsForNoteCollectionKey = getRomanTriadsForNoteCollectionKey;
@@ -34,6 +36,16 @@ function getRomanNumeralForScaleIndexAndChordQuality(scaleIndex, quality) {
34
36
  return undefined;
35
37
  return romanNumeral + rendering.suffix;
36
38
  }
39
+ function getRomanNumeralForScaleIndexAndChordCollectionKey(scaleIndex, chordCollectionKey) {
40
+ const rendering = (0, mod_js_1.getChordCollectionSymbolRendering)(chordCollectionKey);
41
+ const numerals = rendering.numeralCase === "lower"
42
+ ? mod_js_1.lowerCaseRomanNumerals
43
+ : mod_js_1.upperCaseRomanNumerals;
44
+ const romanNumeral = numerals[scaleIndex];
45
+ if (romanNumeral === undefined)
46
+ return undefined;
47
+ return romanNumeral + rendering.romanSuffix;
48
+ }
37
49
  /**
38
50
  * Converts standard triad qualities (e.g., "M", "m") into their corresponding Roman numeral representations
39
51
  * based on their scale degree index.
@@ -122,6 +134,13 @@ function getModeData(modeKey) {
122
134
  }
123
135
  return undefined;
124
136
  }
137
+ /**
138
+ * Checks whether a note collection has authored modal harmony data.
139
+ * Collections without authored harmony intentionally return undefined chord placeholders.
140
+ */
141
+ function hasAuthoredNoteCollectionHarmony(noteCollectionKey) {
142
+ return getModeData(noteCollectionKey) !== undefined;
143
+ }
125
144
  function getUndefinedChordPlaceholders(intervals, fillChromatic) {
126
145
  if (fillChromatic) {
127
146
  return (0, chromatic_js_1.createChromaticTuple)(Array.from({ length: 12 }, () => undefined));
@@ -1,13 +1,12 @@
1
- import type { RootNote } from "../data/labels/note-labels.js";
1
+ import type { ChromaticTuple } from "../data/chromatic.js";
2
+ import type { Interval, NoteName, RootNote } from "../data/labels/note-labels.js";
2
3
  import type { NoteCollectionKey } from "../data/note-collections/mod.js";
3
- import type { Interval } from "../data/labels/note-labels.js";
4
4
  import type { RomanSeventhChord, RomanTriad } from "../types/chords";
5
- import type { NoteName } from "../data/labels/note-labels.js";
6
5
  /**
7
6
  * Options specifically tailored for robust Conversion Registry UI usage.
8
7
  * Requires `fillChromatic: true` and `rotateToRootInteger0: true` to ensure
9
- * all returned arrays are 12 elements long and uniformly anchored to C=0,
10
- * making them easy to align in a UI like a fretboard.
8
+ * all returned arrays are 12 elements long and indexed by absolute pitch class
9
+ * where C is index 0. The selected root appears at its pitch-class index.
11
10
  */
12
11
  export interface ConversionRegistryOptions {
13
12
  fillChromatic: true;
@@ -17,25 +16,46 @@ export interface ConversionRegistryOptions {
17
16
  /**
18
17
  * A generic function signature for all registry entries.
19
18
  */
20
- export type ConversionFunction<T> = (rootNote: RootNote, noteCollectionKey: NoteCollectionKey, options: ConversionRegistryOptions) => readonly (T | undefined)[];
21
- export interface ConversionRegistryEntry<T> {
22
- id: string;
19
+ export type ConversionFunction<T> = (rootNote: RootNote, noteCollectionKey: NoteCollectionKey, options: ConversionRegistryOptions) => ChromaticTuple<T | undefined>;
20
+ export type ConversionInputKind = "rootAndNoteCollection";
21
+ export type ConversionOutputKind = "noteNames" | "intervals" | "chordNames" | "romanNumerals";
22
+ export type ConversionOutputShape = "chromatic-12";
23
+ export type ConversionOutputIndexing = "absolutePitchClassC0";
24
+ export type ConversionEmptySlot = "none" | "undefined";
25
+ export type ConversionAvailabilityFunction = (rootNote: RootNote, noteCollectionKey: NoteCollectionKey) => boolean;
26
+ export interface ConversionRegistryEntry<T, TId extends string = string> {
27
+ id: TId;
23
28
  name: string;
24
29
  shortName: string;
25
30
  description: string;
26
31
  example: string;
32
+ inputKind: ConversionInputKind;
33
+ outputKind: ConversionOutputKind;
34
+ outputShape: ConversionOutputShape;
35
+ outputIndexing: ConversionOutputIndexing;
36
+ allowsEmptySlots: boolean;
37
+ emptySlot: ConversionEmptySlot;
38
+ isAvailable?: ConversionAvailabilityFunction;
39
+ unavailableReason?: string;
27
40
  get: ConversionFunction<T>;
28
41
  }
29
- export declare const conversions: {
30
- rootAndNoteCollection: {
31
- noteNames: ConversionRegistryEntry<NoteName | string>;
32
- intervals: ConversionRegistryEntry<Interval>;
33
- extensions: ConversionRegistryEntry<Interval>;
34
- compoundIntervals: ConversionRegistryEntry<Interval>;
35
- triads: ConversionRegistryEntry<string>;
36
- seventhChords: ConversionRegistryEntry<string>;
37
- romanTriads: ConversionRegistryEntry<RomanTriad>;
38
- romanSeventhChords: ConversionRegistryEntry<RomanSeventhChord>;
39
- };
40
- };
42
+ export interface RootAndNoteCollectionConversions {
43
+ noteNames: ConversionRegistryEntry<NoteName, "note-names">;
44
+ intervals: ConversionRegistryEntry<Interval, "intervals">;
45
+ extensions: ConversionRegistryEntry<Interval, "extensions">;
46
+ compoundIntervals: ConversionRegistryEntry<Interval, "compound-intervals">;
47
+ triads: ConversionRegistryEntry<string, "triads">;
48
+ seventhChords: ConversionRegistryEntry<string, "seventh-chords">;
49
+ romanTriads: ConversionRegistryEntry<RomanTriad, "roman-triads">;
50
+ romanSeventhChords: ConversionRegistryEntry<RomanSeventhChord, "roman-seventh-chords">;
51
+ }
52
+ export interface ConversionRegistry {
53
+ rootAndNoteCollection: RootAndNoteCollectionConversions;
54
+ }
55
+ export declare const conversions: ConversionRegistry;
56
+ export declare const rootAndNoteCollectionConversions: RootAndNoteCollectionConversions;
57
+ export type RootAndNoteCollectionConversionKey = keyof typeof rootAndNoteCollectionConversions;
58
+ export type RootAndNoteCollectionConversion = typeof rootAndNoteCollectionConversions[RootAndNoteCollectionConversionKey];
59
+ export declare function isRootAndNoteCollectionConversionAvailable(conversion: RootAndNoteCollectionConversion, rootNote: RootNote, noteCollectionKey: NoteCollectionKey): boolean;
60
+ export declare function getAvailableRootAndNoteCollectionConversions(rootNote: RootNote, noteCollectionKey: NoteCollectionKey): RootAndNoteCollectionConversion[];
41
61
  //# sourceMappingURL=conversion-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversion-registry.d.ts","sourceRoot":"","sources":["../../../src/src/utils/conversion-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAc9D;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,IAAI,CAAC;IACpB,oBAAoB,EAAE,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAClC,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,yBAAyB,KAC/B,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;AAEhC,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,EAAE,EAAE,MAAM,CAAC;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B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClD,aAAa,EAAE,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACjE,WAAW,EAAE,uBAAuB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACjE,kBAAkB,EAAE,uBAAuB,CACzC,iBAAiB,EACjB,sBAAsB,CACvB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,qBAAqB,EAAE,gCAAgC,CAAC;CACzD;AAkBD,eAAO,MAAM,WAAW,EAAE,kBA2JzB,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAC3C,gCAAoE,CAAC;AAEvE,MAAM,MAAM,kCAAkC,GAC5C,MAAM,OAAO,gCAAgC,CAAC;AAEhD,MAAM,MAAM,+BAA+B,GACzC,OAAO,gCAAgC,CAAC,kCAAkC,CAAC,CAAC;AAE9E,wBAAgB,0CAA0C,CACxD,UAAU,EAAE,+BAA+B,EAC3C,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAET;AAED,wBAAgB,4CAA4C,CAC1D,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,GACnC,+BAA+B,EAAE,CAQnC"}
@@ -1,74 +1,146 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.conversions = void 0;
3
+ exports.rootAndNoteCollectionConversions = exports.conversions = void 0;
4
+ exports.isRootAndNoteCollectionConversionAvailable = isRootAndNoteCollectionConversionAvailable;
5
+ exports.getAvailableRootAndNoteCollectionConversions = getAvailableRootAndNoteCollectionConversions;
6
+ const chords_js_1 = require("./chords.js");
7
+ const chromatic_js_1 = require("./chromatic.js");
4
8
  const note_names_js_1 = require("./note-names.js");
5
9
  const intervals_js_1 = require("./intervals.js");
6
- const chords_js_1 = require("./chords.js");
10
+ const authoredHarmonyUnavailableReason = "This note collection does not have authored modal harmony data.";
11
+ const isAuthoredHarmonyAvailable = (_rootNote, noteCollectionKey) => (0, chords_js_1.hasAuthoredNoteCollectionHarmony)(noteCollectionKey);
12
+ const absolutePitchClassC0 = "absolutePitchClassC0";
13
+ function createConversionResult(values) {
14
+ return (0, chromatic_js_1.createChromaticTuple)(values);
15
+ }
7
16
  exports.conversions = {
8
17
  rootAndNoteCollection: {
9
18
  noteNames: {
10
19
  id: "note-names",
11
20
  name: "Note Names",
12
21
  shortName: "Notes",
13
- description: "Returns the specific note names (e.g., 'C', 'E♭', 'G') for the root and collection.",
14
- example: "C, E♭, G",
15
- get: (root, key, opts) => (0, note_names_js_1.getNoteNamesForRootAndNoteCollectionKey)(root, key, opts),
22
+ description: "Returns 12 absolute pitch-class slots for the root and collection, indexed so C is slot 0.",
23
+ example: "C, D♭, D, E♭, E, F, G♭, G, A♭, A, B♭, B",
24
+ inputKind: "rootAndNoteCollection",
25
+ outputKind: "noteNames",
26
+ outputShape: "chromatic-12",
27
+ outputIndexing: absolutePitchClassC0,
28
+ allowsEmptySlots: false,
29
+ emptySlot: "none",
30
+ get: (root, key, opts) => createConversionResult((0, note_names_js_1.getNoteNamesForRootAndNoteCollectionKey)(root, key, opts)),
16
31
  },
17
32
  intervals: {
18
33
  id: "intervals",
19
34
  name: "Intervals",
20
35
  shortName: "Intervals",
21
- description: "Returns the relative intervals (e.g., '1', '♭3', '5') for the collection.",
22
- example: "1, ♭3, 5",
23
- get: (root, key, opts) => (0, intervals_js_1.getIntervalsForRootAndNoteCollectionKey)(root, key, opts),
36
+ description: "Returns 12 absolute pitch-class slots labeled with intervals relative to the root, indexed so C is slot 0.",
37
+ example: "1, ♭2, 2, ♭3, 3, 4, ♭5, 5, ♭6, 6, ♭7, 7",
38
+ inputKind: "rootAndNoteCollection",
39
+ outputKind: "intervals",
40
+ outputShape: "chromatic-12",
41
+ outputIndexing: absolutePitchClassC0,
42
+ allowsEmptySlots: false,
43
+ emptySlot: "none",
44
+ get: (root, key, opts) => createConversionResult((0, intervals_js_1.getIntervalsForRootAndNoteCollectionKey)(root, key, opts)),
24
45
  },
25
46
  extensions: {
26
47
  id: "extensions",
27
48
  name: "Extensions",
28
49
  shortName: "Extensions",
29
- description: "Returns intervals with simple intervals converted to extensions where applicable (e.g., '2' becomes '9').",
30
- example: "9, 11, ♭13",
31
- get: (root, key, opts) => (0, intervals_js_1.getExtensionsForRootAndNoteCollectionKey)(root, key, opts),
50
+ description: "Returns 12 chromatic interval slots with simple intervals converted to extensions where applicable.",
51
+ example: "1, ♭9, 9, ♭3, 3, 11, ♭5, 5, ♭13, 13, ♭7, 7",
52
+ inputKind: "rootAndNoteCollection",
53
+ outputKind: "intervals",
54
+ outputShape: "chromatic-12",
55
+ outputIndexing: absolutePitchClassC0,
56
+ allowsEmptySlots: false,
57
+ emptySlot: "none",
58
+ get: (root, key, opts) => createConversionResult((0, intervals_js_1.getExtensionsForRootAndNoteCollectionKey)(root, key, opts)),
32
59
  },
33
60
  compoundIntervals: {
34
61
  id: "compound-intervals",
35
62
  name: "Compound Intervals",
36
63
  shortName: "Compound",
37
- description: "Returns intervals converted to their compound equivalents (e.g., '3' becomes '10').",
38
- example: "10, 12, 14",
39
- get: (root, key, opts) => (0, intervals_js_1.getCompoundIntervalsForRootAndNoteCollectionKey)(root, key, opts),
64
+ description: "Returns 12 chromatic interval slots with simple intervals converted to compound equivalents.",
65
+ example: "1, ♭9, 9, ♭10, 10, 11, ♭12, 12, ♭13, 13, ♭14, 14",
66
+ inputKind: "rootAndNoteCollection",
67
+ outputKind: "intervals",
68
+ outputShape: "chromatic-12",
69
+ outputIndexing: absolutePitchClassC0,
70
+ allowsEmptySlots: false,
71
+ emptySlot: "none",
72
+ get: (root, key, opts) => createConversionResult((0, intervals_js_1.getCompoundIntervalsForRootAndNoteCollectionKey)(root, key, opts)),
40
73
  },
41
74
  triads: {
42
75
  id: "triads",
43
76
  name: "Triads",
44
77
  shortName: "Triads",
45
- description: "Returns the triads with prepended note names (e.g., 'Cm', 'E♭M').",
46
- example: "Cm, E♭M",
47
- get: (root, key, opts) => (0, chords_js_1.getTriadsForRootAndNoteCollectionKey)(root, key, opts),
78
+ description: "Returns 12 chromatic triad-name slots for note collections with authored modal harmony.",
79
+ example: "CM, -, Dm, -, Em, FM, -, GM, -, Am, -, B°",
80
+ inputKind: "rootAndNoteCollection",
81
+ outputKind: "chordNames",
82
+ outputShape: "chromatic-12",
83
+ outputIndexing: absolutePitchClassC0,
84
+ allowsEmptySlots: true,
85
+ emptySlot: "undefined",
86
+ isAvailable: isAuthoredHarmonyAvailable,
87
+ unavailableReason: authoredHarmonyUnavailableReason,
88
+ get: (root, key, opts) => createConversionResult((0, chords_js_1.getTriadsForRootAndNoteCollectionKey)(root, key, opts)),
48
89
  },
49
90
  seventhChords: {
50
91
  id: "seventh-chords",
51
92
  name: "Seventh Chords",
52
93
  shortName: "Sevenths",
53
- description: "Returns the seventh chords with prepended note names (e.g., 'Cm7', 'E♭M7').",
54
- example: "Cm7, E♭M7",
55
- get: (root, key, opts) => (0, chords_js_1.getSeventhChordsForRootAndNoteCollectionKey)(root, key, opts),
94
+ description: "Returns 12 chromatic seventh-chord-name slots for note collections with authored modal harmony.",
95
+ example: "CM7, -, Dm7, -, Em7, FM7, -, G7, -, Am7, -, Bø7",
96
+ inputKind: "rootAndNoteCollection",
97
+ outputKind: "chordNames",
98
+ outputShape: "chromatic-12",
99
+ outputIndexing: absolutePitchClassC0,
100
+ allowsEmptySlots: true,
101
+ emptySlot: "undefined",
102
+ isAvailable: isAuthoredHarmonyAvailable,
103
+ unavailableReason: authoredHarmonyUnavailableReason,
104
+ get: (root, key, opts) => createConversionResult((0, chords_js_1.getSeventhChordsForRootAndNoteCollectionKey)(root, key, opts)),
56
105
  },
57
106
  romanTriads: {
58
107
  id: "roman-triads",
59
108
  name: "Roman Numeral Triads",
60
109
  shortName: "Roman Triads",
61
- description: "Returns the Roman numeral representation of the triads (e.g., 'I', 'ii', 'iii').",
62
- example: "I, ii, iii",
63
- get: (root, key, opts) => (0, chords_js_1.getRomanTriadsForRootAndNoteCollectionKey)(root, key, opts),
110
+ description: "Returns 12 chromatic Roman numeral triad slots for note collections with authored modal harmony.",
111
+ example: "I, -, ii, -, iii, IV, -, V, -, vi, -, vii°",
112
+ inputKind: "rootAndNoteCollection",
113
+ outputKind: "romanNumerals",
114
+ outputShape: "chromatic-12",
115
+ outputIndexing: absolutePitchClassC0,
116
+ allowsEmptySlots: true,
117
+ emptySlot: "undefined",
118
+ isAvailable: isAuthoredHarmonyAvailable,
119
+ unavailableReason: authoredHarmonyUnavailableReason,
120
+ get: (root, key, opts) => createConversionResult((0, chords_js_1.getRomanTriadsForRootAndNoteCollectionKey)(root, key, opts)),
64
121
  },
65
122
  romanSeventhChords: {
66
123
  id: "roman-seventh-chords",
67
124
  name: "Roman Numeral Seventh Chords",
68
125
  shortName: "Roman Sevenths",
69
- description: "Returns the Roman numeral representation of the seventh chords (e.g., 'I7', 'ii7', 'iii7').",
70
- example: "I7, ii7, iii7",
71
- get: (root, key, opts) => (0, chords_js_1.getRomanSeventhChordsForRootAndNoteCollectionKey)(root, key, opts),
126
+ description: "Returns 12 chromatic Roman numeral seventh-chord slots for note collections with authored modal harmony.",
127
+ example: "IM7, -, iim7, -, iiim7, IVM7, -, V7, -, vim7, -, viiø7",
128
+ inputKind: "rootAndNoteCollection",
129
+ outputKind: "romanNumerals",
130
+ outputShape: "chromatic-12",
131
+ outputIndexing: absolutePitchClassC0,
132
+ allowsEmptySlots: true,
133
+ emptySlot: "undefined",
134
+ isAvailable: isAuthoredHarmonyAvailable,
135
+ unavailableReason: authoredHarmonyUnavailableReason,
136
+ get: (root, key, opts) => createConversionResult((0, chords_js_1.getRomanSeventhChordsForRootAndNoteCollectionKey)(root, key, opts)),
72
137
  },
73
138
  },
74
139
  };
140
+ exports.rootAndNoteCollectionConversions = exports.conversions.rootAndNoteCollection;
141
+ function isRootAndNoteCollectionConversionAvailable(conversion, rootNote, noteCollectionKey) {
142
+ return conversion.isAvailable?.(rootNote, noteCollectionKey) ?? true;
143
+ }
144
+ function getAvailableRootAndNoteCollectionConversions(rootNote, noteCollectionKey) {
145
+ return Object.values(exports.rootAndNoteCollectionConversions).filter((conversion) => isRootAndNoteCollectionConversionAvailable(conversion, rootNote, noteCollectionKey));
146
+ }
@@ -1,6 +1,7 @@
1
1
  import { type CompoundInterval, type Interval, type IntervalQuality, type RootNote, type SimpleInterval } from "../data/labels/note-labels.js";
2
2
  import type { ChromaticIndex, ChromaticTuple } from "../data/chromatic.js";
3
3
  import { type NoteCollectionKey } from "../data/note-collections/mod.js";
4
+ export declare const DIATONIC_STEPS_PER_OCTAVE = 7;
4
5
  export type ChromaticIntervalTuple = ChromaticTuple<Interval>;
5
6
  export declare function isOctaveInterval(interval: Interval): boolean;
6
7
  /**
@@ -52,6 +53,8 @@ export declare function normalizeCompoundIntervalString(name: string): CompoundI
52
53
  * Parses an array of strings and returns an array of canonical `CompoundInterval`s.
53
54
  */
54
55
  export declare function normalizeCompoundIntervalStringArray(names: readonly string[]): CompoundInterval[];
56
+ export declare function getIntervalLabelDegree(intervalLabel: string): number | undefined;
57
+ export declare function shiftIntervalLabelByOctaves(intervalLabel: string, octaveOffset: number): string;
55
58
  /**
56
59
  * Sorts an array of intervals in ascending order based on their integer value.
57
60
  * This is a pure function and returns a new sorted array, leaving the original array unchanged.
@@ -1 +1 @@
1
- {"version":3,"file":"intervals.d.ts","sourceRoot":"","sources":["../../../src/src/utils/intervals.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EAGrB,KAAK,QAAQ,EACb,KAAK,eAAe,EAIpB,KAAK,QAAQ,EACb,KAAK,cAAc,EAGpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,iCAAiC,CAAC;AASzC,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAE9D,wBAA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C,OAAO,EAAE,wCAAwC,GAAG;IAAE,aAAa,EAAE,IAAI,CAAA;CAAE,GAC1E,sBAAsB,CAAC;AAC1B,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,wCAAwC,GACjD,QAAQ,EAAE,CAAC;AA4Bd;;;;;;;;GAQG;AACH,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EACH,IAAI,CACJ,wCAAwC,EACxC,wBAAwB,CACzB,GACC;IAAE,aAAa,EAAE,IAAI,CAAA;CAAE,GAC1B,sBAAsB,CAAC;AAC1B,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,IAAI,CACZ,wCAAwC,EACxC,wBAAwB,CACzB,GACA,QAAQ,EAAE,CAAC;AAgBd;;;;;;;;GAQG;AACH,wBAAgB,+CAA+C,CAC7D,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EACH,IAAI,CACJ,wCAAwC,EACxC,wBAAwB,CACzB,GACC;IAAE,aAAa,EAAE,IAAI,CAAA;CAAE,GAC1B,sBAAsB,CAAC;AAC1B,wBAAgB,+CAA+C,CAC7D,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,IAAI,CACZ,wCAAwC,EACxC,wBAAwB,CACzB,GACA,QAAQ,EAAE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DIATONIC_STEPS_PER_OCTAVE = void 0;
3
4
  exports.isOctaveInterval = isOctaveInterval;
4
5
  exports.filterOutOctaveIntervals = filterOutOctaveIntervals;
5
6
  exports.filterOutRootLikeIntervals = filterOutRootLikeIntervals;
@@ -9,6 +10,8 @@ exports.normalizeSimpleIntervalString = normalizeSimpleIntervalString;
9
10
  exports.normalizeSimpleIntervalStringArray = normalizeSimpleIntervalStringArray;
10
11
  exports.normalizeCompoundIntervalString = normalizeCompoundIntervalString;
11
12
  exports.normalizeCompoundIntervalStringArray = normalizeCompoundIntervalStringArray;
13
+ exports.getIntervalLabelDegree = getIntervalLabelDegree;
14
+ exports.shiftIntervalLabelByOctaves = shiftIntervalLabelByOctaves;
12
15
  exports.sortIntervals = sortIntervals;
13
16
  exports.transformIntervals = transformIntervals;
14
17
  exports.getIntervalsForQualities = getIntervalsForQualities;
@@ -26,6 +29,8 @@ const accidentals_js_1 = require("./accidentals.js");
26
29
  const note_collections_js_1 = require("./note-collections.js");
27
30
  const chromatic_js_1 = require("./chromatic.js");
28
31
  const INTERVAL_NUMBER_REGEX = /\d+$/;
32
+ const INTERVAL_LABEL_REGEX = /^([^\d]*)(\d+)$/;
33
+ exports.DIATONIC_STEPS_PER_OCTAVE = 7;
29
34
  function isOctaveInterval(interval) {
30
35
  return interval === "8" || interval === "♮8";
31
36
  }
@@ -155,6 +160,27 @@ function normalizeCompoundIntervalStringArray(names) {
155
160
  .map((name) => normalizeCompoundIntervalString(name))
156
161
  .filter((name) => name !== undefined);
157
162
  }
163
+ function getIntervalLabelDegree(intervalLabel) {
164
+ const match = intervalLabel.match(INTERVAL_LABEL_REGEX);
165
+ if (!match)
166
+ return undefined;
167
+ const degree = Number(match[2]);
168
+ return Number.isInteger(degree) && degree > 0 ? degree : undefined;
169
+ }
170
+ function shiftIntervalLabelByOctaves(intervalLabel, octaveOffset) {
171
+ if (octaveOffset === 0)
172
+ return intervalLabel;
173
+ const match = intervalLabel.match(INTERVAL_LABEL_REGEX);
174
+ if (!match)
175
+ return intervalLabel;
176
+ const [, accidental = "", degreeLabel] = match;
177
+ const degree = Number(degreeLabel);
178
+ if (!Number.isInteger(degree) || degree < 1)
179
+ return intervalLabel;
180
+ const shiftedDegree = degree +
181
+ octaveOffset * exports.DIATONIC_STEPS_PER_OCTAVE;
182
+ return shiftedDegree >= 1 ? `${accidental}${shiftedDegree}` : intervalLabel;
183
+ }
158
184
  /**
159
185
  * Sorts an array of intervals in ascending order based on their integer value.
160
186
  * This is a pure function and returns a new sorted array, leaving the original array unchanged.
@@ -1,5 +1,12 @@
1
1
  import { type Interval, type NoteName } from "../data/labels/note-labels.js";
2
2
  import type { MidiNoteNumber } from "../types/midi";
3
+ export declare function getMidiOctave(midi: number): number;
4
+ export type MidiNoteSpelling = "flat" | "sharp";
5
+ export interface FormatMidiNoteOptions {
6
+ spelling?: MidiNoteSpelling;
7
+ }
8
+ export declare function formatMidiNote(midi: number, options?: FormatMidiNoteOptions): string;
9
+ export declare function formatSpelledMidiNote(noteName: string, midi: number): string;
3
10
  /**
4
11
  * Calculates a MIDI note number based on a starting musical note (represented by its integer value and octave)
5
12
  * and an interval to apply to it.
@@ -1 +1 @@
1
- {"version":3,"file":"midi.d.ts","sourceRoot":"","sources":["../../../src/src/utils/midi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,QAAQ,EAEd,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,QAAQ,GACjB,cAAc,GAAG,SAAS,CAM5B;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,QAAQ,GACjB,cAAc,GAAG,SAAS,CAQ5B;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,GACjB,cAAc,GAAG,SAAS,CAI5B;AAED;;;;;;GAMG;AACH,w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 -1,10 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMidiOctave = getMidiOctave;
4
+ exports.formatMidiNote = formatMidiNote;
5
+ exports.formatSpelledMidiNote = formatSpelledMidiNote;
3
6
  exports.getMidiForNoteIntegerAndInterval = getMidiForNoteIntegerAndInterval;
4
7
  exports.getMidiForNoteNameAndInterval = getMidiForNoteNameAndInterval;
5
8
  exports.getMidiForNoteMidiAndInterval = getMidiForNoteMidiAndInterval;
6
9
  exports.getMidiForNoteName = getMidiForNoteName;
7
10
  const note_labels_js_1 = require("../data/labels/note-labels.js");
11
+ const note_label_collections_js_1 = require("../data/labels/note-label-collections.js");
12
+ const chromatic_js_1 = require("./chromatic.js");
13
+ function getMidiOctave(midi) {
14
+ return Math.floor(midi / 12) - 1;
15
+ }
16
+ function formatMidiNote(midi, options = {}) {
17
+ const { spelling = "flat" } = options;
18
+ const labels = spelling === "sharp"
19
+ ? note_label_collections_js_1.noteLabelCollections.noteNamesSharp.labels
20
+ : note_label_collections_js_1.noteLabelCollections.noteNamesFlat.labels;
21
+ const noteName = labels[(0, chromatic_js_1.normalizeChromaticIndex)(midi)];
22
+ return `${noteName}${getMidiOctave(midi)}`;
23
+ }
24
+ function formatSpelledMidiNote(noteName, midi) {
25
+ return noteName === "" ? "" : `${noteName}${getMidiOctave(midi)}`;
26
+ }
8
27
  /**
9
28
  * Calculates a MIDI note number based on a starting musical note (represented by its integer value and octave)
10
29
  * and an interval to apply to it.