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,92 @@
|
|
|
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
|
+
linearToDecibels
|
|
4
|
+
} from "../chunk-VHB57TXT.mjs";
|
|
5
|
+
import {
|
|
6
|
+
guard_exports,
|
|
7
|
+
utils_exports
|
|
8
|
+
} from "../chunk-X7BMJX7E.mjs";
|
|
9
|
+
import "../chunk-A7C2G7OG.mjs";
|
|
10
|
+
|
|
11
|
+
// src/audio/index.ts
|
|
12
|
+
import { Note, PitchNotation, SymbolSet } from "web-music-score/theory";
|
|
13
|
+
import { init as initCore, MusicError, MusicErrorType } from "web-music-score/core";
|
|
14
|
+
import { Synthesizer } from "web-music-score/audio-synth";
|
|
15
|
+
initCore();
|
|
16
|
+
function getNoteName(note) {
|
|
17
|
+
if (typeof note === "string") {
|
|
18
|
+
return note;
|
|
19
|
+
} else if (typeof note === "number") {
|
|
20
|
+
note = Note.getChromaticNote(note);
|
|
21
|
+
}
|
|
22
|
+
return note.format(PitchNotation.Scientific, SymbolSet.Ascii);
|
|
23
|
+
}
|
|
24
|
+
var InstrumentList = [Synthesizer];
|
|
25
|
+
var currentInstrument = Synthesizer;
|
|
26
|
+
var DefaultDuration = (function calcDuration(noteSize, beatsPerMinute, timeTisgnature) {
|
|
27
|
+
var _a;
|
|
28
|
+
let beatSize = parseInt((_a = timeTisgnature.split("/")[1]) != null ? _a : "4");
|
|
29
|
+
return 60 * (1 / noteSize) / (beatsPerMinute * (1 / beatSize));
|
|
30
|
+
})(2, 80, "4/4");
|
|
31
|
+
var DefaultVolume = 1;
|
|
32
|
+
var mutePlayback = false;
|
|
33
|
+
function getInstrumentList() {
|
|
34
|
+
return InstrumentList.map((instr) => instr.getName());
|
|
35
|
+
}
|
|
36
|
+
function getCurrentInstrument() {
|
|
37
|
+
return currentInstrument.getName();
|
|
38
|
+
}
|
|
39
|
+
function addInstrument(instrument) {
|
|
40
|
+
(guard_exports.isArray(instrument) ? instrument : [instrument]).forEach((instr) => {
|
|
41
|
+
if (!utils_exports.Obj.hasProperties(instr, ["getName", "playNote", "stop"]) || !guard_exports.isFunction(instr.getName) || !guard_exports.isFunction(instr.playNote) || !guard_exports.isFunction(instr.stop)) {
|
|
42
|
+
throw new MusicError(MusicErrorType.Audio, "Invalid instrument object: " + instr);
|
|
43
|
+
}
|
|
44
|
+
if (InstrumentList.some((instr2) => instr2.getName() === instr.getName())) {
|
|
45
|
+
console.warn(`Instrument "${instr.getName()}" already added!`);
|
|
46
|
+
} else {
|
|
47
|
+
InstrumentList.push(instr);
|
|
48
|
+
}
|
|
49
|
+
useInstrument(instr.getName());
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function useInstrument(instrumentName) {
|
|
53
|
+
if (instrumentName === currentInstrument.getName()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
currentInstrument.stop();
|
|
57
|
+
let instr = InstrumentList.find((instr2) => instr2.getName() === instrumentName);
|
|
58
|
+
if (instr) {
|
|
59
|
+
currentInstrument = instr;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function playNote(note, duration, linearVolume) {
|
|
63
|
+
if (!mutePlayback) {
|
|
64
|
+
currentInstrument.playNote(getNoteName(note), duration != null ? duration : DefaultDuration, linearVolume != null ? linearVolume : DefaultVolume);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function stop() {
|
|
68
|
+
currentInstrument.stop();
|
|
69
|
+
}
|
|
70
|
+
function mute() {
|
|
71
|
+
stop();
|
|
72
|
+
mutePlayback = true;
|
|
73
|
+
}
|
|
74
|
+
function unmute() {
|
|
75
|
+
mutePlayback = false;
|
|
76
|
+
}
|
|
77
|
+
function isMuted() {
|
|
78
|
+
return mutePlayback;
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
addInstrument,
|
|
82
|
+
getCurrentInstrument,
|
|
83
|
+
getInstrumentList,
|
|
84
|
+
isMuted,
|
|
85
|
+
linearToDecibels,
|
|
86
|
+
mute,
|
|
87
|
+
playNote,
|
|
88
|
+
stop,
|
|
89
|
+
unmute,
|
|
90
|
+
useInstrument
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { I as Instrument } from '../instrument-DS-9C6_8.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Make this module "audio-cg" in typedoc instead of "audio-instruments/audio-cg".
|
|
5
|
+
* @module audio-cg
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Export classical guitar instrument object.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Usage
|
|
13
|
+
* import * as Audio from "web-music-score/audio";
|
|
14
|
+
* import { ClassicalGuitar } from "web-music-score/audio-cg";
|
|
15
|
+
*
|
|
16
|
+
* Audio.addInstrument(ClassicalGuitar);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const ClassicalGuitar: Instrument;
|
|
20
|
+
|
|
21
|
+
export { ClassicalGuitar };
|