@k-l-lambda/lilylet 0.1.30
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 +60 -0
- package/lib/grammar.jison.js +1263 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/meiEncoder.d.ts +8 -0
- package/lib/meiEncoder.js +1386 -0
- package/lib/musicXmlDecoder.d.ts +20 -0
- package/lib/musicXmlDecoder.js +1047 -0
- package/lib/musicXmlTypes.d.ts +199 -0
- package/lib/musicXmlTypes.js +7 -0
- package/lib/musicXmlUtils.d.ts +81 -0
- package/lib/musicXmlUtils.js +435 -0
- package/lib/parser.d.ts +3 -0
- package/lib/parser.js +151 -0
- package/lib/serializer.d.ts +11 -0
- package/lib/serializer.js +578 -0
- package/lib/types.d.ts +241 -0
- package/lib/types.js +99 -0
- package/package.json +57 -0
- package/source/lilylet/grammar.jison.js +1263 -0
- package/source/lilylet/index.ts +12 -0
- package/source/lilylet/lilylet.jison +593 -0
- package/source/lilylet/lilypondDecoder.ts +789 -0
- package/source/lilylet/meiEncoder.ts +1780 -0
- package/source/lilylet/musicXmlDecoder.ts +1311 -0
- package/source/lilylet/musicXmlTypes.ts +205 -0
- package/source/lilylet/musicXmlUtils.ts +532 -0
- package/source/lilylet/parser.ts +178 -0
- package/source/lilylet/serializer.ts +748 -0
- package/source/lilylet/types.ts +304 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// === Enums ===
|
|
2
|
+
|
|
3
|
+
export enum Phonet {
|
|
4
|
+
c = 'c',
|
|
5
|
+
d = 'd',
|
|
6
|
+
e = 'e',
|
|
7
|
+
f = 'f',
|
|
8
|
+
g = 'g',
|
|
9
|
+
a = 'a',
|
|
10
|
+
b = 'b',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export enum Accidental {
|
|
14
|
+
natural = 'natural',
|
|
15
|
+
sharp = 'sharp',
|
|
16
|
+
flat = 'flat',
|
|
17
|
+
doubleSharp = 'doubleSharp',
|
|
18
|
+
doubleFlat = 'doubleFlat',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export enum Clef {
|
|
22
|
+
treble = 'treble',
|
|
23
|
+
bass = 'bass',
|
|
24
|
+
alto = 'alto',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export enum StemDirection {
|
|
28
|
+
up = 'up',
|
|
29
|
+
down = 'down',
|
|
30
|
+
auto = 'auto',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export enum ArticulationType {
|
|
34
|
+
staccato = 'staccato',
|
|
35
|
+
staccatissimo = 'staccatissimo',
|
|
36
|
+
tenuto = 'tenuto',
|
|
37
|
+
marcato = 'marcato',
|
|
38
|
+
accent = 'accent',
|
|
39
|
+
portato = 'portato',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum OrnamentType {
|
|
43
|
+
trill = 'trill',
|
|
44
|
+
turn = 'turn',
|
|
45
|
+
mordent = 'mordent',
|
|
46
|
+
prall = 'prall',
|
|
47
|
+
fermata = 'fermata',
|
|
48
|
+
shortFermata = 'shortFermata',
|
|
49
|
+
arpeggio = 'arpeggio',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export enum DynamicType {
|
|
53
|
+
ppp = 'ppp',
|
|
54
|
+
pp = 'pp',
|
|
55
|
+
p = 'p',
|
|
56
|
+
mp = 'mp',
|
|
57
|
+
mf = 'mf',
|
|
58
|
+
f = 'f',
|
|
59
|
+
ff = 'ff',
|
|
60
|
+
fff = 'fff',
|
|
61
|
+
sfz = 'sfz',
|
|
62
|
+
rfz = 'rfz',
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export enum HairpinType {
|
|
66
|
+
crescendoStart = 'crescendoStart',
|
|
67
|
+
crescendoEnd = 'crescendoEnd',
|
|
68
|
+
diminuendoStart = 'diminuendoStart',
|
|
69
|
+
diminuendoEnd = 'diminuendoEnd',
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export enum PedalType {
|
|
73
|
+
sustainOn = 'sustainOn',
|
|
74
|
+
sustainOff = 'sustainOff',
|
|
75
|
+
sostenutoOn = 'sostenutoOn',
|
|
76
|
+
sostenutoOff = 'sostenutoOff',
|
|
77
|
+
unaCordaOn = 'unaCordaOn',
|
|
78
|
+
unaCordaOff = 'unaCordaOff',
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export enum BarlineType {
|
|
82
|
+
single = '|',
|
|
83
|
+
double = '||',
|
|
84
|
+
end = '|.',
|
|
85
|
+
repeatStart = '.|:',
|
|
86
|
+
repeatEnd = ':|.',
|
|
87
|
+
repeatBoth = ':..:'
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export enum NavigationMarkType {
|
|
91
|
+
coda = 'coda',
|
|
92
|
+
segno = 'segno',
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// === Basic Types ===
|
|
96
|
+
|
|
97
|
+
export interface Fraction {
|
|
98
|
+
numerator: number;
|
|
99
|
+
denominator: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface Pitch {
|
|
103
|
+
phonet: Phonet;
|
|
104
|
+
accidental?: Accidental;
|
|
105
|
+
octave: number; // 0 = middle C octave, positive = higher, negative = lower
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface Duration {
|
|
109
|
+
division: number; // 1=whole, 2=half, 4=quarter, 8=eighth, etc.
|
|
110
|
+
dots: number; // 0, 1, or 2
|
|
111
|
+
tuplet?: Fraction; // e.g., {numerator: 2, denominator: 3} for triplet
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// === Placement Direction ===
|
|
115
|
+
|
|
116
|
+
export enum Placement {
|
|
117
|
+
above = 'above',
|
|
118
|
+
below = 'below',
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// === Expressive Marks ===
|
|
122
|
+
|
|
123
|
+
export interface Articulation {
|
|
124
|
+
markType: 'articulation';
|
|
125
|
+
type: ArticulationType;
|
|
126
|
+
placement?: Placement;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface Ornament {
|
|
130
|
+
markType: 'ornament';
|
|
131
|
+
type: OrnamentType;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface Dynamic {
|
|
135
|
+
markType: 'dynamic';
|
|
136
|
+
type: DynamicType;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface Hairpin {
|
|
140
|
+
markType: 'hairpin';
|
|
141
|
+
type: HairpinType;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface Tie {
|
|
145
|
+
markType: 'tie';
|
|
146
|
+
start: boolean;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface Slur {
|
|
150
|
+
markType: 'slur';
|
|
151
|
+
start: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface Beam {
|
|
155
|
+
markType: 'beam';
|
|
156
|
+
start: boolean;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface Pedal {
|
|
160
|
+
markType: 'pedal';
|
|
161
|
+
type: PedalType;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface Fingering {
|
|
165
|
+
markType: 'fingering';
|
|
166
|
+
finger: number; // 1-5
|
|
167
|
+
placement?: Placement;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface NavigationMark {
|
|
171
|
+
markType: 'navigation';
|
|
172
|
+
type: NavigationMarkType;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface MarkupMark {
|
|
176
|
+
markType: 'markup';
|
|
177
|
+
content: string;
|
|
178
|
+
placement?: Placement;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type Mark = Articulation | Ornament | Dynamic | Hairpin | Tie | Slur | Beam | Pedal | Fingering | NavigationMark | MarkupMark;
|
|
182
|
+
|
|
183
|
+
// === Key Signature ===
|
|
184
|
+
|
|
185
|
+
export interface KeySignature {
|
|
186
|
+
pitch: Phonet;
|
|
187
|
+
accidental?: Accidental;
|
|
188
|
+
mode: 'major' | 'minor';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// === Tempo ===
|
|
192
|
+
|
|
193
|
+
export interface Tempo {
|
|
194
|
+
text?: string;
|
|
195
|
+
beat?: Duration;
|
|
196
|
+
bpm?: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// === Events ===
|
|
200
|
+
|
|
201
|
+
export interface NoteEvent {
|
|
202
|
+
type: 'note';
|
|
203
|
+
pitches: Pitch[]; // Single note or chord
|
|
204
|
+
duration: Duration;
|
|
205
|
+
marks?: Mark[];
|
|
206
|
+
grace?: boolean;
|
|
207
|
+
tremolo?: number; // Tremolo division (8, 16, 32, etc.)
|
|
208
|
+
staff?: number; // For cross-staff notation
|
|
209
|
+
stemDirection?: StemDirection;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface RestEvent {
|
|
213
|
+
type: 'rest';
|
|
214
|
+
duration: Duration;
|
|
215
|
+
invisible?: boolean; // space rest (s)
|
|
216
|
+
fullMeasure?: boolean; // full measure rest (R)
|
|
217
|
+
pitch?: Pitch; // positioned rest (e.g., g'\rest)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ContextChange {
|
|
221
|
+
type: 'context';
|
|
222
|
+
key?: KeySignature;
|
|
223
|
+
time?: Fraction;
|
|
224
|
+
clef?: Clef;
|
|
225
|
+
ottava?: number; // -1, 0, 1
|
|
226
|
+
stemDirection?: StemDirection;
|
|
227
|
+
tempo?: Tempo;
|
|
228
|
+
staff?: number; // Staff number for cross-staff notation
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface TremoloEvent {
|
|
232
|
+
type: 'tremolo';
|
|
233
|
+
pitchA: Pitch[]; // First note/chord
|
|
234
|
+
pitchB: Pitch[]; // Second note/chord
|
|
235
|
+
count: number; // Number of repetitions
|
|
236
|
+
division: number; // Note division (16, 32, etc.)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface TupletEvent {
|
|
240
|
+
type: 'tuplet';
|
|
241
|
+
ratio: Fraction; // e.g., {numerator: 2, denominator: 3} for triplet
|
|
242
|
+
events: (NoteEvent | RestEvent)[];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface PitchResetEvent {
|
|
246
|
+
type: 'pitchReset';
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface BarlineEvent {
|
|
250
|
+
type: 'barline';
|
|
251
|
+
style: string; // "|", "||", "|.", ".|:", ":|.", ":..:", etc.
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface HarmonyEvent {
|
|
255
|
+
type: 'harmony';
|
|
256
|
+
text: string; // Chord symbol text like "Am7", "Cmaj7", "D/F#"
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface MarkupEvent {
|
|
260
|
+
type: 'markup';
|
|
261
|
+
content: string; // Text content of the markup
|
|
262
|
+
placement?: Placement; // Optional placement (above/below)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export type Event = NoteEvent | RestEvent | ContextChange | TremoloEvent | TupletEvent | PitchResetEvent | BarlineEvent | HarmonyEvent | MarkupEvent;
|
|
266
|
+
|
|
267
|
+
// === Structure ===
|
|
268
|
+
|
|
269
|
+
export interface Voice {
|
|
270
|
+
staff: number;
|
|
271
|
+
events: Event[];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface Metadata {
|
|
275
|
+
title?: string;
|
|
276
|
+
subtitle?: string;
|
|
277
|
+
composer?: string;
|
|
278
|
+
arranger?: string;
|
|
279
|
+
lyricist?: string;
|
|
280
|
+
opus?: string;
|
|
281
|
+
instrument?: string;
|
|
282
|
+
genre?: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Part within a measure: can be a single staff or grand staff (multiple staves)
|
|
286
|
+
// When voices have staff > 1, it's a grand staff
|
|
287
|
+
export interface Part {
|
|
288
|
+
name?: string;
|
|
289
|
+
voices: Voice[];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Measure contains parts separated by \\\
|
|
293
|
+
export interface Measure {
|
|
294
|
+
key?: KeySignature;
|
|
295
|
+
timeSig?: Fraction;
|
|
296
|
+
parts: Part[];
|
|
297
|
+
partial?: boolean;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Document structure
|
|
301
|
+
export interface LilyletDoc {
|
|
302
|
+
metadata?: Metadata;
|
|
303
|
+
measures: Measure[];
|
|
304
|
+
}
|