@scorelabs/core 1.0.3 → 1.0.5

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.
@@ -21,6 +21,7 @@ export interface Instrument {
21
21
  name: string;
22
22
  midiProgram: number;
23
23
  type?: InstrumentType;
24
+ transposition?: number;
24
25
  }
25
26
  export declare const PRESET_INSTRUMENTS: Record<string, Instrument>;
26
27
  export declare function getInstrumentByProgram(program: number): Instrument;
@@ -42,12 +42,23 @@ export const PRESET_INSTRUMENTS = {
42
42
  midiProgram: 32,
43
43
  type: InstrumentType.String,
44
44
  },
45
- [InstrumentPreset.Flute]: { name: 'Flute', midiProgram: 73, type: InstrumentType.Woodwind },
46
- [InstrumentPreset.Trumpet]: { name: 'Trumpet', midiProgram: 56, type: InstrumentType.Brass },
45
+ [InstrumentPreset.Flute]: {
46
+ name: 'Flute',
47
+ midiProgram: 73,
48
+ type: InstrumentType.Woodwind,
49
+ transposition: 0,
50
+ },
51
+ [InstrumentPreset.Trumpet]: {
52
+ name: 'Trumpet',
53
+ midiProgram: 56,
54
+ type: InstrumentType.Brass,
55
+ transposition: -2,
56
+ },
47
57
  [InstrumentPreset.Drums]: {
48
58
  name: 'Drum Kit',
49
59
  midiProgram: 118,
50
60
  type: InstrumentType.Percussion,
61
+ transposition: 0,
51
62
  },
52
63
  };
