@tspro/web-music-score 4.2.0 → 5.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 +13 -0
- package/README.md +51 -17
- package/dist/audio/index.d.mts +9 -26
- package/dist/audio/index.d.ts +9 -26
- package/dist/audio/index.js +44 -25
- package/dist/audio/index.mjs +38 -24
- package/dist/audio-cg/index.d.mts +13 -3
- package/dist/audio-cg/index.d.ts +13 -3
- package/dist/audio-cg/index.js +54 -51
- package/dist/audio-cg/index.mjs +49 -52
- package/dist/chunk-AAL3CMRO.mjs +11 -0
- package/dist/{chunk-7MNV5JN6.mjs → chunk-EYFT3RWB.mjs} +3 -3
- package/dist/{chunk-5NWLGWHS.mjs → chunk-J3KU3U4W.mjs} +2 -2
- package/dist/core/index.d.mts +2 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.mjs +4 -3
- package/dist/iife/audio-cg.global.js +220 -0
- package/dist/iife/index.global.js +11 -11
- package/dist/instrument-DYboobMW.d.mts +44 -0
- package/dist/instrument-DYboobMW.d.ts +44 -0
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +22 -22
- package/dist/react-ui/index.d.ts +22 -22
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/score/index.d.mts +6 -6
- package/dist/score/index.d.ts +6 -6
- package/dist/score/index.js +24 -24
- package/dist/score/index.mjs +26 -26
- package/dist/theory/index.js +1 -1
- package/dist/theory/index.mjs +3 -3
- package/package.json +3 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrument interface.
|
|
3
|
+
* <p>To create your own instrument just create a class that implement this simple interface.</p>
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import * as Audio from "@tspro/web-music-score/audio";
|
|
7
|
+
*
|
|
8
|
+
* class MyCoolInstrument implements Audio.Instrument {
|
|
9
|
+
* constructor() { }
|
|
10
|
+
* getName() { return "My Cool Instrument"; }
|
|
11
|
+
* playNote(note: string, duration: number, linearVolume: number) { }
|
|
12
|
+
* stop() { }
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* // Add and use my cool instrument.
|
|
16
|
+
* Audio.addInstrument(new MyCoolInstrument());
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
interface Instrument {
|
|
20
|
+
/**
|
|
21
|
+
* Get instrument name.
|
|
22
|
+
* @return - Instrument name.
|
|
23
|
+
*/
|
|
24
|
+
getName(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Play a note.
|
|
27
|
+
* @param note - Note to play (e.g. "C4").
|
|
28
|
+
* @param duration - Play duration in seconds.
|
|
29
|
+
* @param linearVolume - Linear volume in range [0, 1].
|
|
30
|
+
*/
|
|
31
|
+
playNote(note: string, duration: number, linearVolume: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Stop playback.
|
|
34
|
+
*/
|
|
35
|
+
stop(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Linear volume to decibels converter.
|
|
39
|
+
* @param linearVolume - Linear volume in range [0, 1].
|
|
40
|
+
* @returns - Volume in decibels.
|
|
41
|
+
*/
|
|
42
|
+
declare function linearToDecibels(linearVolume: number): number;
|
|
43
|
+
|
|
44
|
+
export { type Instrument as I, linearToDecibels as l };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrument interface.
|
|
3
|
+
* <p>To create your own instrument just create a class that implement this simple interface.</p>
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import * as Audio from "@tspro/web-music-score/audio";
|
|
7
|
+
*
|
|
8
|
+
* class MyCoolInstrument implements Audio.Instrument {
|
|
9
|
+
* constructor() { }
|
|
10
|
+
* getName() { return "My Cool Instrument"; }
|
|
11
|
+
* playNote(note: string, duration: number, linearVolume: number) { }
|
|
12
|
+
* stop() { }
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* // Add and use my cool instrument.
|
|
16
|
+
* Audio.addInstrument(new MyCoolInstrument());
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
interface Instrument {
|
|
20
|
+
/**
|
|
21
|
+
* Get instrument name.
|
|
22
|
+
* @return - Instrument name.
|
|
23
|
+
*/
|
|
24
|
+
getName(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Play a note.
|
|
27
|
+
* @param note - Note to play (e.g. "C4").
|
|
28
|
+
* @param duration - Play duration in seconds.
|
|
29
|
+
* @param linearVolume - Linear volume in range [0, 1].
|
|
30
|
+
*/
|
|
31
|
+
playNote(note: string, duration: number, linearVolume: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Stop playback.
|
|
34
|
+
*/
|
|
35
|
+
stop(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Linear volume to decibels converter.
|
|
39
|
+
* @param linearVolume - Linear volume in range [0, 1].
|
|
40
|
+
* @returns - Volume in decibels.
|
|
41
|
+
*/
|
|
42
|
+
declare function linearToDecibels(linearVolume: number): number;
|
|
43
|
+
|
|
44
|
+
export { type Instrument as I, linearToDecibels as l };
|
package/dist/pieces/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore
|
|
1
|
+
/* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/pieces/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* WebMusicScore
|
|
2
|
-
import "../chunk-
|
|
1
|
+
/* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
|
+
import "../chunk-J3KU3U4W.mjs";
|
|
3
3
|
|
|
4
4
|
// src/pieces/frere-jacques.ts
|
|
5
5
|
import { DocumentBuilder } from "@tspro/web-music-score/score";
|
|
@@ -14,7 +14,7 @@ interface CircleOfFifthsProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Circle of fifths react component.
|
|
17
|
-
*
|
|
17
|
+
* ```ts
|
|
18
18
|
* // Using with React TSX/JSX
|
|
19
19
|
* import * as ScoreUI from "@tspro/web-music-score/react-ui";
|
|
20
20
|
* import * as Theory from "@tspro/web-music-score/theory";
|
|
@@ -27,14 +27,14 @@ interface CircleOfFifthsProps {
|
|
|
27
27
|
* console.log("New scale is " + newScale.getScaleName());
|
|
28
28
|
* }
|
|
29
29
|
*
|
|
30
|
-
* return
|
|
31
|
-
*
|
|
30
|
+
* return <>
|
|
31
|
+
* <ScoreUI.CircleOfFifths
|
|
32
32
|
* style={{ position: "relative", padding: "0.5em" }}
|
|
33
33
|
* scale={curScale}
|
|
34
|
-
* onScaleChange={onChangeScale}
|
|
35
|
-
*
|
|
34
|
+
* onScaleChange={onChangeScale} />
|
|
35
|
+
* </>;
|
|
36
36
|
* }
|
|
37
|
-
*
|
|
37
|
+
* ```
|
|
38
38
|
*/
|
|
39
39
|
declare class CircleOfFifths extends React.Component<CircleOfFifthsProps, {}> {
|
|
40
40
|
constructor(props: CircleOfFifthsProps);
|
|
@@ -187,7 +187,7 @@ interface GuitarViewState {
|
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* Guitar (neck) view react component.
|
|
190
|
-
*
|
|
190
|
+
* ```ts
|
|
191
191
|
* // Using with React TSX/JSX
|
|
192
192
|
* import * as ScoreUI from "@tspro/web-music-score/react-ui";
|
|
193
193
|
* import * as Theory from "@tspro/web-music-score/theory";
|
|
@@ -204,15 +204,15 @@ interface GuitarViewState {
|
|
|
204
204
|
* const onUpdateFretPosition: ScoreUI.UpdateFretPositionFunc = (fretPos) => { }
|
|
205
205
|
* const onClickFretPosition: ScoreUI.ClickFretPositionFunc = (fretPos) => { }
|
|
206
206
|
*
|
|
207
|
-
* return
|
|
208
|
-
*
|
|
207
|
+
* return <>
|
|
208
|
+
* <ScoreUI.GuitarView
|
|
209
209
|
* style={{ position: "relative", width: 640 }}
|
|
210
210
|
* guitarContext={guitarCtx}
|
|
211
211
|
* onUpdateFretPosition={onUpdateFretPosition}
|
|
212
|
-
* onClickFretPosition={onClickFretPosition}
|
|
213
|
-
*
|
|
212
|
+
* onClickFretPosition={onClickFretPosition} />
|
|
213
|
+
* </>;
|
|
214
214
|
* }
|
|
215
|
-
*
|
|
215
|
+
* ```
|
|
216
216
|
*/
|
|
217
217
|
declare class GuitarView extends React.Component<GuitarViewProps, GuitarViewState> {
|
|
218
218
|
state: GuitarViewState;
|
|
@@ -234,7 +234,7 @@ interface MusicScoreViewProps {
|
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Music score view react component.
|
|
237
|
-
*
|
|
237
|
+
* ```ts
|
|
238
238
|
* // Using with React TSX/JSX
|
|
239
239
|
* import * as Score from "@tspro/web-music-score/react";
|
|
240
240
|
* import * as Pieces from "@tspro/web-music-score/pieces";
|
|
@@ -243,11 +243,11 @@ interface MusicScoreViewProps {
|
|
|
243
243
|
* render() {
|
|
244
244
|
* const doc = Pieces.createFrereJacques();
|
|
245
245
|
*
|
|
246
|
-
* return
|
|
247
|
-
*
|
|
248
|
-
*
|
|
246
|
+
* return <>
|
|
247
|
+
* <Score.MusicScoreView doc=\{doc\} />
|
|
248
|
+
* </>;
|
|
249
249
|
* }
|
|
250
|
-
*
|
|
250
|
+
* ```
|
|
251
251
|
*/
|
|
252
252
|
declare class MusicScoreView extends React.Component<MusicScoreViewProps, {}> {
|
|
253
253
|
renderer: MRenderer;
|
|
@@ -273,7 +273,7 @@ interface PlaybackButtonsState {
|
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Usage:
|
|
276
|
-
*
|
|
276
|
+
* ```ts
|
|
277
277
|
* // Using with React TSX/JSX
|
|
278
278
|
* import * as Score from "\@tspro/web-music-score/score";
|
|
279
279
|
* import * as Pieces from "@tspro/web-music-score/pieces";
|
|
@@ -282,14 +282,14 @@ interface PlaybackButtonsState {
|
|
|
282
282
|
* const doc = Pieces.createFrereJacques();
|
|
283
283
|
*
|
|
284
284
|
* // Create default playback buttons
|
|
285
|
-
*
|
|
285
|
+
* <Score.PlaybackButtons doc={doc} />
|
|
286
286
|
*
|
|
287
287
|
* // Create playback buttons with custom play, pause and stop labels:
|
|
288
|
-
*
|
|
288
|
+
* <Score.PlaybackButtons doc={doc} playLabel="⏵" pauseLabel="⏸" stopLabel="⏹" />
|
|
289
289
|
*
|
|
290
290
|
* // Create playback buttons with different button layout.
|
|
291
|
-
*
|
|
292
|
-
*
|
|
291
|
+
* <Score.PlaybackButtons doc={doc} buttonLayout={Score.PlaybackButtonsLayout.PlayStopSingle} />
|
|
292
|
+
* ```
|
|
293
293
|
*/
|
|
294
294
|
declare class PlaybackButtons extends React.Component<PlaybackButtonsProps, PlaybackButtonsState> {
|
|
295
295
|
state: PlaybackButtonsState;
|
package/dist/react-ui/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface CircleOfFifthsProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Circle of fifths react component.
|
|
17
|
-
*
|
|
17
|
+
* ```ts
|
|
18
18
|
* // Using with React TSX/JSX
|
|
19
19
|
* import * as ScoreUI from "@tspro/web-music-score/react-ui";
|
|
20
20
|
* import * as Theory from "@tspro/web-music-score/theory";
|
|
@@ -27,14 +27,14 @@ interface CircleOfFifthsProps {
|
|
|
27
27
|
* console.log("New scale is " + newScale.getScaleName());
|
|
28
28
|
* }
|
|
29
29
|
*
|
|
30
|
-
* return
|
|
31
|
-
*
|
|
30
|
+
* return <>
|
|
31
|
+
* <ScoreUI.CircleOfFifths
|
|
32
32
|
* style={{ position: "relative", padding: "0.5em" }}
|
|
33
33
|
* scale={curScale}
|
|
34
|
-
* onScaleChange={onChangeScale}
|
|
35
|
-
*
|
|
34
|
+
* onScaleChange={onChangeScale} />
|
|
35
|
+
* </>;
|
|
36
36
|
* }
|
|
37
|
-
*
|
|
37
|
+
* ```
|
|
38
38
|
*/
|
|
39
39
|
declare class CircleOfFifths extends React.Component<CircleOfFifthsProps, {}> {
|
|
40
40
|
constructor(props: CircleOfFifthsProps);
|
|
@@ -187,7 +187,7 @@ interface GuitarViewState {
|
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* Guitar (neck) view react component.
|
|
190
|
-
*
|
|
190
|
+
* ```ts
|
|
191
191
|
* // Using with React TSX/JSX
|
|
192
192
|
* import * as ScoreUI from "@tspro/web-music-score/react-ui";
|
|
193
193
|
* import * as Theory from "@tspro/web-music-score/theory";
|
|
@@ -204,15 +204,15 @@ interface GuitarViewState {
|
|
|
204
204
|
* const onUpdateFretPosition: ScoreUI.UpdateFretPositionFunc = (fretPos) => { }
|
|
205
205
|
* const onClickFretPosition: ScoreUI.ClickFretPositionFunc = (fretPos) => { }
|
|
206
206
|
*
|
|
207
|
-
* return
|
|
208
|
-
*
|
|
207
|
+
* return <>
|
|
208
|
+
* <ScoreUI.GuitarView
|
|
209
209
|
* style={{ position: "relative", width: 640 }}
|
|
210
210
|
* guitarContext={guitarCtx}
|
|
211
211
|
* onUpdateFretPosition={onUpdateFretPosition}
|
|
212
|
-
* onClickFretPosition={onClickFretPosition}
|
|
213
|
-
*
|
|
212
|
+
* onClickFretPosition={onClickFretPosition} />
|
|
213
|
+
* </>;
|
|
214
214
|
* }
|
|
215
|
-
*
|
|
215
|
+
* ```
|
|
216
216
|
*/
|
|
217
217
|
declare class GuitarView extends React.Component<GuitarViewProps, GuitarViewState> {
|
|
218
218
|
state: GuitarViewState;
|
|
@@ -234,7 +234,7 @@ interface MusicScoreViewProps {
|
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Music score view react component.
|
|
237
|
-
*
|
|
237
|
+
* ```ts
|
|
238
238
|
* // Using with React TSX/JSX
|
|
239
239
|
* import * as Score from "@tspro/web-music-score/react";
|
|
240
240
|
* import * as Pieces from "@tspro/web-music-score/pieces";
|
|
@@ -243,11 +243,11 @@ interface MusicScoreViewProps {
|
|
|
243
243
|
* render() {
|
|
244
244
|
* const doc = Pieces.createFrereJacques();
|
|
245
245
|
*
|
|
246
|
-
* return
|
|
247
|
-
*
|
|
248
|
-
*
|
|
246
|
+
* return <>
|
|
247
|
+
* <Score.MusicScoreView doc=\{doc\} />
|
|
248
|
+
* </>;
|
|
249
249
|
* }
|
|
250
|
-
*
|
|
250
|
+
* ```
|
|
251
251
|
*/
|
|
252
252
|
declare class MusicScoreView extends React.Component<MusicScoreViewProps, {}> {
|
|
253
253
|
renderer: MRenderer;
|
|
@@ -273,7 +273,7 @@ interface PlaybackButtonsState {
|
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Usage:
|
|
276
|
-
*
|
|
276
|
+
* ```ts
|
|
277
277
|
* // Using with React TSX/JSX
|
|
278
278
|
* import * as Score from "\@tspro/web-music-score/score";
|
|
279
279
|
* import * as Pieces from "@tspro/web-music-score/pieces";
|
|
@@ -282,14 +282,14 @@ interface PlaybackButtonsState {
|
|
|
282
282
|
* const doc = Pieces.createFrereJacques();
|
|
283
283
|
*
|
|
284
284
|
* // Create default playback buttons
|
|
285
|
-
*
|
|
285
|
+
* <Score.PlaybackButtons doc={doc} />
|
|
286
286
|
*
|
|
287
287
|
* // Create playback buttons with custom play, pause and stop labels:
|
|
288
|
-
*
|
|
288
|
+
* <Score.PlaybackButtons doc={doc} playLabel="⏵" pauseLabel="⏸" stopLabel="⏹" />
|
|
289
289
|
*
|
|
290
290
|
* // Create playback buttons with different button layout.
|
|
291
|
-
*
|
|
292
|
-
*
|
|
291
|
+
* <Score.PlaybackButtons doc={doc} buttonLayout={Score.PlaybackButtonsLayout.PlayStopSingle} />
|
|
292
|
+
* ```
|
|
293
293
|
*/
|
|
294
294
|
declare class PlaybackButtons extends React.Component<PlaybackButtonsProps, PlaybackButtonsState> {
|
|
295
295
|
state: PlaybackButtonsState;
|
package/dist/react-ui/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore
|
|
1
|
+
/* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist/react-ui/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* WebMusicScore
|
|
1
|
+
/* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
import {
|
|
3
3
|
__publicField
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-J3KU3U4W.mjs";
|
|
5
5
|
|
|
6
6
|
// src/react-ui/circle-of-fifths.tsx
|
|
7
7
|
import * as React from "react";
|
package/dist/score/index.d.mts
CHANGED
|
@@ -59,7 +59,7 @@ type ExtensionBuilder = {
|
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* Document builder class.
|
|
62
|
-
*
|
|
62
|
+
* ```ts
|
|
63
63
|
* // Example
|
|
64
64
|
* let doc = new Score.DocumentBuilder()
|
|
65
65
|
* .addScoreConfiguration({ type: "staff", clef: "G", isOctavewDown: true })
|
|
@@ -70,7 +70,7 @@ type ExtensionBuilder = {
|
|
|
70
70
|
* .addRest(1, "4n")
|
|
71
71
|
* // etc.
|
|
72
72
|
* .getDEocument();
|
|
73
|
-
*
|
|
73
|
+
* ```
|
|
74
74
|
*/
|
|
75
75
|
declare class DocumentBuilder {
|
|
76
76
|
private readonly doc;
|
|
@@ -208,13 +208,13 @@ declare class DocumentBuilder {
|
|
|
208
208
|
addRest(voiceId: VoiceId, restLength: NoteLength | NoteLengthStr, restOptions?: RestOptions): DocumentBuilder;
|
|
209
209
|
/**
|
|
210
210
|
* Usage:
|
|
211
|
-
*
|
|
211
|
+
* ```ts
|
|
212
212
|
* addTuplet(0, Theory.Tuplet.Triplet, notes => {
|
|
213
213
|
* notes.addNote("G3", Theory.NoteLength.Eighth);
|
|
214
214
|
* notes.addNote("B3", Theory.NoteLength.Eighth);
|
|
215
215
|
* notes.addNote("D4", Theory.NoteLength.Eighth);
|
|
216
216
|
* });
|
|
217
|
-
*
|
|
217
|
+
* ```
|
|
218
218
|
*
|
|
219
219
|
* @param voiceId - Voice id to add tuplet to.
|
|
220
220
|
* @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
|
|
@@ -371,13 +371,13 @@ declare class DocumentBuilder {
|
|
|
371
371
|
addConnective(connective: Connective.Slide | `${Connective.Slide}`, notAnchor?: NoteAnchor | `${NoteAnchor}`): DocumentBuilder;
|
|
372
372
|
/**
|
|
373
373
|
* Add extension line to previously added annotation or label element.
|
|
374
|
-
*
|
|
374
|
+
* ```ts
|
|
375
375
|
* // Example
|
|
376
376
|
* addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
|
|
377
377
|
* addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
|
|
378
378
|
* addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
|
|
379
379
|
* addExtension(ext => ext.infinity()) // length is as long as possible
|
|
380
|
-
*
|
|
380
|
+
* ```
|
|
381
381
|
* @param extensionBuilder - Extension builder function used to build exstension.
|
|
382
382
|
* @returns - This document builder instance.
|
|
383
383
|
*/
|
package/dist/score/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ type ExtensionBuilder = {
|
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* Document builder class.
|
|
62
|
-
*
|
|
62
|
+
* ```ts
|
|
63
63
|
* // Example
|
|
64
64
|
* let doc = new Score.DocumentBuilder()
|
|
65
65
|
* .addScoreConfiguration({ type: "staff", clef: "G", isOctavewDown: true })
|
|
@@ -70,7 +70,7 @@ type ExtensionBuilder = {
|
|
|
70
70
|
* .addRest(1, "4n")
|
|
71
71
|
* // etc.
|
|
72
72
|
* .getDEocument();
|
|
73
|
-
*
|
|
73
|
+
* ```
|
|
74
74
|
*/
|
|
75
75
|
declare class DocumentBuilder {
|
|
76
76
|
private readonly doc;
|
|
@@ -208,13 +208,13 @@ declare class DocumentBuilder {
|
|
|
208
208
|
addRest(voiceId: VoiceId, restLength: NoteLength | NoteLengthStr, restOptions?: RestOptions): DocumentBuilder;
|
|
209
209
|
/**
|
|
210
210
|
* Usage:
|
|
211
|
-
*
|
|
211
|
+
* ```ts
|
|
212
212
|
* addTuplet(0, Theory.Tuplet.Triplet, notes => {
|
|
213
213
|
* notes.addNote("G3", Theory.NoteLength.Eighth);
|
|
214
214
|
* notes.addNote("B3", Theory.NoteLength.Eighth);
|
|
215
215
|
* notes.addNote("D4", Theory.NoteLength.Eighth);
|
|
216
216
|
* });
|
|
217
|
-
*
|
|
217
|
+
* ```
|
|
218
218
|
*
|
|
219
219
|
* @param voiceId - Voice id to add tuplet to.
|
|
220
220
|
* @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
|
|
@@ -371,13 +371,13 @@ declare class DocumentBuilder {
|
|
|
371
371
|
addConnective(connective: Connective.Slide | `${Connective.Slide}`, notAnchor?: NoteAnchor | `${NoteAnchor}`): DocumentBuilder;
|
|
372
372
|
/**
|
|
373
373
|
* Add extension line to previously added annotation or label element.
|
|
374
|
-
*
|
|
374
|
+
* ```ts
|
|
375
375
|
* // Example
|
|
376
376
|
* addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
|
|
377
377
|
* addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
|
|
378
378
|
* addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
|
|
379
379
|
* addExtension(ext => ext.infinity()) // length is as long as possible
|
|
380
|
-
*
|
|
380
|
+
* ```
|
|
381
381
|
* @param extensionBuilder - Extension builder function used to build exstension.
|
|
382
382
|
* @returns - This document builder instance.
|
|
383
383
|
*/
|
package/dist/score/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore
|
|
1
|
+
/* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1816,24 +1816,24 @@ var ObjRest = class extends MusicObject {
|
|
|
1816
1816
|
visibleInStaff(staff) {
|
|
1817
1817
|
return staff.containsVoiceId(this.voiceId) && this.staffObjects.some((obj) => obj instanceof ObjStaffRest && obj.staff === staff);
|
|
1818
1818
|
}
|
|
1819
|
-
getRestDotVerticalDisplacement(
|
|
1820
|
-
switch (
|
|
1821
|
-
case
|
|
1819
|
+
getRestDotVerticalDisplacement(noteSize) {
|
|
1820
|
+
switch (noteSize) {
|
|
1821
|
+
case 1:
|
|
1822
1822
|
return 1;
|
|
1823
|
-
case
|
|
1823
|
+
case 2:
|
|
1824
1824
|
return -1;
|
|
1825
|
-
case
|
|
1825
|
+
case 4:
|
|
1826
1826
|
return -1;
|
|
1827
|
-
case
|
|
1827
|
+
case 8:
|
|
1828
1828
|
return -1;
|
|
1829
|
-
case
|
|
1829
|
+
case 16:
|
|
1830
1830
|
return -1;
|
|
1831
|
-
case
|
|
1831
|
+
case 32:
|
|
1832
1832
|
return -3;
|
|
1833
|
-
case
|
|
1833
|
+
case 64:
|
|
1834
1834
|
return -3;
|
|
1835
1835
|
default:
|
|
1836
|
-
throw new import_core5.MusicError(import_core5.MusicErrorType.Score,
|
|
1836
|
+
throw new import_core5.MusicError(import_core5.MusicErrorType.Score, `Get rest dot vertical displacement: Invalid note size: ${noteSize}`);
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
1839
|
updateAccidentalState(accState) {
|
|
@@ -1846,22 +1846,22 @@ var ObjRest = class extends MusicObject {
|
|
|
1846
1846
|
}
|
|
1847
1847
|
let { unitSize } = renderer;
|
|
1848
1848
|
let { ownDiatonicId } = this;
|
|
1849
|
-
let {
|
|
1849
|
+
let { noteSize, dotCount, flagCount } = this.rhythmProps;
|
|
1850
1850
|
let leftw = 0;
|
|
1851
1851
|
let rightw = 0;
|
|
1852
1852
|
let toph = 0;
|
|
1853
1853
|
let bottomh = 0;
|
|
1854
|
-
if (
|
|
1854
|
+
if (import_theory3.NoteLengthProps.equals(noteSize, import_theory3.NoteLength.Whole)) {
|
|
1855
1855
|
leftw = unitSize;
|
|
1856
1856
|
rightw = unitSize;
|
|
1857
1857
|
toph = 0;
|
|
1858
1858
|
bottomh = unitSize;
|
|
1859
|
-
} else if (
|
|
1859
|
+
} else if (import_theory3.NoteLengthProps.equals(noteSize, import_theory3.NoteLength.Half)) {
|
|
1860
1860
|
leftw = unitSize;
|
|
1861
1861
|
rightw = unitSize;
|
|
1862
1862
|
toph = unitSize;
|
|
1863
1863
|
bottomh = 0;
|
|
1864
|
-
} else if (
|
|
1864
|
+
} else if (import_theory3.NoteLengthProps.equals(noteSize, import_theory3.NoteLength.Quarter)) {
|
|
1865
1865
|
leftw = unitSize * 1;
|
|
1866
1866
|
rightw = unitSize * 1;
|
|
1867
1867
|
toph = unitSize * 3.2;
|
|
@@ -1882,7 +1882,7 @@ var ObjRest = class extends MusicObject {
|
|
|
1882
1882
|
for (let i = 0; i < dotCount; i++) {
|
|
1883
1883
|
let dotWidth = DocumentSettings.DotSize * unitSize;
|
|
1884
1884
|
let dotX = rightw + (DocumentSettings.RestDotSpace + DocumentSettings.DotSize * unitSize) + i * DocumentSettings.DotSize * unitSize * 1.5;
|
|
1885
|
-
let dotY = this.getRestDotVerticalDisplacement(
|
|
1885
|
+
let dotY = this.getRestDotVerticalDisplacement(noteSize) * unitSize;
|
|
1886
1886
|
obj.dotRects.push(DivRect.createCentered(dotX, dotY, dotWidth, dotWidth));
|
|
1887
1887
|
}
|
|
1888
1888
|
obj.offset(0, staff.getDiatonicIdY(ownDiatonicId));
|
|
@@ -1913,18 +1913,18 @@ var ObjRest = class extends MusicObject {
|
|
|
1913
1913
|
renderer.drawDebugRect(this.getRect());
|
|
1914
1914
|
let { unitSize, lineWidth } = renderer;
|
|
1915
1915
|
let { color } = this;
|
|
1916
|
-
let {
|
|
1916
|
+
let { noteSize, flagCount } = this.rhythmProps;
|
|
1917
1917
|
ctx.strokeStyle = ctx.fillStyle = color;
|
|
1918
1918
|
ctx.lineWidth = lineWidth;
|
|
1919
1919
|
this.staffObjects.forEach((obj) => {
|
|
1920
1920
|
let { dotRects, restRect } = obj;
|
|
1921
1921
|
let x = restRect.centerX;
|
|
1922
1922
|
let y = restRect.centerY;
|
|
1923
|
-
if (
|
|
1923
|
+
if (import_theory3.NoteLengthProps.equals(noteSize, import_theory3.NoteLength.Whole)) {
|
|
1924
1924
|
ctx.fillRect(x - unitSize, y, unitSize * 2, unitSize);
|
|
1925
|
-
} else if (
|
|
1925
|
+
} else if (import_theory3.NoteLengthProps.equals(noteSize, import_theory3.NoteLength.Half)) {
|
|
1926
1926
|
ctx.fillRect(x - unitSize, y - unitSize, unitSize * 2, unitSize);
|
|
1927
|
-
} else if (
|
|
1927
|
+
} else if (import_theory3.NoteLengthProps.equals(noteSize, import_theory3.NoteLength.Quarter)) {
|
|
1928
1928
|
ctx.beginPath();
|
|
1929
1929
|
ctx.moveTo(x - unitSize * 0.6, y - unitSize * 3.2);
|
|
1930
1930
|
ctx.lineTo(x + unitSize * 0.7, y - unitSize * 1.5);
|
|
@@ -7762,13 +7762,13 @@ var DocumentBuilder = class {
|
|
|
7762
7762
|
}
|
|
7763
7763
|
/**
|
|
7764
7764
|
* Usage:
|
|
7765
|
-
*
|
|
7765
|
+
* ```ts
|
|
7766
7766
|
* addTuplet(0, Theory.Tuplet.Triplet, notes => {
|
|
7767
7767
|
* notes.addNote("G3", Theory.NoteLength.Eighth);
|
|
7768
7768
|
* notes.addNote("B3", Theory.NoteLength.Eighth);
|
|
7769
7769
|
* notes.addNote("D4", Theory.NoteLength.Eighth);
|
|
7770
7770
|
* });
|
|
7771
|
-
*
|
|
7771
|
+
* ```
|
|
7772
7772
|
*
|
|
7773
7773
|
* @param voiceId - Voice id to add tuplet to.
|
|
7774
7774
|
* @param tupletRatio - You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).
|
|
@@ -7983,13 +7983,13 @@ var DocumentBuilder = class {
|
|
|
7983
7983
|
}
|
|
7984
7984
|
/**
|
|
7985
7985
|
* Add extension line to previously added annotation or label element.
|
|
7986
|
-
*
|
|
7986
|
+
* ```ts
|
|
7987
7987
|
* // Example
|
|
7988
7988
|
* addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
|
|
7989
7989
|
* addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
|
|
7990
7990
|
* addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
|
|
7991
7991
|
* addExtension(ext => ext.infinity()) // length is as long as possible
|
|
7992
|
-
*
|
|
7992
|
+
* ```
|
|
7993
7993
|
* @param extensionBuilder - Extension builder function used to build exstension.
|
|
7994
7994
|
* @returns - This document builder instance.
|
|
7995
7995
|
*/
|