@scorelabs/viewer 1.0.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/README.md +5 -0
- package/dist/android-chrome-192x192.png +0 -0
- package/dist/android-chrome-512x512.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/audio/AudioPlayer.d.ts +54 -0
- package/dist/favicon-16x16.png +0 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/favicon-96x96.png +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/favicon.svg +1 -0
- package/dist/importers/MusicXMLParser.d.ts +51 -0
- package/dist/importers/index.d.ts +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/layouts/LayoutConfig.d.ts +62 -0
- package/dist/layouts/LayoutUtils.d.ts +10 -0
- package/dist/layouts/MeasureLayout.d.ts +20 -0
- package/dist/layouts/NoteLayout.d.ts +21 -0
- package/dist/layouts/ScoreLayout.d.ts +28 -0
- package/dist/layouts/StaffLayout.d.ts +26 -0
- package/dist/layouts/StaffSystemLayout.d.ts +18 -0
- package/dist/layouts/index.d.ts +6 -0
- package/dist/models/Instrument.d.ts +26 -0
- package/dist/models/Measure.d.ts +80 -0
- package/dist/models/Note.d.ts +122 -0
- package/dist/models/Part.d.ts +60 -0
- package/dist/models/Pitch.d.ts +45 -0
- package/dist/models/Score.d.ts +120 -0
- package/dist/models/Staff.d.ts +57 -0
- package/dist/models/__tests__/Note.test.d.ts +1 -0
- package/dist/models/__tests__/Pitch.test.d.ts +1 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/types.d.ts +163 -0
- package/dist/new_score.json +112 -0
- package/dist/rendering/NoteRenderer.d.ts +52 -0
- package/dist/rendering/ScoreRenderer.d.ts +35 -0
- package/dist/rendering/StaffRenderer.d.ts +67 -0
- package/dist/rendering/glyphs/AccidentalGlyphs.d.ts +5 -0
- package/dist/rendering/glyphs/ClefGlyphs.d.ts +19 -0
- package/dist/rendering/glyphs/DecorationGlyphs.d.ts +11 -0
- package/dist/rendering/glyphs/NoteGlyphs.d.ts +19 -0
- package/dist/rendering/glyphs/RestGlyphs.d.ts +11 -0
- package/dist/rendering/glyphs/SignatureGlyphs.d.ts +11 -0
- package/dist/rendering/glyphs/index.d.ts +6 -0
- package/dist/rendering/index.d.ts +4 -0
- package/dist/satb.xml +4 -0
- package/dist/score-viewer.js +13234 -0
- package/dist/score-viewer.umd.cjs +145 -0
- package/dist/scores/canon_pachelbel.xml +4 -0
- package/dist/scores/el_cant_dels_ocells.xml +112 -0
- package/dist/scores/el_noi_de_la_mare.xml +102 -0
- package/dist/scores/els_segadors.xml +110 -0
- package/dist/scores/imported/forest.xml +161 -0
- package/dist/showcase.json +292 -0
- package/dist/site.webmanifest +21 -0
- package/dist/src/App.d.ts +1 -0
- package/dist/src/components/AboutDialog.d.ts +6 -0
- package/dist/src/components/ChordDialog.d.ts +8 -0
- package/dist/src/components/ClefDialog.d.ts +9 -0
- package/dist/src/components/FloatingToolbar.d.ts +26 -0
- package/dist/src/components/InstrumentsDialog.d.ts +22 -0
- package/dist/src/components/KeySignatureDialog.d.ts +9 -0
- package/dist/src/components/Logo.d.ts +6 -0
- package/dist/src/components/MenuBar.d.ts +20 -0
- package/dist/src/components/NoteInputToolbar.d.ts +101 -0
- package/dist/src/components/PageSetupDialog.d.ts +9 -0
- package/dist/src/components/ScoreCanvas.d.ts +49 -0
- package/dist/src/components/ScoreInfoDialog.d.ts +19 -0
- package/dist/src/components/ScoreLayoutDialog.d.ts +9 -0
- package/dist/src/components/TempoDialog.d.ts +11 -0
- package/dist/src/components/TextDialog.d.ts +10 -0
- package/dist/src/components/TimeSignatureDialog.d.ts +9 -0
- package/dist/src/components/TransposeDialog.d.ts +9 -0
- package/dist/src/components/VirtualKeyboard.d.ts +10 -0
- package/dist/src/exporters/MusicXMLExporter.d.ts +10 -0
- package/dist/src/hooks/useHistory.d.ts +14 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/main.d.ts +1 -0
- package/dist/src/services/HarmonyService.d.ts +10 -0
- package/dist/src/services/VocalSynthesisService.d.ts +13 -0
- package/dist/src/utils/pdfToPng.d.ts +5 -0
- package/dist/web-app-manifest-192x192.png +0 -0
- package/dist/web-app-manifest-512x512.png +0 -0
- package/package.json +63 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { TimeSignature, KeySignature, Duration } from './types';
|
|
2
|
+
import { Part, PartJSON } from './Part';
|
|
3
|
+
import { Staff } from './Staff';
|
|
4
|
+
import { Note } from './Note';
|
|
5
|
+
import { Measure } from './Measure';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a complete musical score.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Score {
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly composer: string;
|
|
12
|
+
readonly timeSignature: TimeSignature;
|
|
13
|
+
readonly keySignature: KeySignature;
|
|
14
|
+
readonly parts: Part[];
|
|
15
|
+
readonly bpm: number;
|
|
16
|
+
readonly tempoDuration: Duration;
|
|
17
|
+
readonly tempoIsDotted: boolean;
|
|
18
|
+
readonly copyright: string;
|
|
19
|
+
readonly lyricist: string;
|
|
20
|
+
readonly swing: boolean;
|
|
21
|
+
readonly subtitle: string;
|
|
22
|
+
constructor(title: string, composer: string, timeSignature: TimeSignature, keySignature: KeySignature, parts: Part[], bpm?: number, tempoDuration?: Duration, tempoIsDotted?: boolean, copyright?: string, lyricist?: string, swing?: boolean, subtitle?: string);
|
|
23
|
+
withTitle(title: string): Score;
|
|
24
|
+
withComposer(composer: string): Score;
|
|
25
|
+
withSubtitle(subtitle: string): Score;
|
|
26
|
+
/**
|
|
27
|
+
* Get total number of measures in the score
|
|
28
|
+
*/
|
|
29
|
+
getMeasureCount(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Get the active time signature at a specific measure index.
|
|
32
|
+
*/
|
|
33
|
+
getTimeSignatureAt(measureIndex: number): TimeSignature;
|
|
34
|
+
/**
|
|
35
|
+
* Get the active key signature at a specific measure index.
|
|
36
|
+
*/
|
|
37
|
+
getKeySignatureAt(measureIndex: number): KeySignature;
|
|
38
|
+
/**
|
|
39
|
+
* Get all staves across all parts (flattened)
|
|
40
|
+
*/
|
|
41
|
+
getAllStaves(): {
|
|
42
|
+
partIndex: number;
|
|
43
|
+
staffIndex: number;
|
|
44
|
+
staff: Staff;
|
|
45
|
+
}[];
|
|
46
|
+
/**
|
|
47
|
+
* Create a completely empty Score
|
|
48
|
+
*/
|
|
49
|
+
static empty(): Score;
|
|
50
|
+
/**
|
|
51
|
+
* Create a Score from JSON data
|
|
52
|
+
*/
|
|
53
|
+
static fromJSON(data: ScoreJSON): Score;
|
|
54
|
+
/**
|
|
55
|
+
* Create a Score from MusicXML string
|
|
56
|
+
*/
|
|
57
|
+
static fromMusicXML(xmlString: string): Score;
|
|
58
|
+
/**
|
|
59
|
+
* Transpose the entire score by semitones.
|
|
60
|
+
* Returns a new Score with all notes transposed.
|
|
61
|
+
* Key signature is also adjusted.
|
|
62
|
+
*/
|
|
63
|
+
transpose(semitones: number): Score;
|
|
64
|
+
/**
|
|
65
|
+
* Replaces a note and automatically updates beams in the affected measure.
|
|
66
|
+
*/
|
|
67
|
+
replaceNote(partIndex: number, staffIndex: number, measureIndex: number, noteIndex: number, newNote: Note, voiceIndex?: number): Score;
|
|
68
|
+
/**
|
|
69
|
+
* Replaces a measure and optionally automatically updates beams.
|
|
70
|
+
*/
|
|
71
|
+
replaceMeasure(partIndex: number, staffIndex: number, measureIndex: number, newMeasure: Measure, autoBeam?: boolean): Score;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a note in a specific part/staff/measure
|
|
74
|
+
*/
|
|
75
|
+
deleteNote(partIndex: number, staffIndex: number, measureIndex: number, noteIndex: number, voiceIndex?: number): Score;
|
|
76
|
+
/**
|
|
77
|
+
* Change note duration in a specific part/staff/measure
|
|
78
|
+
*/
|
|
79
|
+
changeNoteDuration(partIndex: number, staffIndex: number, measureIndex: number, noteIndex: number, newDuration: Duration, isDotted?: boolean, voiceIndex?: number): Score;
|
|
80
|
+
/**
|
|
81
|
+
* Paste notes starting at a specific location, handling measure overflow
|
|
82
|
+
*/
|
|
83
|
+
pasteNotes(partIndex: number, staffIndex: number, measureIndex: number, noteIndex: number, notesToPaste: Note[]): Score;
|
|
84
|
+
/**
|
|
85
|
+
* Update tempo settings
|
|
86
|
+
*/
|
|
87
|
+
withTempo(bpm: number, duration: Duration, isDotted: boolean): Score;
|
|
88
|
+
withSwing(swing: boolean): Score;
|
|
89
|
+
withLyricist(lyricist: string): Score;
|
|
90
|
+
withCopyright(copyright: string): Score;
|
|
91
|
+
/**
|
|
92
|
+
* Convert to JSON
|
|
93
|
+
*/
|
|
94
|
+
toJSON(): ScoreJSON;
|
|
95
|
+
replacePart(partIndex: number, newPart: Part): Score;
|
|
96
|
+
addPart(newPart: Part): Score;
|
|
97
|
+
removePart(partIndex: number): Score;
|
|
98
|
+
replaceStaff(partIndex: number, staffIndex: number, newStaff: Staff): Score;
|
|
99
|
+
addMeasure(index: number, measure: Measure): Score;
|
|
100
|
+
deleteMeasure(index: number): Score;
|
|
101
|
+
/**
|
|
102
|
+
* Returns an unrolled sequence of measure indices for playback,
|
|
103
|
+
* considering repeat markers and Voltas (endings).
|
|
104
|
+
*/
|
|
105
|
+
getPlaybackSequence(): number[];
|
|
106
|
+
}
|
|
107
|
+
export interface ScoreJSON {
|
|
108
|
+
title: string;
|
|
109
|
+
composer: string;
|
|
110
|
+
timeSignature: TimeSignature;
|
|
111
|
+
keySignature: KeySignature;
|
|
112
|
+
parts: PartJSON[];
|
|
113
|
+
bpm?: number;
|
|
114
|
+
tempoDuration?: Duration;
|
|
115
|
+
tempoIsDotted?: boolean;
|
|
116
|
+
copyright?: string;
|
|
117
|
+
lyricist?: string;
|
|
118
|
+
swing?: boolean;
|
|
119
|
+
subtitle?: string;
|
|
120
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Clef, Duration } from './types';
|
|
2
|
+
import { Measure, MeasureJSON } from './Measure';
|
|
3
|
+
import { Pitch } from './Pitch';
|
|
4
|
+
import { Note } from './Note';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a single staff (one set of 5 lines with a clef).
|
|
7
|
+
*/
|
|
8
|
+
export declare class Staff {
|
|
9
|
+
readonly clef: Clef;
|
|
10
|
+
readonly measures: Measure[];
|
|
11
|
+
readonly lineCount: number;
|
|
12
|
+
readonly tuning?: Pitch[] | undefined;
|
|
13
|
+
constructor(clef: Clef, measures: Measure[], lineCount?: number, tuning?: Pitch[] | undefined);
|
|
14
|
+
/**
|
|
15
|
+
* Get total number of measures
|
|
16
|
+
*/
|
|
17
|
+
getMeasureCount(): number;
|
|
18
|
+
/**
|
|
19
|
+
* Create a Staff from JSON data
|
|
20
|
+
*/
|
|
21
|
+
static fromJSON(data: StaffJSON): Staff;
|
|
22
|
+
/**
|
|
23
|
+
* Transpose all measures in this staff by semitones
|
|
24
|
+
*/
|
|
25
|
+
transpose(semitones: number): Staff;
|
|
26
|
+
/**
|
|
27
|
+
* Replace a note in a specific measure
|
|
28
|
+
*/
|
|
29
|
+
replaceNote(measureIndex: number, noteIndex: number, newNote: Note, voiceIndex?: number): Staff;
|
|
30
|
+
replaceMeasure(measureIndex: number, newMeasure: Measure): Staff;
|
|
31
|
+
/**
|
|
32
|
+
* Delete a note in a specific measure
|
|
33
|
+
*/
|
|
34
|
+
deleteNote(measureIndex: number, noteIndex: number, voiceIndex?: number): Staff;
|
|
35
|
+
/**
|
|
36
|
+
* Change note duration in a specific measure
|
|
37
|
+
*/
|
|
38
|
+
changeNoteDuration(measureIndex: number, noteIndex: number, newDuration: Duration, isDotted?: boolean, voiceIndex?: number): Staff;
|
|
39
|
+
/**
|
|
40
|
+
* Convert to JSON
|
|
41
|
+
*/
|
|
42
|
+
toJSON(): StaffJSON;
|
|
43
|
+
withClef(clef: Clef): Staff;
|
|
44
|
+
withLineCount(lineCount: number): Staff;
|
|
45
|
+
withTuning(tuning: Pitch[]): Staff;
|
|
46
|
+
withMeasures(measures: Measure[]): Staff;
|
|
47
|
+
addMeasure(index: number, measure: Measure): Staff;
|
|
48
|
+
deleteMeasure(index: number): Staff;
|
|
49
|
+
}
|
|
50
|
+
export interface StaffJSON {
|
|
51
|
+
clef: string;
|
|
52
|
+
measures: MeasureJSON[];
|
|
53
|
+
lineCount?: number;
|
|
54
|
+
tuning?: {
|
|
55
|
+
midiNumber: number;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and enums for the score viewer
|
|
3
|
+
*/
|
|
4
|
+
export declare enum StemDirection {
|
|
5
|
+
Up = "up",
|
|
6
|
+
Down = "down"
|
|
7
|
+
}
|
|
8
|
+
export declare enum Clef {
|
|
9
|
+
Treble = "treble",
|
|
10
|
+
Bass = "bass",
|
|
11
|
+
Alto = "alto",
|
|
12
|
+
Tenor = "tenor",
|
|
13
|
+
Percussion = "percussion",
|
|
14
|
+
Tab = "tab"
|
|
15
|
+
}
|
|
16
|
+
export declare enum Duration {
|
|
17
|
+
Whole = "whole",
|
|
18
|
+
Half = "half",
|
|
19
|
+
Quarter = "quarter",
|
|
20
|
+
Eighth = "eighth",
|
|
21
|
+
Sixteenth = "sixteenth",
|
|
22
|
+
ThirtySecond = "thirty-second",
|
|
23
|
+
SixtyFourth = "sixty-fourth",
|
|
24
|
+
OneHundredTwentyEighth = "one-hundred-twenty-eighth",
|
|
25
|
+
TwoHundredFiftySixth = "two-hundred-fifty-sixth"
|
|
26
|
+
}
|
|
27
|
+
export declare enum Accidental {
|
|
28
|
+
Sharp = "sharp",
|
|
29
|
+
Flat = "flat",
|
|
30
|
+
Natural = "natural",
|
|
31
|
+
DoubleSharp = "double-sharp",
|
|
32
|
+
DoubleFlat = "double-flat"
|
|
33
|
+
}
|
|
34
|
+
export declare enum Articulation {
|
|
35
|
+
Staccato = "staccato",
|
|
36
|
+
Accent = "accent",
|
|
37
|
+
Tenuto = "tenuto",
|
|
38
|
+
Marcato = "marcato",
|
|
39
|
+
Fermata = "fermata",
|
|
40
|
+
Staccatissimo = "staccatissimo"
|
|
41
|
+
}
|
|
42
|
+
export declare enum Bowing {
|
|
43
|
+
DownBow = "down-bow",
|
|
44
|
+
UpBow = "up-bow"
|
|
45
|
+
}
|
|
46
|
+
export declare enum NoteheadShape {
|
|
47
|
+
Normal = "normal",
|
|
48
|
+
Cross = "cross",// X shape (percussion, spoken)
|
|
49
|
+
Diamond = "diamond",// Harmonics
|
|
50
|
+
Slash = "slash",// Rhythmic notation
|
|
51
|
+
Triangle = "triangle",// Percussion
|
|
52
|
+
Square = "square"
|
|
53
|
+
}
|
|
54
|
+
export declare enum Dynamic {
|
|
55
|
+
PPP = "ppp",
|
|
56
|
+
PP = "pp",
|
|
57
|
+
P = "p",
|
|
58
|
+
MP = "mp",
|
|
59
|
+
MF = "mf",
|
|
60
|
+
F = "f",
|
|
61
|
+
FF = "ff",
|
|
62
|
+
FFF = "fff"
|
|
63
|
+
}
|
|
64
|
+
export interface TimeSignature {
|
|
65
|
+
beats: number;
|
|
66
|
+
beatType: number;
|
|
67
|
+
}
|
|
68
|
+
export interface KeySignature {
|
|
69
|
+
fifths: number;
|
|
70
|
+
}
|
|
71
|
+
export interface Tempo {
|
|
72
|
+
bpm: number;
|
|
73
|
+
duration: Duration;
|
|
74
|
+
isDotted: boolean;
|
|
75
|
+
text?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface Slur {
|
|
78
|
+
placement: 'start' | 'stop';
|
|
79
|
+
direction?: 'up' | 'down';
|
|
80
|
+
}
|
|
81
|
+
export interface Tuplet {
|
|
82
|
+
actual: number;
|
|
83
|
+
normal: number;
|
|
84
|
+
type: 'start' | 'stop' | 'middle';
|
|
85
|
+
}
|
|
86
|
+
export declare enum HairpinType {
|
|
87
|
+
Crescendo = "crescendo",
|
|
88
|
+
Decrescendo = "decrescendo"
|
|
89
|
+
}
|
|
90
|
+
export interface Hairpin {
|
|
91
|
+
type: HairpinType;
|
|
92
|
+
placement: 'start' | 'stop';
|
|
93
|
+
}
|
|
94
|
+
export interface Repeat {
|
|
95
|
+
type: 'start' | 'end';
|
|
96
|
+
times?: number;
|
|
97
|
+
}
|
|
98
|
+
export interface Volta {
|
|
99
|
+
type: 'start' | 'stop';
|
|
100
|
+
number: number;
|
|
101
|
+
}
|
|
102
|
+
export declare enum GlissandoType {
|
|
103
|
+
Wavy = "wavy",
|
|
104
|
+
Straight = "straight"
|
|
105
|
+
}
|
|
106
|
+
export interface Glissando {
|
|
107
|
+
type: GlissandoType;
|
|
108
|
+
placement: 'start' | 'stop';
|
|
109
|
+
}
|
|
110
|
+
export declare enum Arpeggio {
|
|
111
|
+
Normal = "normal",
|
|
112
|
+
Up = "up",
|
|
113
|
+
Down = "down"
|
|
114
|
+
}
|
|
115
|
+
export declare enum OttavaType {
|
|
116
|
+
OttavaAlta = "8va",
|
|
117
|
+
OttavaBassa = "8vb",
|
|
118
|
+
QuindicesimaAlta = "15ma",
|
|
119
|
+
QuindicesimaBassa = "15mb"
|
|
120
|
+
}
|
|
121
|
+
export interface Ottava {
|
|
122
|
+
type: OttavaType;
|
|
123
|
+
placement: 'start' | 'stop';
|
|
124
|
+
}
|
|
125
|
+
export interface Pedal {
|
|
126
|
+
type: 'sustain' | 'una-corda';
|
|
127
|
+
placement: 'start' | 'stop';
|
|
128
|
+
}
|
|
129
|
+
export declare enum Ornament {
|
|
130
|
+
Trill = "trill",
|
|
131
|
+
Mordent = "mordent",
|
|
132
|
+
InvertedMordent = "inverted-mordent",
|
|
133
|
+
Turn = "turn",
|
|
134
|
+
InvertedTurn = "inverted-turn"
|
|
135
|
+
}
|
|
136
|
+
export declare const DURATION_VALUES: Record<Duration, number>;
|
|
137
|
+
/**
|
|
138
|
+
* Decomposes a duration value (quarter = 1) into a list of duration/dot pairs.
|
|
139
|
+
*/
|
|
140
|
+
export declare function decomposeDuration(value: number): {
|
|
141
|
+
duration: Duration;
|
|
142
|
+
isDotted: boolean;
|
|
143
|
+
val: number;
|
|
144
|
+
}[];
|
|
145
|
+
export interface FretboardDot {
|
|
146
|
+
string: number;
|
|
147
|
+
fret: number;
|
|
148
|
+
label?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface FretboardBarre {
|
|
151
|
+
fret: number;
|
|
152
|
+
startString: number;
|
|
153
|
+
endString: number;
|
|
154
|
+
}
|
|
155
|
+
export interface FretboardDiagram {
|
|
156
|
+
strings: number;
|
|
157
|
+
frets: number;
|
|
158
|
+
startingFret?: number;
|
|
159
|
+
dots: FretboardDot[];
|
|
160
|
+
barres?: FretboardBarre[];
|
|
161
|
+
openStrings?: number[];
|
|
162
|
+
mutedStrings?: number[];
|
|
163
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "New Score",
|
|
3
|
+
"composer": "Anonymous",
|
|
4
|
+
"timeSignature": {
|
|
5
|
+
"beats": 4,
|
|
6
|
+
"beatType": 4
|
|
7
|
+
},
|
|
8
|
+
"keySignature": {
|
|
9
|
+
"fifths": 0
|
|
10
|
+
},
|
|
11
|
+
"bpm": 120,
|
|
12
|
+
"parts": [
|
|
13
|
+
{
|
|
14
|
+
"name": "Violin",
|
|
15
|
+
"staves": [
|
|
16
|
+
{
|
|
17
|
+
"clef": "treble",
|
|
18
|
+
"measures": [
|
|
19
|
+
{
|
|
20
|
+
"voices": [
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
"duration": "quarter",
|
|
24
|
+
"isRest": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"duration": "quarter",
|
|
28
|
+
"isRest": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"duration": "quarter",
|
|
32
|
+
"isRest": true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"duration": "quarter",
|
|
36
|
+
"isRest": true
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"voices": [
|
|
43
|
+
[
|
|
44
|
+
{
|
|
45
|
+
"duration": "quarter",
|
|
46
|
+
"isRest": true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"duration": "quarter",
|
|
50
|
+
"isRest": true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"duration": "quarter",
|
|
54
|
+
"isRest": true
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"duration": "quarter",
|
|
58
|
+
"isRest": true
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"voices": [
|
|
65
|
+
[
|
|
66
|
+
{
|
|
67
|
+
"duration": "quarter",
|
|
68
|
+
"isRest": true
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"duration": "quarter",
|
|
72
|
+
"isRest": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"duration": "quarter",
|
|
76
|
+
"isRest": true
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"duration": "quarter",
|
|
80
|
+
"isRest": true
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"voices": [
|
|
87
|
+
[
|
|
88
|
+
{
|
|
89
|
+
"duration": "quarter",
|
|
90
|
+
"isRest": true
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"duration": "quarter",
|
|
94
|
+
"isRest": true
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"duration": "quarter",
|
|
98
|
+
"isRest": true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"duration": "quarter",
|
|
102
|
+
"isRest": true
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { NoteLayout, MeasureLayout, StaffLayout } from '../layouts';
|
|
2
|
+
/**
|
|
3
|
+
* Renders notes, rests, stems, beams, and related elements.
|
|
4
|
+
*/
|
|
5
|
+
export declare class NoteRenderer {
|
|
6
|
+
private ctx;
|
|
7
|
+
private staffLineSpacing;
|
|
8
|
+
private noteDotDistance;
|
|
9
|
+
private noteNameMode;
|
|
10
|
+
private musicFont;
|
|
11
|
+
constructor(ctx: CanvasRenderingContext2D, staffLineSpacing: number, noteDotDistance?: number, // Default distance
|
|
12
|
+
noteNameMode?: 'none' | 'alphabetical' | 'solfege', musicFont?: 'Standard' | 'Jazz');
|
|
13
|
+
/**
|
|
14
|
+
* Draw a single note with stem
|
|
15
|
+
*/
|
|
16
|
+
drawNote(noteLayout: NoteLayout, skipStem?: boolean): void;
|
|
17
|
+
private drawFingering;
|
|
18
|
+
private drawFretNumber;
|
|
19
|
+
private drawLyric;
|
|
20
|
+
private drawChordSymbol;
|
|
21
|
+
private drawFretboardDiagram;
|
|
22
|
+
/**
|
|
23
|
+
* Draw note name above staff
|
|
24
|
+
*/
|
|
25
|
+
private drawNoteName;
|
|
26
|
+
/**
|
|
27
|
+
* Draw a note stem
|
|
28
|
+
*/
|
|
29
|
+
private drawStem;
|
|
30
|
+
private drawStaffText;
|
|
31
|
+
private drawGraceSlash;
|
|
32
|
+
/**
|
|
33
|
+
* Draw beams connecting notes in a beam group
|
|
34
|
+
*/
|
|
35
|
+
drawBeamGroup(noteLayouts: NoteLayout[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Draw all notes in a measure, handling beam groups
|
|
38
|
+
*/
|
|
39
|
+
drawMeasureNotes(measureLayout: MeasureLayout): void;
|
|
40
|
+
/**
|
|
41
|
+
* Draw connections (Ties and Slurs) for all notes in a staff layout
|
|
42
|
+
*/
|
|
43
|
+
drawStaffConnections(staffLayout: StaffLayout): void;
|
|
44
|
+
private drawHairpin;
|
|
45
|
+
private drawTupletGroup;
|
|
46
|
+
private drawArticulation;
|
|
47
|
+
private drawGlissLine;
|
|
48
|
+
private drawArpeggio;
|
|
49
|
+
private drawOttavaLine;
|
|
50
|
+
private drawPedalLine;
|
|
51
|
+
private drawOrnament;
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Score } from '../models';
|
|
2
|
+
import { ScoreLayout, LayoutConfig } from '../layouts';
|
|
3
|
+
/**
|
|
4
|
+
* Main renderer that orchestrates all drawing operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScoreRenderer {
|
|
7
|
+
private ctx;
|
|
8
|
+
private staffRenderer;
|
|
9
|
+
private noteRenderer;
|
|
10
|
+
private config;
|
|
11
|
+
constructor(ctx: CanvasRenderingContext2D, config?: Partial<LayoutConfig>);
|
|
12
|
+
/**
|
|
13
|
+
* Render a specific page of the score
|
|
14
|
+
*/
|
|
15
|
+
render(score: Score, layout: ScoreLayout, pageIndex?: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Draw part names for a system
|
|
18
|
+
*/
|
|
19
|
+
private drawPartNames;
|
|
20
|
+
/**
|
|
21
|
+
* Render measure numbers for a system
|
|
22
|
+
*/
|
|
23
|
+
private renderMeasureNumbers;
|
|
24
|
+
/**
|
|
25
|
+
* Draw title and composer
|
|
26
|
+
*/
|
|
27
|
+
private drawTitle;
|
|
28
|
+
/**
|
|
29
|
+
* Render notes for a staff (including mid-measure signature changes)
|
|
30
|
+
*/
|
|
31
|
+
private renderStaffNotes;
|
|
32
|
+
private drawSystemBrace;
|
|
33
|
+
private drawSystemText;
|
|
34
|
+
private drawRehearsalMark;
|
|
35
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StaffLayout, TextStyle } from '../layouts';
|
|
2
|
+
import { TimeSignature, KeySignature, Clef, Duration } from '../models/types';
|
|
3
|
+
/**
|
|
4
|
+
* Renders staff lines, clefs, and signatures.
|
|
5
|
+
*/
|
|
6
|
+
export declare class StaffRenderer {
|
|
7
|
+
private ctx;
|
|
8
|
+
private staffLineSpacing;
|
|
9
|
+
private clefWidth;
|
|
10
|
+
private trebleClefYOffset;
|
|
11
|
+
private bassClefYOffset;
|
|
12
|
+
private musicFont;
|
|
13
|
+
private tempoStyle;
|
|
14
|
+
private clefKeySignatureSpacing;
|
|
15
|
+
private bassClefScale;
|
|
16
|
+
private trebleClefScale;
|
|
17
|
+
private clefLeftPadding;
|
|
18
|
+
constructor(ctx: CanvasRenderingContext2D, staffLineSpacing: number, clefWidth: number, trebleClefYOffset?: number, bassClefYOffset?: number, musicFont?: 'Standard' | 'Jazz', tempoStyle?: TextStyle, clefKeySignatureSpacing?: number, bassClefScale?: number, trebleClefScale?: number, clefLeftPadding?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Draw the staff lines (5 horizontal lines)
|
|
21
|
+
*/
|
|
22
|
+
drawStaffLines(layout: StaffLayout): void;
|
|
23
|
+
/**
|
|
24
|
+
* Draw the clef
|
|
25
|
+
*/
|
|
26
|
+
drawClef(layout: StaffLayout): void;
|
|
27
|
+
private drawTabClef;
|
|
28
|
+
/**
|
|
29
|
+
* Draw time signature
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Draw time signature
|
|
33
|
+
*/
|
|
34
|
+
drawTimeSignature(layout: StaffLayout, timeSignature: TimeSignature, keySignature?: KeySignature): void;
|
|
35
|
+
/**
|
|
36
|
+
* Draw key signature
|
|
37
|
+
*/
|
|
38
|
+
drawKeySignature(layout: StaffLayout, keySignature: KeySignature): number;
|
|
39
|
+
private getClefWidth;
|
|
40
|
+
private getKeySignatureWidth;
|
|
41
|
+
/**
|
|
42
|
+
* Draw key signature at a specific X position
|
|
43
|
+
*/
|
|
44
|
+
drawKeySignatureAt(x: number, y: number, fifths: number, clef: Clef): void;
|
|
45
|
+
/**
|
|
46
|
+
* Draw time signature at a specific X position
|
|
47
|
+
*/
|
|
48
|
+
drawTimeSignatureAt(x: number, y: number, beats: number, beatType: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* Draw barlines
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Draw barlines for the entire staff system, spanning across all staves.
|
|
54
|
+
* Draw barlines for multiple staves in a system
|
|
55
|
+
*/
|
|
56
|
+
drawSystemBarlines(staffLayouts: StaffLayout[], totalMeasures?: number): void;
|
|
57
|
+
private drawRepeatBarline;
|
|
58
|
+
private drawVolta;
|
|
59
|
+
/**
|
|
60
|
+
* Draw ledger lines for notes outside the staff
|
|
61
|
+
*/
|
|
62
|
+
drawLedgerLines(x: number, staffPosition: number, middleY: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Draw tempo marking
|
|
65
|
+
*/
|
|
66
|
+
drawTempoMarking(layout: StaffLayout, bpm: number, duration: Duration, isDotted?: boolean, overrideX?: number): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clef rendering functions.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Draw a treble clef (G-clef)
|
|
6
|
+
*/
|
|
7
|
+
export declare function drawTrebleClef(ctx: CanvasRenderingContext2D, x: number, y: number, staffLineSpacing: number, yOffsetFactor?: number, scaleFactor?: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* Draw a bass clef (F-clef)
|
|
10
|
+
*/
|
|
11
|
+
export declare function drawBassClef(ctx: CanvasRenderingContext2D, x: number, y: number, staffLineSpacing: number, yOffset?: number, scaleFactor?: number): void;
|
|
12
|
+
/**
|
|
13
|
+
* Draw a C-clef (Alto/Tenor)
|
|
14
|
+
*/
|
|
15
|
+
export declare function drawCClef(ctx: CanvasRenderingContext2D, x: number, y: number, staffLineSpacing: number, staffPosition: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Draw a percussion clef (neutral clef)
|
|
18
|
+
*/
|
|
19
|
+
export declare function drawPercussionClef(ctx: CanvasRenderingContext2D, x: number, y: number, staffLineSpacing: number): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draw dynamic marking
|
|
3
|
+
*/
|
|
4
|
+
export declare function drawDynamic(ctx: CanvasRenderingContext2D, x: number, y: number, // Reference Y marking position (usually separate from note Y)
|
|
5
|
+
dynamic: string, // Cast from enum or pass string
|
|
6
|
+
staffLineSpacing: number, color?: string, musicFont?: 'Standard' | 'Jazz'): void;
|
|
7
|
+
/**
|
|
8
|
+
* Draw a tie or slur curve (Bezier)
|
|
9
|
+
*/
|
|
10
|
+
export declare function drawCurve(ctx: CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, direction: 'up' | 'down', staffLineSpacing: number, curvature?: number, // Height of the curve in staff spaces (default 0.8)
|
|
11
|
+
color?: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Duration, NoteheadShape, Bowing } from '../../models/types';
|
|
2
|
+
/**
|
|
3
|
+
* Draw a notehead
|
|
4
|
+
*/
|
|
5
|
+
export declare function drawNotehead(ctx: CanvasRenderingContext2D, x: number, y: number, duration: Duration, staffLineSpacing: number, color?: string, shape?: NoteheadShape): void;
|
|
6
|
+
/**
|
|
7
|
+
* Draw a flag for eighth/sixteenth notes
|
|
8
|
+
*/
|
|
9
|
+
export declare function drawFlag(ctx: CanvasRenderingContext2D, x: number, y: number, // Stem end position
|
|
10
|
+
direction: 'up' | 'down', duration: Duration, staffLineSpacing: number, color?: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Draw a dot for dotted notes
|
|
13
|
+
*/
|
|
14
|
+
export declare function drawDot(ctx: CanvasRenderingContext2D, x: number, y: number, staffLineSpacing: number, distanceFactor?: number, // Default distance factor
|
|
15
|
+
color?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Draw bowing mark
|
|
18
|
+
*/
|
|
19
|
+
export declare function drawBowing(ctx: CanvasRenderingContext2D, x: number, y: number, bowing: Bowing, staffLineSpacing: number, color?: string): void;
|