@musodojo/music-theory-data 33.0.0 → 34.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.
package/esm/src/utils/midi.d.ts
CHANGED
|
@@ -1,12 +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
|
|
4
|
-
export type
|
|
3
|
+
export declare function getScientificPitchOctaveForMidiNote(midi: number): number;
|
|
4
|
+
export type MidiNoteSpellingPreference = "flat" | "sharp";
|
|
5
5
|
export interface FormatMidiNoteOptions {
|
|
6
|
-
spelling?:
|
|
6
|
+
spelling?: MidiNoteSpellingPreference;
|
|
7
7
|
}
|
|
8
8
|
export declare function formatMidiNote(midi: number, options?: FormatMidiNoteOptions): string;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function formatNoteNameWithMidiOctave(noteName: string, midi: number): string;
|
|
10
10
|
/**
|
|
11
11
|
* Calculates a MIDI note number based on a starting musical note (represented by its integer value and octave)
|
|
12
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;AAGvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,wBAAgB,
|
|
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;AAGvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,0BAA0B,CAAC;CACvC;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,qBAA0B,GAClC,MAAM,CAQR;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,CAIR;AAED;;;;;;;;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,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,MAAM,GACvB,cAAc,GAAG,SAAS,CAI5B"}
|
package/esm/src/utils/midi.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { intervalToIntegerMap, noteNameToIntegerMap, } from "../data/labels/note-labels.js";
|
|
2
2
|
import { noteLabelCollections } from "../data/labels/note-label-collections.js";
|
|
3
3
|
import { normalizeChromaticIndex } from "./chromatic.js";
|
|
4
|
-
export function
|
|
4
|
+
export function getScientificPitchOctaveForMidiNote(midi) {
|
|
5
5
|
return Math.floor(midi / 12) - 1;
|
|
6
6
|
}
|
|
7
7
|
export function formatMidiNote(midi, options = {}) {
|
|
@@ -10,10 +10,12 @@ export function formatMidiNote(midi, options = {}) {
|
|
|
10
10
|
? noteLabelCollections.noteNamesSharp.labels
|
|
11
11
|
: noteLabelCollections.noteNamesFlat.labels;
|
|
12
12
|
const noteName = labels[normalizeChromaticIndex(midi)];
|
|
13
|
-
return `${noteName}${
|
|
13
|
+
return `${noteName}${getScientificPitchOctaveForMidiNote(midi)}`;
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
16
|
-
return noteName === ""
|
|
15
|
+
export function formatNoteNameWithMidiOctave(noteName, midi) {
|
|
16
|
+
return noteName === ""
|
|
17
|
+
? ""
|
|
18
|
+
: `${noteName}${getScientificPitchOctaveForMidiNote(midi)}`;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Calculates a MIDI note number based on a starting musical note (represented by its integer value and octave)
|
package/package.json
CHANGED
|
@@ -1,12 +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
|
|
4
|
-
export type
|
|
3
|
+
export declare function getScientificPitchOctaveForMidiNote(midi: number): number;
|
|
4
|
+
export type MidiNoteSpellingPreference = "flat" | "sharp";
|
|
5
5
|
export interface FormatMidiNoteOptions {
|
|
6
|
-
spelling?:
|
|
6
|
+
spelling?: MidiNoteSpellingPreference;
|
|
7
7
|
}
|
|
8
8
|
export declare function formatMidiNote(midi: number, options?: FormatMidiNoteOptions): string;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function formatNoteNameWithMidiOctave(noteName: string, midi: number): string;
|
|
10
10
|
/**
|
|
11
11
|
* Calculates a MIDI note number based on a starting musical note (represented by its integer value and octave)
|
|
12
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,+B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utils/midi.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getScientificPitchOctaveForMidiNote = getScientificPitchOctaveForMidiNote;
|
|
4
4
|
exports.formatMidiNote = formatMidiNote;
|
|
5
|
-
exports.
|
|
5
|
+
exports.formatNoteNameWithMidiOctave = formatNoteNameWithMidiOctave;
|
|
6
6
|
exports.getMidiForNoteIntegerAndInterval = getMidiForNoteIntegerAndInterval;
|
|
7
7
|
exports.getMidiForNoteNameAndInterval = getMidiForNoteNameAndInterval;
|
|
8
8
|
exports.getMidiForNoteMidiAndInterval = getMidiForNoteMidiAndInterval;
|
|
@@ -10,7 +10,7 @@ exports.getMidiForNoteName = getMidiForNoteName;
|
|
|
10
10
|
const note_labels_js_1 = require("../data/labels/note-labels.js");
|
|
11
11
|
const note_label_collections_js_1 = require("../data/labels/note-label-collections.js");
|
|
12
12
|
const chromatic_js_1 = require("./chromatic.js");
|
|
13
|
-
function
|
|
13
|
+
function getScientificPitchOctaveForMidiNote(midi) {
|
|
14
14
|
return Math.floor(midi / 12) - 1;
|
|
15
15
|
}
|
|
16
16
|
function formatMidiNote(midi, options = {}) {
|
|
@@ -19,10 +19,12 @@ function formatMidiNote(midi, options = {}) {
|
|
|
19
19
|
? note_label_collections_js_1.noteLabelCollections.noteNamesSharp.labels
|
|
20
20
|
: note_label_collections_js_1.noteLabelCollections.noteNamesFlat.labels;
|
|
21
21
|
const noteName = labels[(0, chromatic_js_1.normalizeChromaticIndex)(midi)];
|
|
22
|
-
return `${noteName}${
|
|
22
|
+
return `${noteName}${getScientificPitchOctaveForMidiNote(midi)}`;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return noteName === ""
|
|
24
|
+
function formatNoteNameWithMidiOctave(noteName, midi) {
|
|
25
|
+
return noteName === ""
|
|
26
|
+
? ""
|
|
27
|
+
: `${noteName}${getScientificPitchOctaveForMidiNote(midi)}`;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Calculates a MIDI note number based on a starting musical note (represented by its integer value and octave)
|