@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
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Lilylet
|
|
2
|
+
|
|
3
|
+
Lilylet is a LilyPond-like music notation language designed for Markdown rendering and symbolic music representation in AIGC applications.
|
|
4
|
+
|
|
5
|
+
## Try It Online
|
|
6
|
+
|
|
7
|
+
- [Live Editor](https://k-l-lambda.github.io/lilylet-live-editor/) - Interactive editor with real-time music notation rendering
|
|
8
|
+
- [Markdown Editor](https://k-l-lambda.github.io/lilylet-live-editor/markdown) - Write documents with embedded Lilylet music snippets
|
|
9
|
+
- [Tutorial](https://k-l-lambda.github.io/lilylet-live-editor/docs/lilylet-tutorial.html) - Comprehensive guide to Lilylet syntax
|
|
10
|
+
|
|
11
|
+
## Why a New Language?
|
|
12
|
+
|
|
13
|
+
### 1. Leveraging LilyPond's Excellent Syntax
|
|
14
|
+
|
|
15
|
+
LilyPond uses a LaTeX-like text markup syntax with significant advantages:
|
|
16
|
+
|
|
17
|
+
- **Beginner-friendly**: Intuitive commands like `\clef`, `\key`, `\time` require no knowledge of complex binary formats
|
|
18
|
+
- **Human-readable**: Notes are represented directly as letters (c d e f g a b), durations as numbers (4 = quarter note)
|
|
19
|
+
- **Relative pitch mode**: Each note is calculated relative to the previous one—only octave shifts (`'` or `,`) are needed when the interval exceeds a fourth, dramatically reducing octave markers. See [LilyPond Relative Octave Entry](https://lilypond.org/doc/v2.23/Documentation/notation/writing-pitches#relative-octave-entry)
|
|
20
|
+
|
|
21
|
+
### 2. Reducing LilyPond's Excessive Flexibility
|
|
22
|
+
|
|
23
|
+
LilyPond is powerful but overly flexible—the same music can be written in multiple ways, which creates problems for AIGC scenarios:
|
|
24
|
+
|
|
25
|
+
| Issue | LilyPond | Lilylet |
|
|
26
|
+
|-------|----------|---------|
|
|
27
|
+
| Verbose context | Requires `\version`, `\header`, `\paper`, `\layout` boilerplate | Only core music content |
|
|
28
|
+
| Inconsistent formats | Relative pitch, absolute pitch, multiple chord notations | Unified format, reduced ambiguity |
|
|
29
|
+
| Complex nesting | `\new Staff << \new Voice \relative c' { ... } >>` | `\staff "1" ...` |
|
|
30
|
+
|
|
31
|
+
### 3. Optimized for AIGC
|
|
32
|
+
|
|
33
|
+
- **Shorter context description**: Removes redundant information, allowing LLMs to process more music content within limited context windows
|
|
34
|
+
- **Formatted layout**: Fixed syntax structure facilitates model learning and generation
|
|
35
|
+
- **Markdown-embeddable**: Music snippets can be directly embedded in documents
|
|
36
|
+
|
|
37
|
+
### Basic Syntax
|
|
38
|
+
|
|
39
|
+
| Element | Syntax | Description |
|
|
40
|
+
|---------|--------|-------------|
|
|
41
|
+
| Staff | `\staff "1"` | Specifies which staff the current voice belongs to |
|
|
42
|
+
| Key | `\key c \major` | C major |
|
|
43
|
+
| Time | `\time 4/4` | 4/4 time signature |
|
|
44
|
+
| Clef | `\clef "treble"` | Treble clef |
|
|
45
|
+
| Notes | `c4 d8 e16` | C quarter note, D eighth note, E sixteenth note |
|
|
46
|
+
| Accidentals | `cs` `cf` `css` `cff` | C sharp, C flat, C double-sharp, C double-flat |
|
|
47
|
+
| Octave | `c'` `c,` | One octave higher, one octave lower |
|
|
48
|
+
| Chord | `<c e g>4` | C major triad, quarter note |
|
|
49
|
+
| Voice separator | `\\` | Separates multiple voices within the same staff |
|
|
50
|
+
| Part separator | `\\\` | Separates different instrument tracks (parts) in a score |
|
|
51
|
+
| Bar line | `\|` | Separates measures |
|
|
52
|
+
|
|
53
|
+
## Syntax Example
|
|
54
|
+
|
|
55
|
+
```lilylet
|
|
56
|
+
\staff "1" \key e \major \time 2/4 \clef "treble" \stemUp e8 [ ds16 e16 ] fs4 ~ \\
|
|
57
|
+
\staff "1" s4 \stemDown ds4 ~ \\
|
|
58
|
+
\staff "2" \key e \major \clef "bass" \stemUp e,,4 b4 \\
|
|
59
|
+
\staff "2" \stemDown e,,16 [ b'8 -> b16 ] b,16 [ b'8 -> b16 ] |
|
|
60
|
+
```
|