53
64
  export function getInstrumentByProgram(program) {
@@ -98,8 +98,14 @@ export class Measure {
98
98
  }
99
99
  static fromJSON(data) {
100
100
  let voices;
101
- if (data.voices) {
102
- voices = data.voices.map((v) => v.map((n) => NoteSet.fromJSON(n)));
101
+ if (data.voices && Array.isArray(data.voices)) {
102
+ voices = data.voices.map((v) => {
103
+ if (!Array.isArray(v)) {
104
+ // Fallback for single-note voice or malformed voice
105
+ return [NoteSet.fromJSON(v)];
106
+ }
107
+ return v.map((n) => NoteSet.fromJSON(n));
108
+ });
103
109
  }
104
110
  else if (data.notes) {
105
111
  voices = [data.notes.map((n) => new NoteSet([Note.fromJSON(n)]))];
@@ -110,7 +116,18 @@ export class Measure {
110
116
  return new Measure(voices, data.timeSignature, data.keySignature, data.systemBreak ?? false, data.pageBreak ?? false, data.repeats || (data.repeat ? [data.repeat] : []), data.volta, data.isPickup ?? false, data.clef, data.tempo, data.rehearsalMark, data.systemText, data.barlineStyle ?? BarlineStyle.Regular);
111
117
  }
112
118
  transpose(semitones) {
113
- return this.withVoices(this.voices.map((v) => v.map((ns) => ns.transpose(semitones))));
119
+ let newKeySignature;
120
+ if (this.keySignature) {
121
+ let fifths = this.keySignature.fifths;
122
+ fifths += semitones * 7;
123
+ // Normalize to [-7, 7] range (prefer fewer accidentals)
124
+ while (fifths > 7)
125
+ fifths -= 12;
126
+ while (fifths < -7)
127
+ fifths += 12;
128
+ newKeySignature = { fifths };
129
+ }
130
+ return this.withVoices(this.voices.map((v) => v.map((ns) => ns.transpose(semitones)))).withKeySignature(newKeySignature);
114
131
  }
115
132
  replaceNoteSet(index, newNoteSet, voiceIndex = 0) {
116
133
  if (index < 0 || voiceIndex < 0 || voiceIndex >= this.voices.length)
@@ -154,10 +171,10 @@ export class Measure {
154
171
  currentBeatLength = 1.5;
155
172
  }
156
173
  else if (timeSign.beatType === 4 && (timeSign.beats === 4 || timeSign.beats === 2)) {
157
- currentBeatLength = (lastGroupHasSixteenths || isSixteenth) ? 1.0 : 2.0;
174
+ currentBeatLength = lastGroupHasSixteenths || isSixteenth ? 1.0 : 2.0;
158
175
  }
159
176
  else if (timeSign.beatType === 2 && timeSign.beats === 2) {
160
- currentBeatLength = (lastGroupHasSixteenths || isSixteenth) ? 1.0 : 2.0;
177
+ currentBeatLength = lastGroupHasSixteenths || isSixteenth ? 1.0 : 2.0;
161
178
  }
162
179
  const currentBeatId = Math.floor(currentOffset / currentBeatLength + 0.001);
163
180
  const endOffset = currentOffset + noteDuration;
@@ -1,4 +1,4 @@
1
- import { Duration, Accidental, Articulation, Dynamic, Slur, Tuplet, Hairpin, Glissando, Arpeggio, Ottava, Pedal, Ornament, FretboardDiagram, NoteheadShape, Bowing } from './types';
1
+ import { Duration, Accidental, Articulation, Dynamic, Slur, Tuplet, Hairpin, Glissando, Arpeggio, Ottava, Pedal, Ornament, FretboardDiagram, NoteheadShape, Bowing, Lyric, StemDirection } from './types';
2
2
  import { Pitch } from './Pitch';
3
3
  /**
4
4
  * Represents a single note or rest in a measure.
@@ -10,7 +10,7 @@ export declare class Note {
10
10
  readonly isDotted: boolean;
11
11
  readonly accidental?: Accidental | undefined;
12
12
  readonly beamGroup?: number | undefined;
13
- readonly articulation?: Articulation | undefined;
13
+ readonly articulations: Articulation[];
14
14
  readonly dynamic?: Dynamic | undefined;
15
15
  readonly tie?: boolean | undefined;
16
16
  readonly slur?: Slur | undefined;
@@ -27,15 +27,28 @@ export declare class Note {
27
27
  readonly fret?: number | undefined;
28
28
  readonly string?: number | undefined;
29
29
  readonly fretboardDiagram?: FretboardDiagram | undefined;
30
- readonly lyrics?: string[] | undefined;
30
+ readonly lyrics?: (string | Lyric)[] | undefined;
31
31
  readonly staffText?: string | undefined;
32
32
  readonly color?: string | undefined;
33
33
  readonly notehead?: NoteheadShape | undefined;
34
34
  readonly bowing?: Bowing | undefined;
35
35
  readonly fingering?: number | undefined;
36
+ readonly stemDirection?: StemDirection | undefined;
37
+ readonly isStringCircled?: boolean | undefined;
38
+ readonly palmMute?: "start" | "stop" | undefined;
39
+ readonly hammerOn?: "start" | "stop" | undefined;
40
+ readonly pullOff?: "start" | "stop" | undefined;
36
41
  constructor(duration: Duration, pitch?: Pitch | undefined, // undefined for rests
37
42
  isRest?: boolean, isDotted?: boolean, accidental?: Accidental | undefined, beamGroup?: number | undefined, // Group ID for beamed notes
38
- articulation?: Articulation | undefined, dynamic?: Dynamic | undefined, tie?: boolean | undefined, slur?: Slur | undefined, tuplet?: Tuplet | undefined, hairpin?: Hairpin | undefined, isGrace?: boolean, lyric?: string | undefined, chord?: string | undefined, glissando?: Glissando | undefined, arpeggio?: Arpeggio | undefined, ottava?: Ottava | undefined, pedal?: Pedal | undefined, ornament?: Ornament | undefined, fret?: number | undefined, string?: number | undefined, fretboardDiagram?: FretboardDiagram | undefined, lyrics?: string[] | undefined, staffText?: string | undefined, color?: string | undefined, notehead?: NoteheadShape | undefined, bowing?: Bowing | undefined, fingering?: number | undefined);
43
+ articulations?: Articulation[], dynamic?: Dynamic | undefined, tie?: boolean | undefined, slur?: Slur | undefined, tuplet?: Tuplet | undefined, hairpin?: Hairpin | undefined, isGrace?: boolean, lyric?: string | undefined, chord?: string | undefined, glissando?: Glissando | undefined, arpeggio?: Arpeggio | undefined, ottava?: Ottava | undefined, pedal?: Pedal | undefined, ornament?: Ornament | undefined, fret?: number | undefined, string?: number | undefined, fretboardDiagram?: FretboardDiagram | undefined, lyrics?: (string | Lyric)[] | undefined, staffText?: string | undefined, color?: string | undefined, notehead?: NoteheadShape | undefined, bowing?: Bowing | undefined, fingering?: number | undefined, stemDirection?: StemDirection | undefined, isStringCircled?: boolean | undefined, palmMute?: "start" | "stop" | undefined, hammerOn?: "start" | "stop" | undefined, pullOff?: "start" | "stop" | undefined);
44
+ /**
45
+ * Get all lyrics as standardized objects
46
+ */
47
+ get allLyrics(): Lyric[];
48
+ /**
49
+ * Backward compatibility getter for single articulation
50
+ */
51
+ get articulation(): Articulation | undefined;
39
52
  /**
40
53
  * Get the duration value (quarter note = 1)
41
54
  */
@@ -52,12 +65,13 @@ export declare class Note {
52
65
  toggleEnharmonic(): Note;
53
66
  withPitch(pitch: Pitch): Note;
54
67
  withArticulation(articulation?: Articulation): Note;
68
+ withArticulations(articulations: Articulation[]): Note;
55
69
  withDynamic(dynamic?: Dynamic): Note;
56
70
  withTie(tie?: boolean): Note;
57
71
  withSlur(slur?: Slur): Note;
58
72
  withTuplet(tuplet?: Tuplet): Note;
59
73
  withLyric(lyric?: string): Note;
60
- withLyrics(lyrics: string[]): Note;
74
+ withLyrics(lyrics: (string | Lyric)[]): Note;
61
75
  withHairpin(hairpin?: Hairpin): Note;
62
76
  withAccidental(accidental?: Accidental): Note;
63
77
  withDuration(duration: Duration, isDotted?: boolean): Note;
@@ -75,6 +89,11 @@ export declare class Note {
75
89
  withNotehead(notehead?: NoteheadShape): Note;
76
90
  withBowing(bowing?: Bowing): Note;
77
91
  withFingering(fingering?: number): Note;
92
+ withStemDirection(stemDirection?: StemDirection): Note;
93
+ withStringCircled(isStringCircled?: boolean): Note;
94
+ withPalmMute(palmMute?: 'start' | 'stop'): Note;
95
+ withHammerOn(hammerOn?: 'start' | 'stop'): Note;
96
+ withPullOff(pullOff?: 'start' | 'stop'): Note;
78
97
  toJSON(): NoteJSON;
79
98
  static fromJSON(data: NoteJSON): Note;
80
99
  }
@@ -91,6 +110,7 @@ export interface NoteJSON {
91
110
  accidental?: string;
92
111
  beamGroup?: number;
93
112
  articulation?: string;
113
+ articulations?: string[];
94
114
  dynamic?: string;
95
115
  tie?: boolean;
96
116
  slur?: Slur;
@@ -107,10 +127,15 @@ export interface NoteJSON {
107
127
  fret?: number;
108
128
  string?: number;
109
129
  fretboardDiagram?: FretboardDiagram;
110
- lyrics?: string[];
130
+ lyrics?: (string | Lyric)[];
111
131
  staffText?: string;
112
132
  color?: string;
113
133
  notehead?: string;
114
134
  bowing?: string;
115
135
  fingering?: number;
136
+ stemDirection?: string;
137
+ isStringCircled?: boolean;
138
+ palmMute?: 'start' | 'stop';
139
+ hammerOn?: 'start' | 'stop';
140
+ pullOff?: 'start' | 'stop';
116
141
  }
@@ -10,7 +10,7 @@ export class Note {
10
10
  isDotted;
11
11
  accidental;
12
12
  beamGroup;
13
- articulation;
13
+ articulations;
14
14
  dynamic;
15
15
  tie;
16
16
  slur;
@@ -33,16 +33,21 @@ export class Note {
33
33
  notehead;
34
34
  bowing;
35
35
  fingering;
36
+ stemDirection;
37
+ isStringCircled;
38
+ palmMute;
39
+ hammerOn;
40
+ pullOff;
36
41
  constructor(duration, pitch, // undefined for rests
37
42
  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) {
43
+ articulations = [], dynamic, tie, slur, tuplet, hairpin, isGrace = false, lyric, chord, glissando, arpeggio, ottava, pedal, ornament, fret, string, fretboardDiagram, lyrics, staffText, color, notehead, bowing, fingering, stemDirection, isStringCircled, palmMute, hammerOn, pullOff) {
39
44
  this.duration = duration;
40
45
  this.pitch = pitch;
41
46
  this.isRest = isRest;
42
47
  this.isDotted = isDotted;
43
48
  this.accidental = accidental;
44
49
  this.beamGroup = beamGroup;
45
- this.articulation = articulation;
50
+ this.articulations = articulations;
46
51
  this.dynamic = dynamic;
47
52
  this.tie = tie;
48
53
  this.slur = slur;
@@ -65,6 +70,29 @@ export class Note {
65
70
  this.notehead = notehead;
66
71
  this.bowing = bowing;
67
72
  this.fingering = fingering;
73
+ this.stemDirection = stemDirection;
74
+ this.isStringCircled = isStringCircled;
75
+ this.palmMute = palmMute;
76
+ this.hammerOn = hammerOn;
77
+ this.pullOff = pullOff;
78
+ }
79
+ /**
80
+ * Get all lyrics as standardized objects
81
+ */
82
+ get allLyrics() {
83
+ if (this.lyrics) {
84
+ return this.lyrics.map((l) => (typeof l === 'string' ? { text: l } : l));
85
+ }
86
+ if (this.lyric) {
87
+ return [{ text: this.lyric }];
88
+ }
89
+ return [];
90
+ }
91
+ /**
92
+ * Backward compatibility getter for single articulation
93
+ */
94
+ get articulation() {
95
+ return this.articulations[0];
68
96
  }
69
97
  /**
70
98
  * Get the duration value (quarter note = 1)
@@ -92,10 +120,10 @@ export class Note {
92
120
  this.duration === Duration.TwoHundredFiftySixth));
93
121
  }
94
122
  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);
123
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection);
96
124
  }
97
125
  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);
126
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection);
99
127
  }
100
128
  transpose(semitones) {
101
129
  if (this.isRest || !this.pitch) {
@@ -105,7 +133,7 @@ export class Note {
105
133
  const chromaticIdx = newPitch.midiNumber % 12;
106
134
  const hasSharp = [1, 3, 6, 8, 10].includes(chromaticIdx);
107
135
  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);
136
+ return new Note(this.duration, newPitch, this.isRest, this.isDotted, newAccidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
109
137
  }
110
138
  transposeOctave(octaves) {
111
139
  if (!this.pitch || this.isRest)
@@ -138,94 +166,116 @@ export class Note {
138
166
  return this.withPitch(newPitch).withAccidental(newAccidental);
139
167
  }
140
168
  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);
169
+ return new Note(this.duration, pitch, false, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
142
170
  }
143
171
  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);
172
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, articulation ? [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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
173
+ }
174
+ withArticulations(articulations) {
175
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
145
176
  }
146
177
  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);
178
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
148
179
  }
149
180
  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);
181
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
151
182
  }
152
183
  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);
184
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
154
185
  }
155
186
  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);
187
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
157
188
  }
158
189
  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);
190
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
160
191
  }
161
192
  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);
193
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
163
194
  }
164
195
  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);
196
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
166
197
  }
167
198
  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);
199
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
169
200
  }
170
201
  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);
202
+ return new Note(duration, this.pitch, this.isRest, isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
172
203
  }
173
204
  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);
205
+ return new Note(this.duration, this.pitch, isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
175
206
  }
176
207
  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);
208
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
178
209
  }
179
210
  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);
211
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
181
212
  }
182
213
  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);
214
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
184
215
  }
185
216
  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);
217
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
187
218
  }
188
219
  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);
220
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
190
221
  }
191
222
  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);
223
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
193
224
  }
194
225
  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);
226
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
196
227
  }
197
228
  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);
229
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
199
230
  }
200
231
  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);
232
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
202
233
  }
203
234
  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);
235
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection);
205
236
  }
206
237
  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);
238
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
208
239
  }
209
240
  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);
241
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
211
242
  }
212
243
  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);
244
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
245
+ }
246
+ withStemDirection(stemDirection) {
247
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
248
+ }
249
+ withStringCircled(isStringCircled) {
250
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, isStringCircled, this.palmMute, this.hammerOn, this.pullOff);
251
+ }
252
+ withPalmMute(palmMute) {
253
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, palmMute, this.hammerOn, this.pullOff);
254
+ }
255
+ withHammerOn(hammerOn) {
256
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, hammerOn, this.pullOff);
257
+ }
258
+ withPullOff(pullOff) {
259
+ return new Note(this.duration, this.pitch, this.isRest, this.isDotted, this.accidental, this.beamGroup, this.articulations, 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, this.stemDirection, this.isStringCircled, this.palmMute, this.hammerOn, pullOff);
214
260
  }
215
261
  toJSON() {
216
262
  return {
217
263
  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,
264
+ pitch: this.isRest
265
+ ? undefined
266
+ : this.pitch
267
+ ? {
268
+ midiNumber: this.pitch.midiNumber,
269
+ step: this.pitch.step,
270
+ alter: this.pitch.alter,
271
+ octave: this.pitch.octave,
272
+ }
273
+ : undefined,
224
274
  isRest: this.isRest || undefined,
225
275
  isDotted: this.isDotted || undefined,
226
276
  accidental: this.accidental,
227
277
  beamGroup: this.beamGroup,
228
- articulation: this.articulation,
278
+ articulations: this.articulations.length > 0 ? this.articulations : undefined,
229
279
  dynamic: this.dynamic,
230
280
  tie: this.tie,
231
281
  slur: this.slur,
@@ -248,12 +298,27 @@ export class Note {
248
298
  notehead: this.notehead,
249
299
  bowing: this.bowing,
250
300
  fingering: this.fingering,
301
+ stemDirection: this.stemDirection,
302
+ isStringCircled: this.isStringCircled,
303
+ palmMute: this.palmMute,
304
+ hammerOn: this.hammerOn,
305
+ pullOff: this.pullOff,
306
+ // Legacy field (optional)
307
+ articulation: this.articulations.length > 0 ? this.articulations[0] : undefined,
251
308
  };
252
309
  }
253
310
  static fromJSON(data) {
254
311
  const pitch = data.pitch
255
312
  ? new Pitch(data.pitch.midiNumber, data.pitch.step, data.pitch.alter, data.pitch.octave)
256
313
  : 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);
314
+ // Handle migration from single articulation to array
315
+ let articulations = [];
316
+ if (data.articulations && Array.isArray(data.articulations)) {
317
+ articulations = data.articulations;
318
+ }
319
+ else if (data.articulation) {
320
+ articulations = [data.articulation];
321
+ }
322
+ return new Note(data.duration, pitch, data.isRest ?? false, data.isDotted ?? false, data.accidental, data.beamGroup, articulations, 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, data.stemDirection, data.isStringCircled, data.palmMute, data.hammerOn, data.pullOff);
258
323
  }
259
324
  }
@@ -13,7 +13,7 @@ export declare class NoteSet {
13
13
  withDuration(duration: Duration, isDotted?: boolean): NoteSet;
14
14
  withBeamGroup(group?: number): NoteSet;
15
15
  withNotes(notes: Note[]): NoteSet;
16
- withLyrics(lyrics: string[]): NoteSet;
16
+ withLyrics(lyrics: (string | any)[]): NoteSet;
17
17
  withTuplet(tuplet?: any): NoteSet;
18
18
  withPitch(pitch: any): NoteSet;
19
19
  withAccidental(accidental: any): NoteSet;
@@ -39,6 +39,11 @@ export declare class NoteSet {
39
39
  withNotehead(notehead: any): NoteSet;
40
40
  withBowing(bowing?: any): NoteSet;
41
41
  withFingering(fingering?: number): NoteSet;
42
+ withHammerOn(type?: 'start' | 'stop'): NoteSet;
43
+ withPullOff(type?: 'start' | 'stop'): NoteSet;
44
+ withPalmMute(type?: 'start' | 'stop'): NoteSet;
45
+ withStringCircled(isStringCircled?: boolean): NoteSet;
46
+ withStemDirection(dir?: any): NoteSet;
42
47
  withLyric(lyric?: any): NoteSet;
43
48
  withStaffText(text?: string): NoteSet;
44
49
  withFretboardDiagram(diagram?: any): NoteSet;
@@ -60,13 +65,19 @@ export declare class NoteSet {
60
65
  get string(): number | undefined;
61
66
  get bowing(): import("./types").Bowing | undefined;
62
67
  get fingering(): number | undefined;
63
- get lyrics(): string[] | undefined;
68
+ get allLyrics(): import("./types").Lyric[];
69
+ get lyrics(): (string | import("./types").Lyric)[] | undefined;
64
70
  get lyric(): string | undefined;
65
71
  get chord(): string | undefined;
66
72
  get fretboardDiagram(): import("./types").FretboardDiagram | undefined;
67
73
  get staffText(): string | undefined;
74
+ get hammerOn(): "start" | "stop" | undefined;
75
+ get pullOff(): "start" | "stop" | undefined;
76
+ get palmMute(): "start" | "stop" | undefined;
77
+ get isStringCircled(): boolean | undefined;
78
+ get stemDirection(): import("./types").StemDirection | undefined;
68
79
  toJSON(): NoteSetJSON;
69
- static fromJSON(data: NoteSetJSON): NoteSet;
80
+ static fromJSON(data: any): NoteSet;
70
81
  }
71
82
  export interface NoteSetJSON {
72
83
  notes: NoteJSON[];