@tspro/web-music-score 1.1.0 → 2.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/CHANGELOG.md +10 -0
- package/README.md +247 -195
- package/dist/audio/index.d.mts +22 -0
- package/dist/audio/index.d.ts +22 -0
- package/dist/audio/index.js +147 -0
- package/dist/audio/index.mjs +109 -0
- package/dist/audio-cg/index.d.mts +4 -0
- package/dist/audio-cg/index.d.ts +4 -0
- package/dist/audio-cg/index.js +124 -0
- package/dist/audio-cg/index.mjs +91 -0
- package/dist/chunk-2EPWQZKJ.mjs +9 -0
- package/dist/core/index.d.mts +21 -0
- package/dist/core/index.d.ts +21 -0
- package/dist/core/index.js +72 -0
- package/dist/core/index.mjs +45 -0
- package/dist/guitar-BIFwFT31.d.ts +24 -0
- package/dist/guitar-kbJYu3Am.d.mts +24 -0
- package/dist/iife/index.global.js +222 -0
- package/dist/note-B5ZtlHc8.d.ts +99 -0
- package/dist/note-CraqEy8x.d.mts +99 -0
- package/dist/pieces/index.d.mts +15 -0
- package/dist/pieces/index.d.ts +15 -0
- package/dist/pieces/index.js +104 -0
- package/dist/pieces/index.mjs +77 -0
- package/dist/react-ui/index.d.mts +169 -0
- package/dist/react-ui/index.d.ts +169 -0
- package/dist/react-ui/index.js +624 -0
- package/dist/react-ui/index.mjs +582 -0
- package/dist/score/index.d.mts +1558 -0
- package/dist/score/index.d.ts +1558 -0
- package/dist/score/index.js +6937 -0
- package/dist/score/index.mjs +6863 -0
- package/dist/tempo--588tdcv.d.ts +203 -0
- package/dist/tempo-BEJBHZ5I.d.mts +203 -0
- package/dist/theory/index.d.mts +47 -0
- package/dist/theory/index.d.ts +47 -0
- package/dist/theory/index.js +1783 -0
- package/dist/theory/index.mjs +1716 -0
- package/package.json +98 -55
- package/dist/index.cjs.js +0 -41053
- package/dist/index.d.ts +0 -1281
- package/dist/index.esm.mjs +0 -41044
- package/dist/index.umd.min.js +0 -9
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { N as Note } from '../note-B5ZtlHc8.js';
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
interface Instrument {
|
|
5
|
+
getName(): string;
|
|
6
|
+
playNote(note: string, duration?: number, volume?: number): void;
|
|
7
|
+
stop(): void;
|
|
8
|
+
}
|
|
9
|
+
/** @public */
|
|
10
|
+
declare function getInstrumentList(): ReadonlyArray<string>;
|
|
11
|
+
/** @public */
|
|
12
|
+
declare function getCurrentInstrument(): string;
|
|
13
|
+
/** @public */
|
|
14
|
+
declare function registerInstrument(instr: Instrument): void;
|
|
15
|
+
/** @public */
|
|
16
|
+
declare function setInstrument(instrName: string): void;
|
|
17
|
+
/** @public */
|
|
18
|
+
declare function playNote(note: Note | string | number, duration?: number, linearVolume?: number): void;
|
|
19
|
+
/** @public */
|
|
20
|
+
declare function stop(): void;
|
|
21
|
+
|
|
22
|
+
export { type Instrument, getCurrentInstrument, getInstrumentList, playNote, registerInstrument, setInstrument, stop };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* WebMusicScore v2.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (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/audio/index.ts
|
|
34
|
+
var audio_exports = {};
|
|
35
|
+
__export(audio_exports, {
|
|
36
|
+
getCurrentInstrument: () => getCurrentInstrument,
|
|
37
|
+
getInstrumentList: () => getInstrumentList,
|
|
38
|
+
playNote: () => playNote,
|
|
39
|
+
registerInstrument: () => registerInstrument,
|
|
40
|
+
setInstrument: () => setInstrument,
|
|
41
|
+
stop: () => stop
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(audio_exports);
|
|
44
|
+
var import_theory = require("@tspro/web-music-score/theory");
|
|
45
|
+
|
|
46
|
+
// src/audio/synth.ts
|
|
47
|
+
var Tone = __toESM(require("tone"));
|
|
48
|
+
var import_ts_utils_lib = require("@tspro/ts-utils-lib");
|
|
49
|
+
var Synth2 = class {
|
|
50
|
+
constructor() {
|
|
51
|
+
__publicField(this, "audioSource");
|
|
52
|
+
try {
|
|
53
|
+
const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
|
|
54
|
+
const filter = new Tone.Filter(800, "lowpass").connect(reverb);
|
|
55
|
+
this.audioSource = new Tone.PolySynth(Tone.Synth, {
|
|
56
|
+
oscillator: {
|
|
57
|
+
type: "triangle"
|
|
58
|
+
},
|
|
59
|
+
envelope: {
|
|
60
|
+
attack: 1e-3,
|
|
61
|
+
decay: 2,
|
|
62
|
+
sustain: 0.1,
|
|
63
|
+
release: 1.2
|
|
64
|
+
}
|
|
65
|
+
}).connect(filter);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
this.audioSource = void 0;
|
|
68
|
+
console.error(err);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
getName() {
|
|
72
|
+
return "Synthesizer";
|
|
73
|
+
}
|
|
74
|
+
playNote(note, duration, linearVolume) {
|
|
75
|
+
try {
|
|
76
|
+
if (this.audioSource) {
|
|
77
|
+
if (linearVolume !== void 0) {
|
|
78
|
+
this.audioSource.volume.value = import_ts_utils_lib.Utils.Math.linearToDecibels(linearVolume);
|
|
79
|
+
}
|
|
80
|
+
this.audioSource.triggerAttackRelease(note, duration != null ? duration : "2n");
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
stop() {
|
|
86
|
+
try {
|
|
87
|
+
if (this.audioSource) {
|
|
88
|
+
this.audioSource.releaseAll();
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var Synthesizer = new Synth2();
|
|
95
|
+
|
|
96
|
+
// src/audio/index.ts
|
|
97
|
+
var import_core = require("@tspro/web-music-score/core");
|
|
98
|
+
(0, import_core.init)();
|
|
99
|
+
function getNoteName(note) {
|
|
100
|
+
if (typeof note === "string") {
|
|
101
|
+
return note;
|
|
102
|
+
} else if (typeof note === "number") {
|
|
103
|
+
note = import_theory.Note.getChromaticNote(note);
|
|
104
|
+
}
|
|
105
|
+
return note.format(import_theory.PitchNotation.Scientific, import_theory.SymbolSet.Ascii);
|
|
106
|
+
}
|
|
107
|
+
var InstrumentList = [Synthesizer];
|
|
108
|
+
var CurrentInstrument = Synthesizer;
|
|
109
|
+
function getInstrumentList() {
|
|
110
|
+
return InstrumentList.map((instr) => instr.getName());
|
|
111
|
+
}
|
|
112
|
+
function getCurrentInstrument() {
|
|
113
|
+
return CurrentInstrument.getName();
|
|
114
|
+
}
|
|
115
|
+
function registerInstrument(instr) {
|
|
116
|
+
if (InstrumentList.some((instr2) => instr2.getName() === instr.getName())) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
InstrumentList.push(instr);
|
|
120
|
+
setInstrument(instr.getName());
|
|
121
|
+
}
|
|
122
|
+
function setInstrument(instrName) {
|
|
123
|
+
if (instrName === CurrentInstrument.getName()) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
CurrentInstrument.stop();
|
|
127
|
+
let instr = InstrumentList.find((instr2) => instr2.getName() === instrName);
|
|
128
|
+
if (instr) {
|
|
129
|
+
CurrentInstrument = instr;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function playNote(note, duration, linearVolume) {
|
|
133
|
+
CurrentInstrument.playNote(getNoteName(note), duration, linearVolume);
|
|
134
|
+
}
|
|
135
|
+
function stop() {
|
|
136
|
+
CurrentInstrument.stop();
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
getCurrentInstrument,
|
|
141
|
+
getInstrumentList,
|
|
142
|
+
playNote,
|
|
143
|
+
registerInstrument,
|
|
144
|
+
setInstrument,
|
|
145
|
+
stop
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* WebMusicScore v2.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
|
+
import {
|
|
3
|
+
__publicField
|
|
4
|
+
} from "../chunk-2EPWQZKJ.mjs";
|
|
5
|
+
|
|
6
|
+
// src/audio/index.ts
|
|
7
|
+
import { Note, PitchNotation, SymbolSet } from "@tspro/web-music-score/theory";
|
|
8
|
+
|
|
9
|
+
// src/audio/synth.ts
|
|
10
|
+
import * as Tone from "tone";
|
|
11
|
+
import { Utils } from "@tspro/ts-utils-lib";
|
|
12
|
+
var Synth2 = class {
|
|
13
|
+
constructor() {
|
|
14
|
+
__publicField(this, "audioSource");
|
|
15
|
+
try {
|
|
16
|
+
const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
|
|
17
|
+
const filter = new Tone.Filter(800, "lowpass").connect(reverb);
|
|
18
|
+
this.audioSource = new Tone.PolySynth(Tone.Synth, {
|
|
19
|
+
oscillator: {
|
|
20
|
+
type: "triangle"
|
|
21
|
+
},
|
|
22
|
+
envelope: {
|
|
23
|
+
attack: 1e-3,
|
|
24
|
+
decay: 2,
|
|
25
|
+
sustain: 0.1,
|
|
26
|
+
release: 1.2
|
|
27
|
+
}
|
|
28
|
+
}).connect(filter);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
this.audioSource = void 0;
|
|
31
|
+
console.error(err);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
getName() {
|
|
35
|
+
return "Synthesizer";
|
|
36
|
+
}
|
|
37
|
+
playNote(note, duration, linearVolume) {
|
|
38
|
+
try {
|
|
39
|
+
if (this.audioSource) {
|
|
40
|
+
if (linearVolume !== void 0) {
|
|
41
|
+
this.audioSource.volume.value = Utils.Math.linearToDecibels(linearVolume);
|
|
42
|
+
}
|
|
43
|
+
this.audioSource.triggerAttackRelease(note, duration != null ? duration : "2n");
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
stop() {
|
|
49
|
+
try {
|
|
50
|
+
if (this.audioSource) {
|
|
51
|
+
this.audioSource.releaseAll();
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var Synthesizer = new Synth2();
|
|
58
|
+
|
|
59
|
+
// src/audio/index.ts
|
|
60
|
+
import { init as initCore } from "@tspro/web-music-score/core";
|
|
61
|
+
initCore();
|
|
62
|
+
function getNoteName(note) {
|
|
63
|
+
if (typeof note === "string") {
|
|
64
|
+
return note;
|
|
65
|
+
} else if (typeof note === "number") {
|
|
66
|
+
note = Note.getChromaticNote(note);
|
|
67
|
+
}
|
|
68
|
+
return note.format(PitchNotation.Scientific, SymbolSet.Ascii);
|
|
69
|
+
}
|
|
70
|
+
var InstrumentList = [Synthesizer];
|
|
71
|
+
var CurrentInstrument = Synthesizer;
|
|
72
|
+
function getInstrumentList() {
|
|
73
|
+
return InstrumentList.map((instr) => instr.getName());
|
|
74
|
+
}
|
|
75
|
+
function getCurrentInstrument() {
|
|
76
|
+
return CurrentInstrument.getName();
|
|
77
|
+
}
|
|
78
|
+
function registerInstrument(instr) {
|
|
79
|
+
if (InstrumentList.some((instr2) => instr2.getName() === instr.getName())) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
InstrumentList.push(instr);
|
|
83
|
+
setInstrument(instr.getName());
|
|
84
|
+
}
|
|
85
|
+
function setInstrument(instrName) {
|
|
86
|
+
if (instrName === CurrentInstrument.getName()) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
CurrentInstrument.stop();
|
|
90
|
+
let instr = InstrumentList.find((instr2) => instr2.getName() === instrName);
|
|
91
|
+
if (instr) {
|
|
92
|
+
CurrentInstrument = instr;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function playNote(note, duration, linearVolume) {
|
|
96
|
+
CurrentInstrument.playNote(getNoteName(note), duration, linearVolume);
|
|
97
|
+
}
|
|
98
|
+
function stop() {
|
|
99
|
+
CurrentInstrument.stop();
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
getCurrentInstrument,
|
|
103
|
+
getInstrumentList,
|
|
104
|
+
playNote,
|
|
105
|
+
registerInstrument,
|
|
106
|
+
setInstrument,
|
|
107
|
+
stop
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=index.mjs.map
|