@scorelabs/core 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/dist/importers/MusicXMLParser.d.ts +36 -0
- package/dist/importers/MusicXMLParser.js +610 -0
- package/dist/importers/index.d.ts +1 -0
- package/dist/importers/index.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/models/Instrument.d.ts +26 -0
- package/dist/models/Instrument.js +56 -0
- package/dist/models/Measure.d.ts +65 -0
- package/dist/models/Measure.js +291 -0
- package/dist/models/Note.d.ts +116 -0
- package/dist/models/Note.js +259 -0
- package/dist/models/NoteSet.d.ts +73 -0
- package/dist/models/NoteSet.js +184 -0
- package/dist/models/Part.d.ts +36 -0
- package/dist/models/Part.js +89 -0
- package/dist/models/Pitch.d.ts +20 -0
- package/dist/models/Pitch.js +110 -0
- package/dist/models/Score.d.ts +71 -0
- package/dist/models/Score.js +284 -0
- package/dist/models/Staff.d.ts +36 -0
- package/dist/models/Staff.js +89 -0
- package/dist/models/index.d.ts +9 -0
- package/dist/models/index.js +9 -0
- package/dist/models/types.d.ts +202 -0
- package/dist/models/types.js +205 -0
- package/package.json +34 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Duration, Accidental, DURATION_VALUES, } from './types';
|
|
2
|
+
import { Pitch } from './Pitch';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single note or rest in a measure.
|
|
5
|
+
*/
|
|
6
|
+
export class Note {
|
|
7
|
+
duration;
|
|
8
|
+
pitch;
|
|
9
|
+
isRest;
|
|
10
|
+
isDotted;
|
|
11
|
+
accidental;
|
|
12
|
+
beamGroup;
|
|
13
|
+
articulation;
|
|
14
|
+
dynamic;
|
|
15
|
+
tie;
|
|
16
|
+
slur;
|
|
17
|
+
tuplet;
|
|
18
|
+
hairpin;
|
|
19
|
+
isGrace;
|
|
20
|
+
lyric;
|
|
21
|
+
chord;
|
|
22
|
+
glissando;
|
|
23
|
+
arpeggio;
|
|
24
|
+
ottava;
|
|
25
|
+
pedal;
|
|
26
|
+
ornament;
|
|
27
|
+
fret;
|
|
28
|
+
string;
|
|
29
|
+
fretboardDiagram;
|
|
30
|
+
lyrics;
|
|
31
|
+
staffText;
|
|
32
|
+
color;
|
|
33
|
+
notehead;
|
|
34
|
+
bowing;
|
|
35
|
+
fingering;
|
|
36
|
+
constructor(duration, pitch, // undefined for rests
|
|
37
|
+
isRest = false, isDotted = false, accidental, beamGroup, // Group ID for beamed notes
|
|
38
|
+
articulation, dynamic, tie, slur, tuplet, hairpin, isGrace = false, lyric, chord, glissando, arpeggio, ottava, pedal, ornament, fret, string, fretboardDiagram, lyrics, staffText, color, notehead, bowing, fingering) {
|
|
39
|
+
this.duration = duration;
|
|
40
|
+
this.pitch = pitch;
|
|
41
|
+
this.isRest = isRest;
|
|
42
|
+
this.isDotted = isDotted;
|
|
43
|
+
this.accidental = accidental;
|
|
44
|
+
this.beamGroup = beamGroup;
|
|
45
|
+
this.articulation = articulation;
|
|
46
|
+
this.dynamic = dynamic;
|
|
47
|
+
this.tie = tie;
|
|
48
|
+
this.slur = slur;
|
|
49
|
+
this.tuplet = tuplet;
|
|
50
|
+
this.hairpin = hairpin;
|
|
51
|
+
this.isGrace = isGrace;
|
|
52
|
+
this.lyric = lyric;
|
|
53
|
+
this.chord = chord;
|
|
54
|
+
this.glissando = glissando;
|
|
55
|
+
this.arpeggio = arpeggio;
|
|
56
|
+
this.ottava = ottava;
|
|
57
|
+
this.pedal = pedal;
|
|
58
|
+
this.ornament = ornament;
|
|
59
|
+
this.fret = fret;
|
|
60
|
+
this.string = string;
|
|
61
|
+
this.fretboardDiagram = fretboardDiagram;
|
|
62
|
+
this.lyrics = lyrics;
|
|
63
|
+
this.staffText = staffText;
|
|
64
|
+
this.color = color;
|
|
65
|
+
this.notehead = notehead;
|
|
66
|
+
this.bowing = bowing;
|
|
67
|
+
this.fingering = fingering;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the duration value (quarter note = 1)
|
|
71
|
+
*/
|
|
72
|
+
getDurationValue() {
|
|
73
|
+
if (this.isGrace)
|
|
74
|
+
return 0;
|
|
75
|
+
const base = DURATION_VALUES[this.duration];
|
|
76
|
+
let val = this.isDotted ? base * 1.5 : base;
|
|
77
|
+
if (this.tuplet) {
|
|
78
|
+
val = val * (this.tuplet.normal / this.tuplet.actual);
|
|
79
|
+
}
|
|
80
|
+
return val;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if this note should be beamed (eighth or shorter)
|
|
84
|
+
*/
|
|
85
|
+
isBeamable() {
|
|
86
|
+
return (!this.isRest &&
|
|
87
|
+
(this.duration === Duration.Eighth ||
|
|
88
|
+
this.duration === Duration.Sixteenth ||
|
|
89
|
+
this.duration === Duration.ThirtySecond ||
|
|
90
|
+
this.duration === Duration.SixtyFourth ||
|
|
91
|
+
this.duration === Duration.OneHundredTwentyEighth ||
|
|
92
|
+
this.duration === Duration.TwoHundredFiftySixth));
|
|
93
|
+
}
|
|
94
|
+
withGrace(isGrace) {
|
|
95
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
96
|
+
}
|
|
97
|
+
withChord(chord) {
|
|
98
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
99
|
+
}
|
|
100
|
+
transpose(semitones) {
|
|
101
|
+
if (this.isRest || !this.pitch) {
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
const newPitch = new Pitch(this.pitch.midiNumber + semitones);
|
|
105
|
+
const chromaticIdx = newPitch.midiNumber % 12;
|
|
106
|
+
const hasSharp = [1, 3, 6, 8, 10].includes(chromaticIdx);
|
|
107
|
+
const newAccidental = hasSharp ? Accidental.Sharp : undefined;
|
|
108
|
+
return new Note(this.duration, newPitch, this.isRest, this.isDotted, newAccidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
109
|
+
}
|
|
110
|
+
transposeOctave(octaves) {
|
|
111
|
+
if (!this.pitch || this.isRest)
|
|
112
|
+
return this;
|
|
113
|
+
const newPitch = new Pitch(this.pitch.midiNumber + octaves * 12, this.pitch.step, this.pitch.alter, this.pitch.octave + octaves);
|
|
114
|
+
return this.withPitch(newPitch);
|
|
115
|
+
}
|
|
116
|
+
transposeDiatonic(steps) {
|
|
117
|
+
if (this.isRest || !this.pitch) {
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
const newPitch = this.pitch.transposeDiatonic(steps);
|
|
121
|
+
return this.withPitch(newPitch).withAccidental(undefined);
|
|
122
|
+
}
|
|
123
|
+
toggleEnharmonic() {
|
|
124
|
+
if (!this.pitch || this.isRest)
|
|
125
|
+
return this;
|
|
126
|
+
const newPitch = this.pitch.withEnharmonicNext();
|
|
127
|
+
let newAccidental = undefined;
|
|
128
|
+
if (newPitch.alter === 1)
|
|
129
|
+
newAccidental = Accidental.Sharp;
|
|
130
|
+
else if (newPitch.alter === -1)
|
|
131
|
+
newAccidental = Accidental.Flat;
|
|
132
|
+
else if (newPitch.alter === 2)
|
|
133
|
+
newAccidental = Accidental.DoubleSharp;
|
|
134
|
+
else if (newPitch.alter === -2)
|
|
135
|
+
newAccidental = Accidental.DoubleFlat;
|
|
136
|
+
else if (newPitch.alter === 0)
|
|
137
|
+
newAccidental = undefined;
|
|
138
|
+
return this.withPitch(newPitch).withAccidental(newAccidental);
|
|
139
|
+
}
|
|
140
|
+
withPitch(pitch) {
|
|
141
|
+
return new Note(this.duration, pitch, false, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
142
|
+
}
|
|
143
|
+
withArticulation(articulation) {
|
|
144
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
145
|
+
}
|
|
146
|
+
withDynamic(dynamic) {
|
|
147
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
148
|
+
}
|
|
149
|
+
withTie(tie) {
|
|
150
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
151
|
+
}
|
|
152
|
+
withSlur(slur) {
|
|
153
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
154
|
+
}
|
|
155
|
+
withTuplet(tuplet) {
|
|
156
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
157
|
+
}
|
|
158
|
+
withLyric(lyric) {
|
|
159
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
160
|
+
}
|
|
161
|
+
withLyrics(lyrics) {
|
|
162
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
163
|
+
}
|
|
164
|
+
withHairpin(hairpin) {
|
|
165
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
166
|
+
}
|
|
167
|
+
withAccidental(accidental) {
|
|
168
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
169
|
+
}
|
|
170
|
+
withDuration(duration, isDotted = false) {
|
|
171
|
+
return new Note(duration, this.pitch, this.isRest, isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
172
|
+
}
|
|
173
|
+
withRest(isRest) {
|
|
174
|
+
return new Note(this.duration, this.pitch, isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
175
|
+
}
|
|
176
|
+
withFretboardDiagram(diagram) {
|
|
177
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, diagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
178
|
+
}
|
|
179
|
+
withBeamGroup(beamGroup) {
|
|
180
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
181
|
+
}
|
|
182
|
+
withGlissando(glissando) {
|
|
183
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
184
|
+
}
|
|
185
|
+
withArpeggio(arpeggio) {
|
|
186
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
187
|
+
}
|
|
188
|
+
withOttava(ottava) {
|
|
189
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
190
|
+
}
|
|
191
|
+
withPedal(pedal) {
|
|
192
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
193
|
+
}
|
|
194
|
+
withOrnament(ornament) {
|
|
195
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
196
|
+
}
|
|
197
|
+
withTab(fret, string) {
|
|
198
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, fret, string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, this.fingering);
|
|
199
|
+
}
|
|
200
|
+
withStaffText(text) {
|
|
201
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, text, this.color, this.notehead, this.bowing, this.fingering);
|
|
202
|
+
}
|
|
203
|
+
withColor(color) {
|
|
204
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, color, this.notehead, this.bowing, this.fingering);
|
|
205
|
+
}
|
|
206
|
+
withNotehead(notehead) {
|
|
207
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, notehead, this.bowing, this.fingering);
|
|
208
|
+
}
|
|
209
|
+
withBowing(bowing) {
|
|
210
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, bowing, this.fingering);
|
|
211
|
+
}
|
|
212
|
+
withFingering(fingering) {
|
|
213
|
+
return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulation, this.dynamic, this.tie, this.slur, this.tuplet, this.hairpin, this.isGrace, this.lyric, this.chord, this.glissando, this.arpeggio, this.ottava, this.pedal, this.ornament, this.fret, this.string, this.fretboardDiagram, this.lyrics, this.staffText, this.color, this.notehead, this.bowing, fingering);
|
|
214
|
+
}
|
|
215
|
+
toJSON() {
|
|
216
|
+
return {
|
|
217
|
+
duration: this.duration,
|
|
218
|
+
pitch: this.isRest ? undefined : this.pitch ? {
|
|
219
|
+
midiNumber: this.pitch.midiNumber,
|
|
220
|
+
step: this.pitch.step,
|
|
221
|
+
alter: this.pitch.alter,
|
|
222
|
+
octave: this.pitch.octave,
|
|
223
|
+
} : undefined,
|
|
224
|
+
isRest: this.isRest || undefined,
|
|
225
|
+
isDotted: this.isDotted || undefined,
|
|
226
|
+
accidental: this.accidental,
|
|
227
|
+
beamGroup: this.beamGroup,
|
|
228
|
+
articulation: this.articulation,
|
|
229
|
+
dynamic: this.dynamic,
|
|
230
|
+
tie: this.tie,
|
|
231
|
+
slur: this.slur,
|
|
232
|
+
tuplet: this.tuplet,
|
|
233
|
+
hairpin: this.hairpin,
|
|
234
|
+
isGrace: this.isGrace || undefined,
|
|
235
|
+
lyric: this.lyric,
|
|
236
|
+
chord: this.chord,
|
|
237
|
+
glissando: this.glissando,
|
|
238
|
+
arpeggio: this.arpeggio,
|
|
239
|
+
ottava: this.ottava,
|
|
240
|
+
pedal: this.pedal,
|
|
241
|
+
ornament: this.ornament,
|
|
242
|
+
fret: this.fret,
|
|
243
|
+
string: this.string,
|
|
244
|
+
fretboardDiagram: this.fretboardDiagram,
|
|
245
|
+
lyrics: this.lyrics,
|
|
246
|
+
staffText: this.staffText,
|
|
247
|
+
color: this.color,
|
|
248
|
+
notehead: this.notehead,
|
|
249
|
+
bowing: this.bowing,
|
|
250
|
+
fingering: this.fingering,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
static fromJSON(data) {
|
|
254
|
+
const pitch = data.pitch
|
|
255
|
+
? new Pitch(data.pitch.midiNumber, data.pitch.step, data.pitch.alter, data.pitch.octave)
|
|
256
|
+
: undefined;
|
|
257
|
+
return new Note(data.duration, pitch, data.isRest ?? false, data.isDotted ?? false, data.accidental, data.beamGroup, data.articulation, data.dynamic, data.tie, data.slur, data.tuplet, data.hairpin, data.isGrace ?? false, data.lyric, data.chord, data.glissando, data.arpeggio, data.ottava, data.pedal, data.ornament, data.fret, data.string, data.fretboardDiagram, data.lyrics, data.staffText, data.color, data.notehead, data.bowing, data.fingering);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Note, NoteJSON } from './Note';
|
|
2
|
+
import { Duration } from './types';
|
|
3
|
+
export declare class NoteSet {
|
|
4
|
+
readonly notes: Note[];
|
|
5
|
+
constructor(notes: Note[]);
|
|
6
|
+
get duration(): Duration;
|
|
7
|
+
get isDotted(): boolean;
|
|
8
|
+
get isRest(): boolean;
|
|
9
|
+
get beamGroup(): number | undefined;
|
|
10
|
+
get tuplet(): import("./types").Tuplet | undefined;
|
|
11
|
+
getDurationValue(): number;
|
|
12
|
+
isBeamable(): boolean;
|
|
13
|
+
withDuration(duration: Duration, isDotted?: boolean): NoteSet;
|
|
14
|
+
withBeamGroup(group?: number): NoteSet;
|
|
15
|
+
withNotes(notes: Note[]): NoteSet;
|
|
16
|
+
withLyrics(lyrics: string[]): NoteSet;
|
|
17
|
+
withTuplet(tuplet?: any): NoteSet;
|
|
18
|
+
withPitch(pitch: any): NoteSet;
|
|
19
|
+
withAccidental(accidental: any): NoteSet;
|
|
20
|
+
withRest(isRest: boolean): NoteSet;
|
|
21
|
+
withGrace(isGrace: boolean): NoteSet;
|
|
22
|
+
toggleEnharmonic(): NoteSet;
|
|
23
|
+
transpose(semitones: number): NoteSet;
|
|
24
|
+
transposeOctave(octaves: number): NoteSet;
|
|
25
|
+
transposeDiatonic(steps: number): NoteSet;
|
|
26
|
+
withChord(chord?: string): NoteSet;
|
|
27
|
+
withTab(fret: number, string: number): NoteSet;
|
|
28
|
+
withTie(tie: boolean): NoteSet;
|
|
29
|
+
withSlur(slur?: any): NoteSet;
|
|
30
|
+
withArticulation(articulation?: any): NoteSet;
|
|
31
|
+
withOrnament(ornament?: any): NoteSet;
|
|
32
|
+
withDynamic(dynamic?: any): NoteSet;
|
|
33
|
+
withHairpin(hairpin?: any): NoteSet;
|
|
34
|
+
withGlissando(glissando?: any): NoteSet;
|
|
35
|
+
withArpeggio(arpeggio?: any): NoteSet;
|
|
36
|
+
withOttava(ottava?: any): NoteSet;
|
|
37
|
+
withPedal(pedal?: any): NoteSet;
|
|
38
|
+
withColor(color?: string): NoteSet;
|
|
39
|
+
withNotehead(notehead: any): NoteSet;
|
|
40
|
+
withBowing(bowing?: any): NoteSet;
|
|
41
|
+
withFingering(fingering?: number): NoteSet;
|
|
42
|
+
withLyric(lyric?: any): NoteSet;
|
|
43
|
+
withStaffText(text?: string): NoteSet;
|
|
44
|
+
withFretboardDiagram(diagram?: any): NoteSet;
|
|
45
|
+
get pitch(): import("./Pitch").Pitch | undefined;
|
|
46
|
+
get accidental(): import("./types").Accidental | undefined;
|
|
47
|
+
get tie(): boolean | undefined;
|
|
48
|
+
get slur(): import("./types").Slur | undefined;
|
|
49
|
+
get articulation(): import("./types").Articulation | undefined;
|
|
50
|
+
get ornament(): import("./types").Ornament | undefined;
|
|
51
|
+
get dynamic(): import("./types").Dynamic | undefined;
|
|
52
|
+
get hairpin(): import("./types").Hairpin | undefined;
|
|
53
|
+
get glissando(): import("./types").Glissando | undefined;
|
|
54
|
+
get arpeggio(): import("./types").Arpeggio | undefined;
|
|
55
|
+
get ottava(): import("./types").Ottava | undefined;
|
|
56
|
+
get pedal(): import("./types").Pedal | undefined;
|
|
57
|
+
get notehead(): import("./types").NoteheadShape | undefined;
|
|
58
|
+
get color(): string | undefined;
|
|
59
|
+
get fret(): number | undefined;
|
|
60
|
+
get string(): number | undefined;
|
|
61
|
+
get bowing(): import("./types").Bowing | undefined;
|
|
62
|
+
get fingering(): number | undefined;
|
|
63
|
+
get lyrics(): string[] | undefined;
|
|
64
|
+
get lyric(): string | undefined;
|
|
65
|
+
get chord(): string | undefined;
|
|
66
|
+
get fretboardDiagram(): import("./types").FretboardDiagram | undefined;
|
|
67
|
+
get staffText(): string | undefined;
|
|
68
|
+
toJSON(): NoteSetJSON;
|
|
69
|
+
static fromJSON(data: NoteSetJSON): NoteSet;
|
|
70
|
+
}
|
|
71
|
+
export interface NoteSetJSON {
|
|
72
|
+
notes: NoteJSON[];
|
|
73
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Note } from './Note';
|
|
2
|
+
export class NoteSet {
|
|
3
|
+
notes;
|
|
4
|
+
constructor(notes) {
|
|
5
|
+
this.notes = notes;
|
|
6
|
+
if (notes.length === 0) {
|
|
7
|
+
throw new Error('NoteSet must have at least one note');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
get duration() {
|
|
11
|
+
return this.notes[0].duration;
|
|
12
|
+
}
|
|
13
|
+
get isDotted() {
|
|
14
|
+
return this.notes[0].isDotted;
|
|
15
|
+
}
|
|
16
|
+
get isRest() {
|
|
17
|
+
return this.notes[0].isRest;
|
|
18
|
+
}
|
|
19
|
+
get beamGroup() {
|
|
20
|
+
return this.notes[0].beamGroup;
|
|
21
|
+
}
|
|
22
|
+
get tuplet() {
|
|
23
|
+
return this.notes[0].tuplet;
|
|
24
|
+
}
|
|
25
|
+
getDurationValue() {
|
|
26
|
+
return this.notes[0].getDurationValue();
|
|
27
|
+
}
|
|
28
|
+
isBeamable() {
|
|
29
|
+
return this.notes[0].isBeamable();
|
|
30
|
+
}
|
|
31
|
+
withDuration(duration, isDotted = false) {
|
|
32
|
+
return new NoteSet(this.notes.map((n) => n.withDuration(duration, isDotted)));
|
|
33
|
+
}
|
|
34
|
+
withBeamGroup(group) {
|
|
35
|
+
return new NoteSet(this.notes.map((n) => n.withBeamGroup(group)));
|
|
36
|
+
}
|
|
37
|
+
withNotes(notes) {
|
|
38
|
+
return new NoteSet(notes);
|
|
39
|
+
}
|
|
40
|
+
withLyrics(lyrics) {
|
|
41
|
+
const newNotes = [...this.notes];
|
|
42
|
+
if (newNotes.length > 0) {
|
|
43
|
+
newNotes[0] = newNotes[0].withLyrics(lyrics);
|
|
44
|
+
}
|
|
45
|
+
return new NoteSet(newNotes);
|
|
46
|
+
}
|
|
47
|
+
withTuplet(tuplet) {
|
|
48
|
+
const newNotes = [...this.notes];
|
|
49
|
+
newNotes.forEach((n, i) => {
|
|
50
|
+
newNotes[i] = n.withTuplet(tuplet);
|
|
51
|
+
});
|
|
52
|
+
return new NoteSet(newNotes);
|
|
53
|
+
}
|
|
54
|
+
withPitch(pitch) {
|
|
55
|
+
const newNotes = [...this.notes];
|
|
56
|
+
if (newNotes.length > 0) {
|
|
57
|
+
newNotes[0] = newNotes[0].withPitch(pitch);
|
|
58
|
+
}
|
|
59
|
+
return new NoteSet(newNotes);
|
|
60
|
+
}
|
|
61
|
+
withAccidental(accidental) {
|
|
62
|
+
const newNotes = [...this.notes];
|
|
63
|
+
if (newNotes.length > 0) {
|
|
64
|
+
newNotes[0] = newNotes[0].withAccidental(accidental);
|
|
65
|
+
}
|
|
66
|
+
return new NoteSet(newNotes);
|
|
67
|
+
}
|
|
68
|
+
withRest(isRest) {
|
|
69
|
+
if (isRest) {
|
|
70
|
+
const first = this.notes[0];
|
|
71
|
+
return new NoteSet([first.withRest(true)]);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return new NoteSet(this.notes.map(n => n.withRest(false)));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
withGrace(isGrace) {
|
|
78
|
+
return new NoteSet(this.notes.map(n => n.withGrace(isGrace)));
|
|
79
|
+
}
|
|
80
|
+
toggleEnharmonic() {
|
|
81
|
+
const newNotes = [...this.notes];
|
|
82
|
+
if (newNotes.length > 0) {
|
|
83
|
+
newNotes[0] = newNotes[0].toggleEnharmonic();
|
|
84
|
+
}
|
|
85
|
+
return new NoteSet(newNotes);
|
|
86
|
+
}
|
|
87
|
+
transpose(semitones) {
|
|
88
|
+
return new NoteSet(this.notes.map((n) => n.transpose(semitones)));
|
|
89
|
+
}
|
|
90
|
+
transposeOctave(octaves) {
|
|
91
|
+
return new NoteSet(this.notes.map((n) => n.transposeOctave(octaves)));
|
|
92
|
+
}
|
|
93
|
+
transposeDiatonic(steps) {
|
|
94
|
+
return new NoteSet(this.notes.map((n) => n.transposeDiatonic(steps)));
|
|
95
|
+
}
|
|
96
|
+
withChord(chord) {
|
|
97
|
+
return new NoteSet(this.notes.map((n) => n.withChord(chord)));
|
|
98
|
+
}
|
|
99
|
+
withTab(fret, string) {
|
|
100
|
+
return new NoteSet(this.notes.map((n) => n.withTab(fret, string)));
|
|
101
|
+
}
|
|
102
|
+
withTie(tie) {
|
|
103
|
+
return new NoteSet(this.notes.map((n) => n.withTie(tie)));
|
|
104
|
+
}
|
|
105
|
+
withSlur(slur) {
|
|
106
|
+
return new NoteSet(this.notes.map((n) => n.withSlur(slur)));
|
|
107
|
+
}
|
|
108
|
+
withArticulation(articulation) {
|
|
109
|
+
return new NoteSet(this.notes.map((n) => n.withArticulation(articulation)));
|
|
110
|
+
}
|
|
111
|
+
withOrnament(ornament) {
|
|
112
|
+
return new NoteSet(this.notes.map((n) => n.withOrnament(ornament)));
|
|
113
|
+
}
|
|
114
|
+
withDynamic(dynamic) {
|
|
115
|
+
return new NoteSet(this.notes.map((n) => n.withDynamic(dynamic)));
|
|
116
|
+
}
|
|
117
|
+
withHairpin(hairpin) {
|
|
118
|
+
return new NoteSet(this.notes.map((n) => n.withHairpin(hairpin)));
|
|
119
|
+
}
|
|
120
|
+
withGlissando(glissando) {
|
|
121
|
+
return new NoteSet(this.notes.map((n) => n.withGlissando(glissando)));
|
|
122
|
+
}
|
|
123
|
+
withArpeggio(arpeggio) {
|
|
124
|
+
return new NoteSet(this.notes.map((n) => n.withArpeggio(arpeggio)));
|
|
125
|
+
}
|
|
126
|
+
withOttava(ottava) {
|
|
127
|
+
return new NoteSet(this.notes.map((n) => n.withOttava(ottava)));
|
|
128
|
+
}
|
|
129
|
+
withPedal(pedal) {
|
|
130
|
+
return new NoteSet(this.notes.map((n) => n.withPedal(pedal)));
|
|
131
|
+
}
|
|
132
|
+
withColor(color) {
|
|
133
|
+
return new NoteSet(this.notes.map((n) => n.withColor(color)));
|
|
134
|
+
}
|
|
135
|
+
withNotehead(notehead) {
|
|
136
|
+
return new NoteSet(this.notes.map((n) => n.withNotehead(notehead)));
|
|
137
|
+
}
|
|
138
|
+
withBowing(bowing) {
|
|
139
|
+
return new NoteSet(this.notes.map((n) => n.withBowing(bowing)));
|
|
140
|
+
}
|
|
141
|
+
withFingering(fingering) {
|
|
142
|
+
return new NoteSet(this.notes.map((n) => n.withFingering(fingering)));
|
|
143
|
+
}
|
|
144
|
+
withLyric(lyric) {
|
|
145
|
+
return new NoteSet(this.notes.map((n) => n.withLyric(lyric)));
|
|
146
|
+
}
|
|
147
|
+
withStaffText(text) {
|
|
148
|
+
return new NoteSet(this.notes.map((n) => n.withStaffText(text)));
|
|
149
|
+
}
|
|
150
|
+
withFretboardDiagram(diagram) {
|
|
151
|
+
return new NoteSet(this.notes.map((n) => n.withFretboardDiagram(diagram)));
|
|
152
|
+
}
|
|
153
|
+
get pitch() { return this.notes[0].pitch; }
|
|
154
|
+
get accidental() { return this.notes[0].accidental; }
|
|
155
|
+
get tie() { return this.notes[0].tie; }
|
|
156
|
+
get slur() { return this.notes[0].slur; }
|
|
157
|
+
get articulation() { return this.notes[0].articulation; }
|
|
158
|
+
get ornament() { return this.notes[0].ornament; }
|
|
159
|
+
get dynamic() { return this.notes[0].dynamic; }
|
|
160
|
+
get hairpin() { return this.notes[0].hairpin; }
|
|
161
|
+
get glissando() { return this.notes[0].glissando; }
|
|
162
|
+
get arpeggio() { return this.notes[0].arpeggio; }
|
|
163
|
+
get ottava() { return this.notes[0].ottava; }
|
|
164
|
+
get pedal() { return this.notes[0].pedal; }
|
|
165
|
+
get notehead() { return this.notes[0].notehead; }
|
|
166
|
+
get color() { return this.notes[0].color; }
|
|
167
|
+
get fret() { return this.notes[0].fret; }
|
|
168
|
+
get string() { return this.notes[0].string; }
|
|
169
|
+
get bowing() { return this.notes[0].bowing; }
|
|
170
|
+
get fingering() { return this.notes[0].fingering; }
|
|
171
|
+
get lyrics() { return this.notes[0].lyrics; }
|
|
172
|
+
get lyric() { return this.notes[0].lyric; }
|
|
173
|
+
get chord() { return this.notes[0].chord; }
|
|
174
|
+
get fretboardDiagram() { return this.notes[0].fretboardDiagram; }
|
|
175
|
+
get staffText() { return this.notes[0].staffText; }
|
|
176
|
+
toJSON() {
|
|
177
|
+
return {
|
|
178
|
+
notes: this.notes.map((n) => n.toJSON()),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
static fromJSON(data) {
|
|
182
|
+
return new NoteSet(data.notes.map((n) => Note.fromJSON(n)));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Staff, StaffJSON } from './Staff';
|
|
2
|
+
import { Instrument } from './Instrument';
|
|
3
|
+
import { Note } from './Note';
|
|
4
|
+
import { Measure } from './Measure';
|
|
5
|
+
import { Duration } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a musical part (instrument/voice) which can have multiple staves.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Part {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly staves: Staff[];
|
|
12
|
+
readonly abbreviation: string;
|
|
13
|
+
readonly instrument: Instrument;
|
|
14
|
+
constructor(name: string, staves: Staff[], abbreviation?: string, instrument?: Instrument);
|
|
15
|
+
isMultiStaff(): boolean;
|
|
16
|
+
getMeasureCount(): number;
|
|
17
|
+
static fromJSON(data: PartJSON): Part;
|
|
18
|
+
transpose(semitones: number): Part;
|
|
19
|
+
replaceNote(staffIndex: number, measureIndex: number, noteIndex: number, newNote: Note, voiceIndex?: number): Part;
|
|
20
|
+
replaceMeasure(staffIndex: number, measureIndex: number, newMeasure: Measure): Part;
|
|
21
|
+
deleteNote(staffIndex: number, measureIndex: number, noteIndex: number, voiceIndex?: number): Part;
|
|
22
|
+
changeNoteDuration(staffIndex: number, measureIndex: number, noteIndex: number, newDuration: Duration, isDotted?: boolean, voiceIndex?: number): Part;
|
|
23
|
+
toJSON(): PartJSON;
|
|
24
|
+
withInstrument(instrument: Instrument): Part;
|
|
25
|
+
replaceStaff(staffIndex: number, newStaff: Staff): Part;
|
|
26
|
+
withStaves(staves: Staff[]): Part;
|
|
27
|
+
withName(name: string): Part;
|
|
28
|
+
addMeasure(index: number, measure: Measure): Part;
|
|
29
|
+
deleteMeasure(index: number): Part;
|
|
30
|
+
}
|
|
31
|
+
export interface PartJSON {
|
|
32
|
+
name: string;
|
|
33
|
+
staves: StaffJSON[];
|
|
34
|
+
abbreviation?: string;
|
|
35
|
+
instrument?: Instrument;
|
|
36
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Staff } from './Staff';
|
|
2
|
+
import { PRESET_INSTRUMENTS } from './Instrument';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a musical part (instrument/voice) which can have multiple staves.
|
|
5
|
+
*/
|
|
6
|
+
export class Part {
|
|
7
|
+
name;
|
|
8
|
+
staves;
|
|
9
|
+
abbreviation;
|
|
10
|
+
instrument;
|
|
11
|
+
constructor(name, staves, abbreviation = name.substring(0, Math.min(name.length, 3)) + '.', instrument = PRESET_INSTRUMENTS['piano']) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.staves = staves;
|
|
14
|
+
this.abbreviation = abbreviation;
|
|
15
|
+
this.instrument = instrument;
|
|
16
|
+
}
|
|
17
|
+
isMultiStaff() {
|
|
18
|
+
return this.staves.length > 1;
|
|
19
|
+
}
|
|
20
|
+
getMeasureCount() {
|
|
21
|
+
return this.staves[0]?.getMeasureCount() ?? 0;
|
|
22
|
+
}
|
|
23
|
+
static fromJSON(data) {
|
|
24
|
+
const staves = data.staves.map((s) => Staff.fromJSON(s));
|
|
25
|
+
const instrument = data.instrument || PRESET_INSTRUMENTS['piano'];
|
|
26
|
+
return new Part(data.name, staves, data.abbreviation, instrument);
|
|
27
|
+
}
|
|
28
|
+
transpose(semitones) {
|
|
29
|
+
return new Part(this.name, this.staves.map((s) => s.transpose(semitones)), this.abbreviation, this.instrument);
|
|
30
|
+
}
|
|
31
|
+
replaceNote(staffIndex, measureIndex, noteIndex, newNote, voiceIndex = 0) {
|
|
32
|
+
if (staffIndex < 0 || staffIndex >= this.staves.length)
|
|
33
|
+
return this;
|
|
34
|
+
const newStaves = [...this.staves];
|
|
35
|
+
newStaves[staffIndex] = newStaves[staffIndex].replaceNote(measureIndex, noteIndex, newNote, voiceIndex);
|
|
36
|
+
return new Part(this.name, newStaves, this.abbreviation, this.instrument);
|
|
37
|
+
}
|
|
38
|
+
replaceMeasure(staffIndex, measureIndex, newMeasure) {
|
|
39
|
+
if (staffIndex < 0 || staffIndex >= this.staves.length)
|
|
40
|
+
return this;
|
|
41
|
+
const newStaves = [...this.staves];
|
|
42
|
+
newStaves[staffIndex] = newStaves[staffIndex].replaceMeasure(measureIndex, newMeasure);
|
|
43
|
+
return new Part(this.name, newStaves, this.abbreviation, this.instrument);
|
|
44
|
+
}
|
|
45
|
+
deleteNote(staffIndex, measureIndex, noteIndex, voiceIndex = 0) {
|
|
46
|
+
if (staffIndex < 0 || staffIndex >= this.staves.length)
|
|
47
|
+
return this;
|
|
48
|
+
const newStaves = [...this.staves];
|
|
49
|
+
newStaves[staffIndex] = newStaves[staffIndex].deleteNote(measureIndex, noteIndex, voiceIndex);
|
|
50
|
+
return new Part(this.name, newStaves, this.abbreviation, this.instrument);
|
|
51
|
+
}
|
|
52
|
+
changeNoteDuration(staffIndex, measureIndex, noteIndex, newDuration, isDotted = false, voiceIndex = 0) {
|
|
53
|
+
if (staffIndex < 0 || staffIndex >= this.staves.length)
|
|
54
|
+
return this;
|
|
55
|
+
const newStaves = [...this.staves];
|
|
56
|
+
newStaves[staffIndex] = newStaves[staffIndex].changeNoteDuration(measureIndex, noteIndex, newDuration, isDotted, voiceIndex);
|
|
57
|
+
return new Part(this.name, newStaves, this.abbreviation, this.instrument);
|
|
58
|
+
}
|
|
59
|
+
toJSON() {
|
|
60
|
+
return {
|
|
61
|
+
name: this.name,
|
|
62
|
+
staves: this.staves.map((s) => s.toJSON()),
|
|
63
|
+
abbreviation: this.abbreviation,
|
|
64
|
+
instrument: this.instrument,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
withInstrument(instrument) {
|
|
68
|
+
return new Part(this.name, this.staves, this.abbreviation, instrument);
|
|
69
|
+
}
|
|
70
|
+
replaceStaff(staffIndex, newStaff) {
|
|
71
|
+
if (staffIndex < 0 || staffIndex >= this.staves.length)
|
|
72
|
+
return this;
|
|
73
|
+
const newStaves = [...this.staves];
|
|
74
|
+
newStaves[staffIndex] = newStaff;
|
|
75
|
+
return new Part(this.name, newStaves, this.abbreviation, this.instrument);
|
|
76
|
+
}
|
|
77
|
+
withStaves(staves) {
|
|
78
|
+
return new Part(this.name, staves, this.abbreviation, this.instrument);
|
|
79
|
+
}
|
|
80
|
+
withName(name) {
|
|
81
|
+
return new Part(name, this.staves, this.abbreviation, this.instrument);
|
|
82
|
+
}
|
|
83
|
+
addMeasure(index, measure) {
|
|
84
|
+
return new Part(this.name, this.staves.map((s) => s.addMeasure(index, measure)), this.abbreviation, this.instrument);
|
|
85
|
+
}
|
|
86
|
+
deleteMeasure(index) {
|
|
87
|
+
return new Part(this.name, this.staves.map((s) => s.deleteMeasure(index)), this.abbreviation, this.instrument);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Clef } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Pitch representation using MIDI numbers and explicit spelling (step, alter, octave).
|
|
4
|
+
*/
|
|
5
|
+
export declare class Pitch {
|
|
6
|
+
readonly midiNumber: number;
|
|
7
|
+
readonly step: number;
|
|
8
|
+
readonly alter: number;
|
|
9
|
+
readonly octave: number;
|
|
10
|
+
constructor(midiNumber: number, step?: number, alter?: number, octave?: number);
|
|
11
|
+
getNoteName(): string;
|
|
12
|
+
getOctave(): number;
|
|
13
|
+
getStaffPosition(clef: Clef): number;
|
|
14
|
+
getAbsoluteDiatonicStep(): number;
|
|
15
|
+
getDiatonicStep(): number;
|
|
16
|
+
transposeDiatonic(steps: number): Pitch;
|
|
17
|
+
withEnharmonicNext(): Pitch;
|
|
18
|
+
static fromNoteName(note: string, octave: number): Pitch;
|
|
19
|
+
static fromStaffPosition(clef: Clef, staffPosition: number): Pitch;
|
|
20
|
+
}
|