web-music-score 0.0.1 → 6.0.0-pre.1
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/CHANGELOG.md +200 -0
- package/LICENSE +62 -1
- package/README.md +46 -2
- package/dist/audio/index.d.ts +50 -0
- package/dist/audio/index.js +1858 -0
- package/dist/audio/index.mjs +92 -0
- package/dist/audio-cg/index.d.ts +21 -0
- package/dist/audio-cg/index.js +17568 -0
- package/dist/audio-cg/index.mjs +90 -0
- package/dist/audio-synth/index.d.ts +15 -0
- package/dist/audio-synth/index.js +18497 -0
- package/dist/audio-synth/index.mjs +63 -0
- package/dist/chunk-A7C2G7OG.mjs +101 -0
- package/dist/chunk-GNT3ECDB.mjs +267 -0
- package/dist/chunk-LO4NI4AU.mjs +18381 -0
- package/dist/chunk-PW2SO6EZ.mjs +37 -0
- package/dist/chunk-VHB57TXT.mjs +11 -0
- package/dist/chunk-X7BMJX7E.mjs +3867 -0
- package/dist/core/index.d.ts +31 -0
- package/dist/core/index.js +74 -0
- package/dist/core/index.mjs +22 -0
- package/dist/iife/audio-cg.global.js +220 -0
- package/dist/iife/index.global.js +228 -0
- package/dist/instrument-DS-9C6_8.d.ts +44 -0
- package/dist/music-objects-DLmp5uL6.d.ts +2398 -0
- package/dist/note-RVXvpfyV.d.ts +306 -0
- package/dist/pieces/index.d.ts +46 -0
- package/dist/pieces/index.js +79 -0
- package/dist/pieces/index.mjs +50 -0
- package/dist/react-ui/index.d.ts +86 -0
- package/dist/react-ui/index.js +132 -0
- package/dist/react-ui/index.mjs +96 -0
- package/dist/scale-B1M10_fu.d.ts +230 -0
- package/dist/score/index.d.ts +466 -0
- package/dist/score/index.js +13964 -0
- package/dist/score/index.mjs +10092 -0
- package/dist/tempo-D-JF-8b_.d.ts +409 -0
- package/dist/theory/index.d.ts +78 -0
- package/dist/theory/index.js +4842 -0
- package/dist/theory/index.mjs +1986 -0
- package/package.json +131 -3
- package/workspace.code-workspace +0 -9
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { M as MDocument, o as ScoreEventListener, r as MPlaybackButtons } from '../music-objects-DLmp5uL6.js';
|
|
4
|
+
import '../note-RVXvpfyV.js';
|
|
5
|
+
import '../tempo-D-JF-8b_.js';
|
|
6
|
+
import '@tspro/ts-utils-lib';
|
|
7
|
+
|
|
8
|
+
interface MusicScoreViewProps {
|
|
9
|
+
doc: MDocument;
|
|
10
|
+
onScoreEvent?: ScoreEventListener;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Music score view react component.
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Using with React TSX/JSX
|
|
16
|
+
* import * as Score from "web-music-score/score";
|
|
17
|
+
* import * as ScoreUI from "web-music-score/react-ui";
|
|
18
|
+
*
|
|
19
|
+
* // Render function of react component.
|
|
20
|
+
* render() {
|
|
21
|
+
* // Create document.
|
|
22
|
+
* const doc = new Score.DocumentBuilder()
|
|
23
|
+
* // Build document...
|
|
24
|
+
* .getDocument();
|
|
25
|
+
*
|
|
26
|
+
* return <>
|
|
27
|
+
* <ScoreUI.MusicScoreView doc={doc} />
|
|
28
|
+
* </>;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare class MusicScoreView extends React.Component<MusicScoreViewProps, {}> {
|
|
33
|
+
private readonly ctx;
|
|
34
|
+
constructor(props: MusicScoreViewProps);
|
|
35
|
+
componentDidUpdate(prevProps: Readonly<MusicScoreViewProps>, prevState: Readonly<{}>): void;
|
|
36
|
+
render(): react_jsx_runtime.JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface PlaybackButtonsProps {
|
|
40
|
+
doc: MDocument;
|
|
41
|
+
singlePlayStop?: boolean;
|
|
42
|
+
playStop?: boolean;
|
|
43
|
+
playPauseStop?: boolean;
|
|
44
|
+
playLabel?: string;
|
|
45
|
+
pauseLabel?: string;
|
|
46
|
+
stopLabel?: string;
|
|
47
|
+
}
|
|
48
|
+
interface PlaybackButtonsState {
|
|
49
|
+
controller: MPlaybackButtons;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Usage:
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Using with React TSX/JSX
|
|
55
|
+
* import * as Score from "web-music-score/score";
|
|
56
|
+
* import * as ScoreUI from "web-music-score/react-ui";
|
|
57
|
+
*
|
|
58
|
+
* // Create document.
|
|
59
|
+
* const doc = new Score.DocumentBuilder()
|
|
60
|
+
* // Build document...
|
|
61
|
+
* .getDocument();
|
|
62
|
+
*
|
|
63
|
+
* // Create default playback buttons (play, pause and stop buttons).
|
|
64
|
+
* <ScoreUI.PlaybackButtons doc={doc} />
|
|
65
|
+
*
|
|
66
|
+
* // Create playback buttons with single play/stop button.
|
|
67
|
+
* <ScoreUI.PlaybackButtons doc={doc} singlePlayStop />
|
|
68
|
+
*
|
|
69
|
+
* // Create playback buttons with play and stop buttons.
|
|
70
|
+
* <ScoreUI.PlaybackButtons doc={doc} playStop />
|
|
71
|
+
*
|
|
72
|
+
* // Create playback buttons with play, pause and stop buttons.
|
|
73
|
+
* <ScoreUI.PlaybackButtons doc={doc} playPauseStop />
|
|
74
|
+
*
|
|
75
|
+
* // You can also set custom play, pause and stop button labels.
|
|
76
|
+
* <ScoreUI.PlaybackButtons doc={doc} playLabel="⏵" pauseLabel="⏸" stopLabel="⏹" />
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare class PlaybackButtons extends React.Component<PlaybackButtonsProps, PlaybackButtonsState> {
|
|
80
|
+
state: PlaybackButtonsState;
|
|
81
|
+
constructor(props: PlaybackButtonsProps);
|
|
82
|
+
componentDidUpdate(prevProps: Readonly<PlaybackButtonsProps>): void;
|
|
83
|
+
render(): react_jsx_runtime.JSX.Element;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { MusicScoreView, type MusicScoreViewProps, PlaybackButtons, type PlaybackButtonsProps, type PlaybackButtonsState };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* WebMusicScore v6.0.0-pre.1 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
+
|
|
33
|
+
// src/react-ui/index.ts
|
|
34
|
+
var react_ui_exports = {};
|
|
35
|
+
__export(react_ui_exports, {
|
|
36
|
+
MusicScoreView: () => MusicScoreView,
|
|
37
|
+
PlaybackButtons: () => PlaybackButtons
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(react_ui_exports);
|
|
40
|
+
|
|
41
|
+
// src/react-ui/music-score-view.tsx
|
|
42
|
+
var React = __toESM(require("react"));
|
|
43
|
+
var import_score = require("web-music-score/score");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var MusicScoreView = class extends React.Component {
|
|
46
|
+
constructor(props) {
|
|
47
|
+
super(props);
|
|
48
|
+
__publicField(this, "ctx");
|
|
49
|
+
this.ctx = new import_score.MRenderContext();
|
|
50
|
+
this.ctx.setDocument(props.doc);
|
|
51
|
+
if (props.onScoreEvent) {
|
|
52
|
+
this.ctx.setScoreEventListener(props.onScoreEvent);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
componentDidUpdate(prevProps, prevState) {
|
|
56
|
+
if (prevProps.doc !== this.props.doc) {
|
|
57
|
+
this.ctx.setDocument(this.props.doc);
|
|
58
|
+
this.ctx.draw();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
const setCanvas = (canvas) => {
|
|
63
|
+
if (canvas) {
|
|
64
|
+
this.ctx.setCanvas(canvas);
|
|
65
|
+
this.ctx.draw();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("canvas", { style: { position: "relative" }, ref: setCanvas, children: "Your browser does not support the HTML canvas tag." });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// src/react-ui/playback-buttons.tsx
|
|
73
|
+
var React2 = __toESM(require("react"));
|
|
74
|
+
var import_score2 = require("web-music-score/score");
|
|
75
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
76
|
+
var PlaybackButtons = class extends React2.Component {
|
|
77
|
+
constructor(props) {
|
|
78
|
+
super(props);
|
|
79
|
+
__publicField(this, "state");
|
|
80
|
+
this.state = {
|
|
81
|
+
controller: new import_score2.MPlaybackButtons().setDocument(props.doc)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
componentDidUpdate(prevProps) {
|
|
85
|
+
if (this.props.doc !== prevProps.doc) {
|
|
86
|
+
this.state.controller.setDocument(this.props.doc);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
let { singlePlayStop, playStop, playPauseStop, playLabel, pauseLabel, stopLabel } = this.props;
|
|
91
|
+
let { controller } = this.state;
|
|
92
|
+
playLabel != null ? playLabel : playLabel = "Play";
|
|
93
|
+
pauseLabel != null ? pauseLabel : pauseLabel = "Pause";
|
|
94
|
+
stopLabel != null ? stopLabel : stopLabel = "Stop";
|
|
95
|
+
if (singlePlayStop) {
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-primary", ref: (btn) => {
|
|
97
|
+
if (btn) controller.setPlayStopButton(btn, playLabel, stopLabel);
|
|
98
|
+
} });
|
|
99
|
+
} else if (playStop) {
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "btn-group", children: [
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-primary", ref: (btn) => {
|
|
102
|
+
if (btn) controller.setPlayButton(btn, playLabel);
|
|
103
|
+
} }),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-primary", ref: (btn) => {
|
|
105
|
+
if (btn) controller.setStopButton(btn, stopLabel);
|
|
106
|
+
} })
|
|
107
|
+
] });
|
|
108
|
+
} else {
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "btn-group", children: [
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-primary", ref: (btn) => {
|
|
111
|
+
if (btn) controller.setPlayButton(btn, playLabel);
|
|
112
|
+
} }),
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-primary", ref: (btn) => {
|
|
114
|
+
if (btn) controller.setPauseButton(btn, pauseLabel);
|
|
115
|
+
} }),
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-primary", ref: (btn) => {
|
|
117
|
+
if (btn) controller.setStopButton(btn, stopLabel);
|
|
118
|
+
} })
|
|
119
|
+
] });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/react-ui/index.ts
|
|
125
|
+
var import_core = require("web-music-score/core");
|
|
126
|
+
(0, import_core.init)();
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
MusicScoreView,
|
|
130
|
+
PlaybackButtons
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* WebMusicScore v6.0.0-pre.1 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
|
|
2
|
+
import {
|
|
3
|
+
__publicField
|
|
4
|
+
} from "../chunk-A7C2G7OG.mjs";
|
|
5
|
+
|
|
6
|
+
// src/react-ui/music-score-view.tsx
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { MRenderContext } from "web-music-score/score";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var MusicScoreView = class extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
__publicField(this, "ctx");
|
|
14
|
+
this.ctx = new MRenderContext();
|
|
15
|
+
this.ctx.setDocument(props.doc);
|
|
16
|
+
if (props.onScoreEvent) {
|
|
17
|
+
this.ctx.setScoreEventListener(props.onScoreEvent);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
componentDidUpdate(prevProps, prevState) {
|
|
21
|
+
if (prevProps.doc !== this.props.doc) {
|
|
22
|
+
this.ctx.setDocument(this.props.doc);
|
|
23
|
+
this.ctx.draw();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
const setCanvas = (canvas) => {
|
|
28
|
+
if (canvas) {
|
|
29
|
+
this.ctx.setCanvas(canvas);
|
|
30
|
+
this.ctx.draw();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsx("canvas", { style: { position: "relative" }, ref: setCanvas, children: "Your browser does not support the HTML canvas tag." });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/react-ui/playback-buttons.tsx
|
|
38
|
+
import * as React2 from "react";
|
|
39
|
+
import { MPlaybackButtons } from "web-music-score/score";
|
|
40
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
41
|
+
var PlaybackButtons = class extends React2.Component {
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
__publicField(this, "state");
|
|
45
|
+
this.state = {
|
|
46
|
+
controller: new MPlaybackButtons().setDocument(props.doc)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
componentDidUpdate(prevProps) {
|
|
50
|
+
if (this.props.doc !== prevProps.doc) {
|
|
51
|
+
this.state.controller.setDocument(this.props.doc);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
let { singlePlayStop, playStop, playPauseStop, playLabel, pauseLabel, stopLabel } = this.props;
|
|
56
|
+
let { controller } = this.state;
|
|
57
|
+
playLabel != null ? playLabel : playLabel = "Play";
|
|
58
|
+
pauseLabel != null ? pauseLabel : pauseLabel = "Pause";
|
|
59
|
+
stopLabel != null ? stopLabel : stopLabel = "Stop";
|
|
60
|
+
if (singlePlayStop) {
|
|
61
|
+
return /* @__PURE__ */ jsx2("button", { className: "btn btn-primary", ref: (btn) => {
|
|
62
|
+
if (btn) controller.setPlayStopButton(btn, playLabel, stopLabel);
|
|
63
|
+
} });
|
|
64
|
+
} else if (playStop) {
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", { className: "btn-group", children: [
|
|
66
|
+
/* @__PURE__ */ jsx2("button", { className: "btn btn-primary", ref: (btn) => {
|
|
67
|
+
if (btn) controller.setPlayButton(btn, playLabel);
|
|
68
|
+
} }),
|
|
69
|
+
/* @__PURE__ */ jsx2("button", { className: "btn btn-primary", ref: (btn) => {
|
|
70
|
+
if (btn) controller.setStopButton(btn, stopLabel);
|
|
71
|
+
} })
|
|
72
|
+
] });
|
|
73
|
+
} else {
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", { className: "btn-group", children: [
|
|
75
|
+
/* @__PURE__ */ jsx2("button", { className: "btn btn-primary", ref: (btn) => {
|
|
76
|
+
if (btn) controller.setPlayButton(btn, playLabel);
|
|
77
|
+
} }),
|
|
78
|
+
/* @__PURE__ */ jsx2("button", { className: "btn btn-primary", ref: (btn) => {
|
|
79
|
+
if (btn) controller.setPauseButton(btn, pauseLabel);
|
|
80
|
+
} }),
|
|
81
|
+
/* @__PURE__ */ jsx2("button", { className: "btn btn-primary", ref: (btn) => {
|
|
82
|
+
if (btn) controller.setStopButton(btn, stopLabel);
|
|
83
|
+
} })
|
|
84
|
+
] });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/react-ui/index.ts
|
|
90
|
+
import { init as initCore } from "web-music-score/core";
|
|
91
|
+
initCore();
|
|
92
|
+
export {
|
|
93
|
+
MusicScoreView,
|
|
94
|
+
PlaybackButtons
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { N as Note, S as SymbolSet } from './note-RVXvpfyV.js';
|
|
2
|
+
import { K as KeySignature } from './tempo-D-JF-8b_.js';
|
|
3
|
+
|
|
4
|
+
/** Interval direction type. */
|
|
5
|
+
type IntervalDirection = "Unison" | "Ascending" | "Descending";
|
|
6
|
+
/** Interval quality type. */
|
|
7
|
+
type IntervalQuality = "Perfect" | "Major" | "minor" | "Augmented" | "Doubly Augmented" | "diminished" | "doubly diminished";
|
|
8
|
+
/**
|
|
9
|
+
* Validate interval quality of unkown value.
|
|
10
|
+
* @param q - Interval quality to validate.
|
|
11
|
+
* @returns - Interval quality if valid, else throws.
|
|
12
|
+
*/
|
|
13
|
+
declare function validateIntervalQuality(q: unknown): IntervalQuality;
|
|
14
|
+
/** Interval class. */
|
|
15
|
+
declare class Interval {
|
|
16
|
+
readonly note1: Note;
|
|
17
|
+
readonly note2: Note;
|
|
18
|
+
/** Interval direction. */
|
|
19
|
+
readonly direction: IntervalDirection;
|
|
20
|
+
/** Number of semitones. */
|
|
21
|
+
readonly semitones: number;
|
|
22
|
+
/** Interval quantity. */
|
|
23
|
+
readonly quantity: number;
|
|
24
|
+
/** Interval quality. */
|
|
25
|
+
readonly quality: IntervalQuality;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Get interval between given two notes.
|
|
29
|
+
* @param note1 - First note.
|
|
30
|
+
* @param note2 - Second note.
|
|
31
|
+
* @returns - Interval if valid, or undefined.
|
|
32
|
+
*/
|
|
33
|
+
static get(note1: Note, note2: Note): Interval | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get string presentation of interval (e.g. "Descending Major 2").
|
|
36
|
+
* @returns - Interval string.
|
|
37
|
+
*/
|
|
38
|
+
toString(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get abbrevated string presentation of interval (e.g. "↓M2").
|
|
41
|
+
* @returns - Interval abbrevated string.
|
|
42
|
+
*/
|
|
43
|
+
toAbbrString(): string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Degree type. */
|
|
47
|
+
type Degree = 1 | 2 | "b3" | 3 | 4 | "b5" | 5 | "#5" | 6 | "bb7" | "b7" | 7 | "#7" | "b9" | 9 | "#9" | 11 | 13;
|
|
48
|
+
/** Scale type enum. */
|
|
49
|
+
declare enum ScaleType {
|
|
50
|
+
/** Major scale. */
|
|
51
|
+
Major = "Major",
|
|
52
|
+
/** Natural minor scale. */
|
|
53
|
+
NaturalMinor = "Natural Minor",
|
|
54
|
+
/** Harmonic minor scale. */
|
|
55
|
+
HarmonicMinor = "Harmonic Minor",
|
|
56
|
+
/** Mode: Ionian. */
|
|
57
|
+
Ionian = "Ionian",
|
|
58
|
+
/** Mode: Dorian. */
|
|
59
|
+
Dorian = "Dorian",
|
|
60
|
+
/** Mode: Phrygian. */
|
|
61
|
+
Phrygian = "Phrygian",
|
|
62
|
+
/** Mode: Lydian. */
|
|
63
|
+
Lydian = "Lydian",
|
|
64
|
+
/** Mode: Mixolydian. */
|
|
65
|
+
Mixolydian = "Mixolydian",
|
|
66
|
+
/** Mode: Aeolian (minor). */
|
|
67
|
+
Aeolian = "Aeolian",
|
|
68
|
+
/** Mode: Locrian (rare). */
|
|
69
|
+
Locrian = "Locrian",
|
|
70
|
+
/** Major pentatonic scale. */
|
|
71
|
+
MajorPentatonic = "Major Pentatonic",
|
|
72
|
+
/** Minor pentatoni scale. */
|
|
73
|
+
MinorPentatonic = "Minor Pentatonic",
|
|
74
|
+
/** Major hexatonic blues scale. */
|
|
75
|
+
MajorHexatonicBlues = "Major Hexatonic Blues",
|
|
76
|
+
/** Minor hexatonic blues scale. */
|
|
77
|
+
MinorHexatonicBlues = "Minor Hexatonic Blues",
|
|
78
|
+
/** Heptatonic blues scale. */
|
|
79
|
+
HeptatonicBlues = "Heptatonic Blues"
|
|
80
|
+
}
|
|
81
|
+
/** Scale class. */
|
|
82
|
+
declare class Scale extends KeySignature {
|
|
83
|
+
readonly tonic: string;
|
|
84
|
+
readonly scaleType: ScaleType;
|
|
85
|
+
/** Degrees of scale notes. */
|
|
86
|
+
private readonly scaleDegrees;
|
|
87
|
+
/** Scale notes. */
|
|
88
|
+
private readonly scaleNotes;
|
|
89
|
+
/** Degrees (or undefined) of chromatic classes. */
|
|
90
|
+
private readonly chromaticClassDegree;
|
|
91
|
+
/**
|
|
92
|
+
* Create nev scale object instance.
|
|
93
|
+
* @param tonic - Tonic (e.g. "C" in "C Major").
|
|
94
|
+
* @param scaleType - Scale typo ("e.g. "Major" in "C Major").
|
|
95
|
+
*/
|
|
96
|
+
constructor(tonic: string, scaleType: ScaleType);
|
|
97
|
+
/**
|
|
98
|
+
* Compare if two scales equals.
|
|
99
|
+
* @param a - Scale a.
|
|
100
|
+
* @param b - Scale b.
|
|
101
|
+
* @returns - Boolean equality of given scales.
|
|
102
|
+
*/
|
|
103
|
+
static equals(a: Scale | null | undefined, b: Scale | null | undefined): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Get scale name.
|
|
106
|
+
* @param symbolSet - Symbol set to format scale name in ascii or unicode.
|
|
107
|
+
* @returns - Scale name string.
|
|
108
|
+
*/
|
|
109
|
+
getScaleName(symbolSet?: SymbolSet): string;
|
|
110
|
+
/**
|
|
111
|
+
* Get scale notes.
|
|
112
|
+
* @param bottomNote - Computed scale notes begin no lower than this note.
|
|
113
|
+
* @param numOctaves - How many octaves?
|
|
114
|
+
* @returns - Array of scale notes.
|
|
115
|
+
*/
|
|
116
|
+
getScaleNotes(bottomNote: string, numOctaves: number): ReadonlyArray<Note>;
|
|
117
|
+
/**
|
|
118
|
+
* Get scale overview (e.g. "C - D - E - F - G - A - B" for "C Major" scale).
|
|
119
|
+
* @returns - Scale overview string.
|
|
120
|
+
*/
|
|
121
|
+
getScaleOverview(): string;
|
|
122
|
+
/**
|
|
123
|
+
* Get scale steps, array of 1 (half step) and 2 (whole step), (e.g. [2, 2, 1, 2, 2, 2, 1] for Major scale).
|
|
124
|
+
* @returns - Array of scale steps.
|
|
125
|
+
*/
|
|
126
|
+
getScaleSteps(): number[];
|
|
127
|
+
/**
|
|
128
|
+
* Get scale steps string presentation, array of "H" (half step) and "W" (whole step), (e.g. ["W", "W", "H", "W", "W", "W", "H"] for Major scale).
|
|
129
|
+
* @returns - Array of scale steps string presentation.
|
|
130
|
+
*/
|
|
131
|
+
getScaleStringSteps(): string[];
|
|
132
|
+
/**
|
|
133
|
+
* Test if given note is scale note.
|
|
134
|
+
* @param note - Note to test.
|
|
135
|
+
* @returns - True/false.
|
|
136
|
+
*/
|
|
137
|
+
isScaleNote(note: Note): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Test if given note is scale root note.
|
|
140
|
+
* @param note - Note to test.
|
|
141
|
+
* @returns - True/false.
|
|
142
|
+
*/
|
|
143
|
+
isScaleRootNote(note: Note): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Get interval value between scale root note and given note.
|
|
146
|
+
* @param note - Note.
|
|
147
|
+
* @returns - Interval.
|
|
148
|
+
*/
|
|
149
|
+
getIntervalFromRootNote(note: Note): Interval;
|
|
150
|
+
private preferredChromaticIdNoteCache;
|
|
151
|
+
/**
|
|
152
|
+
* Get preferred chromatic note from given chromatic id.
|
|
153
|
+
* @param chromaticId - Chromatic id.
|
|
154
|
+
* @returns - Note.
|
|
155
|
+
*/
|
|
156
|
+
getPreferredChromaticNote(chromaticId: number): Note;
|
|
157
|
+
}
|
|
158
|
+
/** Scale factory class. */
|
|
159
|
+
declare class ScaleFactory {
|
|
160
|
+
readonly type: ScaleType;
|
|
161
|
+
private tonicList;
|
|
162
|
+
private scaleMap;
|
|
163
|
+
/**
|
|
164
|
+
* Create new scale factory object instance.
|
|
165
|
+
* @param type - Scale type.
|
|
166
|
+
*/
|
|
167
|
+
constructor(type: ScaleType);
|
|
168
|
+
/**
|
|
169
|
+
* Get list of tonics (e.g. "C", "C#", ... for Major scale type).
|
|
170
|
+
* @returns - Array of tonics.
|
|
171
|
+
*/
|
|
172
|
+
getTonicList(): ReadonlyArray<string>;
|
|
173
|
+
/**
|
|
174
|
+
* Get default tonic.
|
|
175
|
+
* @returns - Default tonic.
|
|
176
|
+
*/
|
|
177
|
+
getDefaultTonic(): string;
|
|
178
|
+
/**
|
|
179
|
+
* Get scale type.
|
|
180
|
+
* @returns - SCale type.
|
|
181
|
+
*/
|
|
182
|
+
getType(): ScaleType;
|
|
183
|
+
/**
|
|
184
|
+
* Get scale by given tonic.
|
|
185
|
+
* @param tonic - Tonic (e.g. "C").
|
|
186
|
+
* @returns - Scale.
|
|
187
|
+
*/
|
|
188
|
+
getScale(tonic: string): Scale;
|
|
189
|
+
/**
|
|
190
|
+
* Test if this scale factory has scale for given tonic value.
|
|
191
|
+
* @param tonic - Tonic.
|
|
192
|
+
* @returns - True/false.
|
|
193
|
+
*/
|
|
194
|
+
hasScale(tonic: string): boolean;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get array of scale factories, has some title string between to category.
|
|
198
|
+
* @returns - Array of scale factories.
|
|
199
|
+
*/
|
|
200
|
+
declare function getScaleFactoryList(): ReadonlyArray<ScaleFactory | string>;
|
|
201
|
+
/**
|
|
202
|
+
* Get scale factory for given scale type.
|
|
203
|
+
* @param scaleType - Scale type.
|
|
204
|
+
* @returns - Scale factory.
|
|
205
|
+
*/
|
|
206
|
+
declare function getScaleFactory(scaleType: ScaleType | `${ScaleType}`): ScaleFactory;
|
|
207
|
+
/**
|
|
208
|
+
* Validate scale type.
|
|
209
|
+
* @param scaleType - Scale type of unknown value.
|
|
210
|
+
* @returns - Scale type if given argument was valid scale type, or throws.
|
|
211
|
+
*/
|
|
212
|
+
declare function validateScaleType(scaleType: unknown): ScaleType;
|
|
213
|
+
/**
|
|
214
|
+
* Get scale.
|
|
215
|
+
* @param tonic - Tonic (e.g. "C").
|
|
216
|
+
* @param scaleType - Scale type (e.g. "Major").
|
|
217
|
+
*/
|
|
218
|
+
declare function getScale(tonic: string, scaleType: ScaleType | `${ScaleType}`): Scale;
|
|
219
|
+
/**
|
|
220
|
+
* Get scale.
|
|
221
|
+
* @param scale - Scale name (e.g. "C Major").
|
|
222
|
+
*/
|
|
223
|
+
declare function getScale(scale: string): Scale;
|
|
224
|
+
/**
|
|
225
|
+
* Get default scale ("C Major").
|
|
226
|
+
* @returns - Default scale.
|
|
227
|
+
*/
|
|
228
|
+
declare function getDefaultScale(): Scale;
|
|
229
|
+
|
|
230
|
+
export { type Degree as D, type IntervalDirection as I, ScaleType as S, type IntervalQuality as a, Interval as b, Scale as c, ScaleFactory as d, getScaleFactory as e, validateScaleType as f, getScaleFactoryList as g, getScale as h, getDefaultScale as i, validateIntervalQuality as v };
|