notula 0.0.0-stage → 0.7.0

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/LICENSE +21 -0
  3. package/README.md +214 -2
  4. package/README.zh-CN.md +216 -0
  5. package/THIRD_PARTY_NOTICES.md +50 -0
  6. package/assets/fonts/OFL.txt +94 -0
  7. package/dist-lib/analyze-DA8Fg8Gs.js +2 -0
  8. package/dist-lib/analyze-DA8Fg8Gs.js.map +1 -0
  9. package/dist-lib/audio/highlight.d.ts +14 -0
  10. package/dist-lib/audio/index.d.ts +3 -0
  11. package/dist-lib/audio/player.d.ts +58 -0
  12. package/dist-lib/audio/timeline.d.ts +45 -0
  13. package/dist-lib/audio.js +2 -0
  14. package/dist-lib/audio.js.map +1 -0
  15. package/dist-lib/core/color.d.ts +1 -0
  16. package/dist-lib/core/number.d.ts +2 -0
  17. package/dist-lib/core/rational.d.ts +20 -0
  18. package/dist-lib/core/text.d.ts +1 -0
  19. package/dist-lib/dsl/ast.d.ts +295 -0
  20. package/dist-lib/dsl/lexer.d.ts +115 -0
  21. package/dist-lib/dsl/parser.d.ts +7 -0
  22. package/dist-lib/index-B2NJU9Bz.js +2 -0
  23. package/dist-lib/index-B2NJU9Bz.js.map +1 -0
  24. package/dist-lib/index.d.ts +16 -0
  25. package/dist-lib/index.js +2 -0
  26. package/dist-lib/index.js.map +1 -0
  27. package/dist-lib/integrations/index.d.ts +1 -0
  28. package/dist-lib/integrations/markdown-dom.d.ts +8 -0
  29. package/dist-lib/integrations/markdown.d.ts +45 -0
  30. package/dist-lib/integrations/obsidian-child.d.ts +16 -0
  31. package/dist-lib/integrations/obsidian-playback.d.ts +19 -0
  32. package/dist-lib/integrations/obsidian.d.ts +86 -0
  33. package/dist-lib/integrations/panorama-scroll.d.ts +7 -0
  34. package/dist-lib/integrations/resize.d.ts +6 -0
  35. package/dist-lib/integrations.js +2 -0
  36. package/dist-lib/integrations.js.map +1 -0
  37. package/dist-lib/ir/analyze.d.ts +13 -0
  38. package/dist-lib/ir/types.d.ts +263 -0
  39. package/dist-lib/layout/accidentals.d.ts +20 -0
  40. package/dist-lib/layout/annotations.d.ts +163 -0
  41. package/dist-lib/layout/articulations.d.ts +93 -0
  42. package/dist-lib/layout/beaming.d.ts +92 -0
  43. package/dist-lib/layout/grace.d.ts +33 -0
  44. package/dist-lib/layout/layout.d.ts +3 -0
  45. package/dist-lib/layout/polyphony.d.ts +20 -0
  46. package/dist-lib/layout/spacing.d.ts +38 -0
  47. package/dist-lib/layout/staff.d.ts +60 -0
  48. package/dist-lib/layout/stems-chords.d.ts +59 -0
  49. package/dist-lib/layout/systems.d.ts +31 -0
  50. package/dist-lib/layout/ties-slurs.d.ts +59 -0
  51. package/dist-lib/layout/tuplets.d.ts +25 -0
  52. package/dist-lib/layout/types.d.ts +210 -0
  53. package/dist-lib/metrics/bravura-glyph-paths.d.ts +9 -0
  54. package/dist-lib/metrics/bravura-metrics.d.ts +52 -0
  55. package/dist-lib/micro/micro.d.ts +33 -0
  56. package/dist-lib/obsidian.js +2 -0
  57. package/dist-lib/obsidian.js.map +1 -0
  58. package/dist-lib/render.d.ts +20 -0
  59. package/dist-lib/shared.d.ts +8 -0
  60. package/dist-lib/svg/dom.d.ts +4 -0
  61. package/dist-lib/svg/emitter.d.ts +56 -0
  62. package/docs/INTEGRATIONS.md +200 -0
  63. package/docs/SYNTAX.md +74 -0
  64. package/docs/assets/cadenza-dark.svg +497 -0
  65. package/docs/assets/cadenza-light.svg +497 -0
  66. package/docs/assets/chords-dark.svg +695 -0
  67. package/docs/assets/chords-light.svg +695 -0
  68. package/docs/assets/hero-dark.svg +498 -0
  69. package/docs/assets/hero-light.svg +498 -0
  70. package/docs/assets/logo-dark.svg +12 -0
  71. package/docs/assets/logo-light.svg +12 -0
  72. package/docs/assets/wordmark-dark.svg +41 -0
  73. package/docs/assets/wordmark-light.svg +41 -0
  74. package/examples/obsidian-plugin/README.md +43 -0
  75. package/llms.txt +141 -0
  76. package/package.json +94 -4
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <g transform="translate(-0.25 0.03)">
3
+ <path fill="#e7e5e4" d="M23.15 6 H24.5
4
+ C28.33 26.46 47.09 22.56 54.85 51.26 V6 H57.05 V56.5 H55.28
5
+ C52.41 34.19 30.33 33.71 25.35 12.7 V49.09
6
+ C25.35 53.45 21.34 57.39 16.4 57.89
7
+ C11.46 58.4 7.45 55.27 7.45 50.91
8
+ C7.45 46.55 11.46 42.61 16.4 42.11
9
+ C18.99 41.84 21.45 42.58 23.15 44.13 Z"/>
10
+ <circle fill="#dc2626" cx="30.05" cy="48.35" r="2.1"/>
11
+ </g>
12
+ </svg>
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <g transform="translate(-0.25 0.03)">
3
+ <path fill="#1c1917" d="M23.15 6 H24.5
4
+ C28.33 26.46 47.09 22.56 54.85 51.26 V6 H57.05 V56.5 H55.28
5
+ C52.41 34.19 30.33 33.71 25.35 12.7 V49.09
6
+ C25.35 53.45 21.34 57.39 16.4 57.89
7
+ C11.46 58.4 7.45 55.27 7.45 50.91
8
+ C7.45 46.55 11.46 42.61 16.4 42.11
9
+ C18.99 41.84 21.45 42.58 23.15 44.13 Z"/>
10
+ <circle fill="#dc2626" cx="30.05" cy="48.35" r="2.1"/>
11
+ </g>
12
+ </svg>
@@ -0,0 +1,41 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 207.5 64" width="207.5" height="64">
2
+ <path fill="#e7e5e4" d="M23.15 6 H24.5
3
+ C28.33 26.46 47.09 22.56 54.85 51.26 V6 H57.05 V56.5 H55.28
4
+ C52.41 34.19 30.33 33.71 25.35 12.7 V49.09
5
+ C25.35 53.45 21.34 57.39 16.4 57.89
6
+ C11.46 58.4 7.45 55.27 7.45 50.91
7
+ C7.45 46.55 11.46 42.61 16.4 42.11
8
+ C18.99 41.84 21.45 42.58 23.15 44.13 Z"/>
9
+ <circle fill="#dc2626" cx="30.05" cy="48.35" r="2.1"/>
10
+ <path fill="#e7e5e4" fill-rule="evenodd" transform="translate(63 0)" d="M15.8 24.5
11
+ C24.7 24.5 30.4 30.9 30.4 39.67 C30.4 49.55 23.8 56.5 14.48 56.5
12
+ C5.88 56.5 0 50.34 0 41.34 C0 31.64 6.61 24.5 15.8 24.5 Z
13
+ M14.67 26.55 C8.68 26.55 6.11 32.9 6.11 40.12
14
+ C6.11 47.72 9.44 54.42 15.75 54.42 C21.72 54.42 24.28 48.23 24.28 40.87
15
+ C24.28 33.11 20.9 26.55 14.67 26.55 Z"/>
16
+ <path fill="#e7e5e4" transform="translate(96.3 0)" d="M5 20.8 L9.93 16.37 H10.61 V25.2
17
+ H18.39 L17.69 27.97 H10.61 V46.54 C10.61 50.78 11.55 53.08 14.28 53.08
18
+ C15.64 53.08 16.87 52.55 18.07 51.7 L19 53.14
19
+ C16.65 55.31 14.47 56.5 11.51 56.5 C6.89 56.5 5 53.35 5 48.69 V27.97
20
+ H0 V26.78 L2.22 25.2 H4.15 Q5 25.2 5 24.35 Z"/>
21
+ <path fill="#e7e5e4" transform="translate(117.9 0)" d="M0 26.23 L10.08 24.55 H10.62 V44.71
22
+ C10.62 49.83 12.37 52.63 16.54 52.63 C19.07 52.63 21.02 51.42 22.46 49.82
23
+ V31.76 C22.46 28.55 21.85 28.18 17.71 27.69 V26.23 L27.68 24.55 H28.23 V50.71
24
+ C28.23 53.95 29.05 54.48 32.1 54.91 V56.5 H22.46 V52.13
25
+ C19.73 54.65 16.6 56.5 13.06 56.5 C7.52 56.5 4.85 52.53 4.85 46.55 V31.76
26
+ C4.85 28.55 4.24 28.18 0 27.69 Z"/>
27
+ <path fill="#e7e5e4" transform="translate(153.6 0)" d="M0 9.72 L10.17 7.4 H10.72 V50.71
28
+ C10.72 53.95 11.52 54.48 15.32 54.91 V56.5 H0 V54.91
29
+ C4.03 54.45 4.91 53.95 4.91 50.71 V15.37 C4.91 12.21 4.22 11.68 0 11.3 Z"/>
30
+ <path fill="#e7e5e4" fill-rule="evenodd" transform="translate(172.1 0)" d="M14.13 24.5
31
+ C21.2 24.5 24.2 28.8 24.2 35.1 V48.1 C24.2 51.48 24.88 53.18 26.53 53.18
32
+ C27.17 53.18 27.97 52.84 28.57 52.31 L29.4 53.76
33
+ C27.81 55.19 26.05 56.5 23.78 56.5 C21.13 56.5 19.45 54.73 18.88 52.15
34
+ C16.14 54.68 12.88 56.5 9.22 56.5 C3.8 56.5 0 52.99 0 48.44
35
+ C0 43.48 2.93 41.21 9.1 39.36 L18.56 36.46 V34.66
36
+ C18.56 29.77 16.9 26.66 12.97 26.66 C9.81 26.66 7.61 28.27 6.84 31.1
37
+ C6.33 33.02 5.36 34.5 3.49 34.5 C1.83 34.5 0.83 33.45 0.83 32.05
38
+ C0.83 28.47 8.59 24.5 14.13 24.5 Z
39
+ M18.56 38.64 L11.6 41.01 C7.64 42.36 6.02 44.26 6.02 47.35
40
+ C6.02 50.72 8.1 52.86 11.19 52.86 C13.71 52.86 16.17 51.66 18.56 49.87 Z"/>
41
+ </svg>
@@ -0,0 +1,41 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 207.5 64" width="207.5" height="64">
2
+ <path fill="#1c1917" d="M23.15 6 H24.5
3
+ C28.33 26.46 47.09 22.56 54.85 51.26 V6 H57.05 V56.5 H55.28
4
+ C52.41 34.19 30.33 33.71 25.35 12.7 V49.09
5
+ C25.35 53.45 21.34 57.39 16.4 57.89
6
+ C11.46 58.4 7.45 55.27 7.45 50.91
7
+ C7.45 46.55 11.46 42.61 16.4 42.11
8
+ C18.99 41.84 21.45 42.58 23.15 44.13 Z"/>
9
+ <circle fill="#dc2626" cx="30.05" cy="48.35" r="2.1"/>
10
+ <path fill="#1c1917" fill-rule="evenodd" transform="translate(63 0)" d="M15.8 24.5
11
+ C24.7 24.5 30.4 30.9 30.4 39.67 C30.4 49.55 23.8 56.5 14.48 56.5
12
+ C5.88 56.5 0 50.34 0 41.34 C0 31.64 6.61 24.5 15.8 24.5 Z
13
+ M14.67 26.55 C8.68 26.55 6.11 32.9 6.11 40.12
14
+ C6.11 47.72 9.44 54.42 15.75 54.42 C21.72 54.42 24.28 48.23 24.28 40.87
15
+ C24.28 33.11 20.9 26.55 14.67 26.55 Z"/>
16
+ <path fill="#1c1917" transform="translate(96.3 0)" d="M5 20.8 L9.93 16.37 H10.61 V25.2
17
+ H18.39 L17.69 27.97 H10.61 V46.54 C10.61 50.78 11.55 53.08 14.28 53.08
18
+ C15.64 53.08 16.87 52.55 18.07 51.7 L19 53.14
19
+ C16.65 55.31 14.47 56.5 11.51 56.5 C6.89 56.5 5 53.35 5 48.69 V27.97
20
+ H0 V26.78 L2.22 25.2 H4.15 Q5 25.2 5 24.35 Z"/>
21
+ <path fill="#1c1917" transform="translate(117.9 0)" d="M0 26.23 L10.08 24.55 H10.62 V44.71
22
+ C10.62 49.83 12.37 52.63 16.54 52.63 C19.07 52.63 21.02 51.42 22.46 49.82
23
+ V31.76 C22.46 28.55 21.85 28.18 17.71 27.69 V26.23 L27.68 24.55 H28.23 V50.71
24
+ C28.23 53.95 29.05 54.48 32.1 54.91 V56.5 H22.46 V52.13
25
+ C19.73 54.65 16.6 56.5 13.06 56.5 C7.52 56.5 4.85 52.53 4.85 46.55 V31.76
26
+ C4.85 28.55 4.24 28.18 0 27.69 Z"/>
27
+ <path fill="#1c1917" transform="translate(153.6 0)" d="M0 9.72 L10.17 7.4 H10.72 V50.71
28
+ C10.72 53.95 11.52 54.48 15.32 54.91 V56.5 H0 V54.91
29
+ C4.03 54.45 4.91 53.95 4.91 50.71 V15.37 C4.91 12.21 4.22 11.68 0 11.3 Z"/>
30
+ <path fill="#1c1917" fill-rule="evenodd" transform="translate(172.1 0)" d="M14.13 24.5
31
+ C21.2 24.5 24.2 28.8 24.2 35.1 V48.1 C24.2 51.48 24.88 53.18 26.53 53.18
32
+ C27.17 53.18 27.97 52.84 28.57 52.31 L29.4 53.76
33
+ C27.81 55.19 26.05 56.5 23.78 56.5 C21.13 56.5 19.45 54.73 18.88 52.15
34
+ C16.14 54.68 12.88 56.5 9.22 56.5 C3.8 56.5 0 52.99 0 48.44
35
+ C0 43.48 2.93 41.21 9.1 39.36 L18.56 36.46 V34.66
36
+ C18.56 29.77 16.9 26.66 12.97 26.66 C9.81 26.66 7.61 28.27 6.84 31.1
37
+ C6.33 33.02 5.36 34.5 3.49 34.5 C1.83 34.5 0.83 33.45 0.83 32.05
38
+ C0.83 28.47 8.59 24.5 14.13 24.5 Z
39
+ M18.56 38.64 L11.6 41.01 C7.64 42.36 6.02 44.26 6.02 47.35
40
+ C6.02 50.72 8.1 52.86 11.19 52.86 C13.71 52.86 16.17 51.66 18.56 49.87 Z"/>
41
+ </svg>
@@ -0,0 +1,43 @@
1
+ # Notula for Obsidian
2
+
3
+ Notula Music Scores renders fenced `notula` blocks as standalone SVG paths and plays them with Web Audio. The plugin works in Reading view and Live Preview on Obsidian 1.4 and later. The score follows your vault theme and needs no local music font.
4
+
5
+ ## Build and install
6
+
7
+ 1. From the repository root, run `npm ci` and `npm run build:obsidian`.
8
+ 2. Copy `main.js`, `manifest.json`, and `styles.css` from `dist-obsidian/` into your vault’s `.obsidian/plugins/notula-scores/` directory.
9
+ 3. Reload Obsidian. In **Settings → Community plugins**, enable **Notula Music Scores**.
10
+
11
+ ## Score blocks
12
+
13
+ ````markdown
14
+ ```notula
15
+ % notula: zoom=1.25 view=panorama speed=0.75 audio=on sound=builtin theme=inherit
16
+ \clef treble \key g \major \time 3/4
17
+ \relative c'' { d4 g,8( a b c) | d4 g,4 g4 | g2. |. }
18
+ ```
19
+ ````
20
+
21
+ The optional `% notula:` comment must be the first non-empty line. Set `zoom` and `speed` to values from `0.5` to `2`, `view` to `wrap` or `panorama`, and `audio` to `on` or `off`. Use `sound=builtin` for the offline synth or `sound=smplr` for the sampled grand piano. `theme=inherit` uses the surrounding text color. Unknown or invalid directives are ignored.
22
+
23
+ In the **Notula Music Scores** settings tab, configure **Default zoom**, **Default view**, **Default playback speed**, and **Sound source** for the vault. A block header overrides the corresponding global defaults. Toolbar changes take precedence for the current rendered block. Select the zoom percentage to reset that block to 100%. Changing speed during playback starts the score again at the selected rate.
24
+
25
+ **Wrap** reflows the systems to fit the available width. **Pano** displays one horizontal score and follows the active notes during playback. Drag the score, use the horizontal scrollbar, or scroll horizontally with a trackpad or touch gesture to pause following. Select **Resume follow** to return to the current note. Use Tab to reach the controls with the keyboard.
26
+
27
+ ## Export image
28
+
29
+ Hover over a score to reveal the toolbar, or use Tab to reach its controls. On touch screens, the toolbar is visible. Open the export button menu and choose **Copy PNG** to copy to a supported clipboard, **Save PNG (2×)** to save a raster image, or **Save SVG** to save a standalone vector image.
30
+
31
+ The **Export theme** setting offers **Print light (white)** by default, **Follow current theme**, and **Transparent (SVG only, white for PNG)**. Wide scores in **Pano** automatically export PNG at a lower scale when 2× exceeds the device’s canvas limits. Use **Save SVG** for ultra-wide scores that exceed those limits even at 1×.
32
+
33
+ On desktop, saves normally go to your downloads. On mobile, saves go to the vault’s attachment location. When the attachment path API is unavailable, the plugin saves next to the source note, or in the vault root when the note path is unavailable. Image export works 100% offline with zero network requests.
34
+
35
+ ## Playback and network use
36
+
37
+ **Grand piano (smplr)** is selected by default under **Sound source**. Rendering and editing scores make zero sample requests. For immediate offline playback, choose **Built-in synth (offline)**, select **Synth** in the block toolbar, or set `% notula: sound=builtin` on the first non-empty line. Use `audio=off` to hide a block’s audio controls. You can switch between the score and `</>` source view during loading or playback.
38
+
39
+ Grand piano downloads public-domain Steinway audio samples from `smpldsnds.github.io` only when you press **Play** and samples are needed. Requests fetch sample files and send no score text or vault contents. The plugin displays **Loading…** during loading. If samples fail to load, loading reaches the 2.5-second timeout, or the sampled instrument fails during playback, the plugin plays with the built-in synth and shows **Offline fallback**. [Sample host](https://smpldsnds.github.io/sfzinstruments-splendid-grand-piano/)
40
+
41
+ The `notula/audio` npm entry defaults to the offline synth with zero runtime dependencies. The sampler is bundled with the Playground and the Obsidian plugin.
42
+
43
+ smplr is distributed under the MIT License. AKAI released the SplendidGrandPiano Steinway samples into the public domain. The upstream credits kinwie for sample fixes and SFZ mapping. [smplr](https://github.com/danigb/smplr) · [SplendidGrandPiano](https://github.com/sfzinstruments/SplendidGrandPiano) · [Third-party notices](https://github.com/ZenithRains/notula/blob/main/THIRD_PARTY_NOTICES.md)
package/llms.txt ADDED
@@ -0,0 +1,141 @@
1
+ # Notula
2
+
3
+ > Notula renders short scores and standalone music symbols to SVG for the web and Markdown.
4
+
5
+ Pass score source to `compile(source)` and require empty `result.diagnostics`. For inline staves pass `{ mode: 'compact', sizeUnit: 'em' }`. Use `String.raw` in JavaScript to preserve backslashes. `%` starts a line comment.
6
+
7
+ ## JavaScript API
8
+
9
+ - `notula` exports `compile(source)` for SVG and diagnostics, `renderToString(source)` for an SVG string, `render(source, host)` for DOM mounting, and `compileMicro(expression)` for an inline symbol result with `.svg`.
10
+ - The default is `standalone: true`, which embeds music glyphs as SVG `<path>` elements. Pass `{ standalone: false }` to render music glyphs as Bravura font `<text>` elements and load the font in the host.
11
+ - `notula/audio` provides Web Audio playback. `notula/integrations` provides Markdown and DOM adapters. `notula/obsidian` provides the Obsidian adapter.
12
+
13
+ ## Pitch and duration
14
+
15
+ - Write lowercase `c d e f g a b`. Spell every sharp `is` or flat `es` explicitly regardless of `\key`, as in `fis`, `ees`, `bes`. Double accidentals use `isis` and `eses`. Bare letters are naturals. Before the duration, append `!` to force an accidental (`fis'!4`) or `?` for a courtesy accidental.
16
+ - Absolute `c'` is middle C (C4). Bass C is `c` (C3) or `c,` (C2). Each apostrophe raises an octave and each comma lowers one. Keep marks attached and use one kind per pitch.
17
+ - `\relative c' { c4 e g c }` initializes the reference at C4. Each note chooses the diatonically nearest octave to the preceding pitch, then applies its octave marks as shifts. Chord tones resolve in input order. The first tone anchors the following event.
18
+ - Base durations are `1 2 4 8 16 32 64 128` with up to two dots. Notes, chords, rests (`r`) and spacers (`s`) inherit the preceding duration including dots in each voice. The score starts with quarter-note inheritance. Set the duration explicitly at voice entries and after tuplets when it changes.
19
+ - Write distinct chord pitches with one duration after `>` (`<c' e' g'>4`). Tie `c'4~ c'4` or tie only C with `<c'~ e' g'>4 <c' f' a'>4`. Match pitch spelling and octave on the next event of that voice. Slur `c'8( d' e' f')` or beam `c'8[ d' e' f']`. Close both kinds of spans without nesting. Beam at least two eighths or shorter within a bar.
20
+
21
+ ## Meter and structure
22
+
23
+ - At bar boundaries set `\clef` to `treble`, `bass`, `alto` or `tenor`. Treble and bass take optional `_8` or `^8` suffixes. Use `\key bes \major` or `\key g \minor` with no octave marks and at most seven sharps or flats. Defaults are treble, C major and 4/4.
24
+ - Use `\time N/D` with numerator 1 through 64 and denominator `1 2 4 8 16 32 64`. `\time C` is 4/4 and `\time C|` is 2/2. Keep the cut-time bar attached to C. A pickup such as `\partial 8` goes after the opening meter and before music or polyphony. Use only one per staff, shorter than a full bar. `\partial` accepts `1 2 4 8 16 32` with up to two dots. Write `\measureRest` without a duration at the start of an empty full bar, outside a pickup, free meter or a tuplet.
25
+ - Barlines are `|`, `||`, `|.`, `|:`, `:|` and `:|:`. Quoted `\bar "||"` also works. Fill measured bars exactly, using the pickup length when declared. `|:` can precede a repeat's first note. Between `\cadenzaOn` and `\cadenzaOff`, bars have free length. Close the free bar before turning measured time back on. `\break` starts a display system.
26
+ - `\tuplet N/D { ... }` scales durations by D/N. Use a nonempty body, N from 2 to 1024 and D from 1 to 1024. Avoid nested tuplets or polyphony inside tuplets. `\tempo "Label" 4=96` uses an optional quoted label, a beat unit of `1 2 4 8 16 32` with at most one dot, and integer BPM 1 through 999. Place tempo on the top staff outside polyphony, tuplets and grace blocks.
27
+ - In 4/4 write `|: c'1 | \volta 1 d'1 :| \volta 2 e'1 |.`. Start endings on the top staff outside polyphony and tuplets. Use bare integers, one or more common bars, and one or more full bars per ending. `\volta 0` can close ending 2 at the next bar start. Avoid nested repeats, signature changes in ending 1, and ties, slurs or hairpins crossing between endings.
28
+
29
+ ## Staves and voices
30
+
31
+ Use `\grandStaff { \staff { ... } \staff { ... } }` with upper staff first. Put headers inside each staff before `<< { ... } \\ { ... } >>` (two backslashes). Each of the two voices must fill the bar independently. Align bar counts, meters and pickups across staves. Fill silent voice segments with timed `s` spacers. Only in a two-staff grand staff, `\staffUp` and `\staffDown` route subsequent notes or chords to the upper or lower staff until switched again. Rhythm stays in the source voice. Beams can cross the switch.
32
+
33
+ ## Markings
34
+
35
+ - Prefix a note or chord tone with `\parenthesize`. Color a span with `\hl primary { ... }` or tag a note, chord or chord tone with `@primary`. Other roles include `leading`, `passing`, `secondary`, `pivot` and `muted`.
36
+ - Use one postfix `\ch "Cmaj7/E"` or `^\ch "Cmaj7/E"` above a note or chord. Root and optional slash bass use uppercase A through G with optional accidentals like `#` or `b`. Use no internal spaces. `_"V^6_5/V"` gives a Roman numeral below and `^"Theme"` gives a label above.
37
+ - `\deg "3"`, `^\deg "#4"` and `_\deg "b6"` label degrees 1 through 7 with optional `#`, `b` or `n`. Default placement is above. On a note or chord, start `\bracket "Label"` with optional `^` or `_`. Match it with exactly one bare `\bracketEnd` on a pitched event in the same voice, without prefix or argument. Keep one active bracket per voice. Labels must have 1 to 24 characters after trimming, with no control characters.
38
+ - Add `\trill`, `\prall`, `\mordent` or `\turn` after a pitched event. `-.`, `->`, `--`, `-^` and `\fermata` give staccato, accent, tenuto, marcato and fermata. Fingering uses `^1` or `_1` (0 through 5). `\breathe` and `\caesura` follow a note, chord or visible rest.
39
+ - Dynamics are `\ppp \pp \p \mp \mf \f \ff \fff \sf \sfz \sffff \fp`. Start a crescendo with `\<` or a diminuendo with `\>`. End it on a later event with `\!` or a compatible steady dynamic on the same side, before any repeat boundary. Avoid overlapping hairpins or `\fp` inside one.
40
+ - Put `\ottava 1` or `\ottava -1` before the affected notes and reset with `\ottava 0`. Keep these directives outside `<< >>` and grace blocks. Use a pitched-event postfix `\tremolo 8`, `16` or `32` with a subdivision finer than its written duration. Roll a chord of at least two pitches with `\arpeggio`, `\arpeggioUp` or `\arpeggioDown`.
41
+ - Attach `\sustainOn` and `\sustainOff` to notes, chords, rests or spacers at different onsets. Use `\grace { d'16 } c'4` or `\acciaccatura { d'16[ e'] } c'4`. Grace groups use notes or chords, optional beams and separate duration inheritance. Follow with a pitched host. Count only the host toward the measure.
42
+
43
+ ## Markdown and Obsidian
44
+
45
+ Use the Micro-Inline code span `notula:F#m7` or pass `F#m7` to `compileMicro`. Use `\note 4.` for a dotted note, `\rest 8` for a rest, and `\fig "6/4"` for stacked figured bass. Micro-Inline `\note` and `\rest` accept `1 2 4 8 16 32` with up to two dots. Unknown expressions may render as text. Compact-Inline uses a score code span such as `notula-compact:\clef alto \time 2/4 c'4 d' |.`.
46
+
47
+ Use a `notula` fence for display. In Obsidian the first nonblank line can start with `% notula:` and space-separated `key=value` options. Set `zoom` and `speed` from 0.5 to 2, `view=wrap` or `view=panorama`, `sound=builtin` or `sound=smplr`, `audio=on` or `audio=off`, and optionally `theme=inherit`.
48
+
49
+ The sampled piano is the default in the Playground (**Grand Piano (smplr)**) and Obsidian (**Grand piano (smplr)**). Rendering and editing make zero sample requests. Play fetches public-domain Steinway samples from `smpldsnds.github.io` when needed. Failed loads or the 2.5-second timeout trigger **Offline fallback**. Choose **Built-in Piano (Offline)** in the Playground or **Built-in synth (offline)** in Obsidian for local playback. In Obsidian, the block toolbar and `% notula: sound=builtin` can also select the offline synth. The `notula/audio` npm entry defaults to offline Web Audio synthesis with zero runtime dependencies. The sampler ships with the Playground and the Obsidian plugin.
50
+
51
+ ## High-frequency LilyPond hallucination blacklist
52
+
53
+ | Avoid | Notula syntax |
54
+ | --- | --- |
55
+ | `\version`, `\score`, `\header`, `\override` | Write the score body directly. Pass render options to the API. |
56
+ | `\new Staff`, `\new PianoStaff`, `\new Voice` | `\staff { ... }`, `\grandStaff { ... }`, `<< { ... } \\ { ... } >>` |
57
+ | `\change Staff = ...`, `\stemUp`, `\stemDown` | `\staffUp` / `\staffDown` for staff routing. `\voiceOne` / `\voiceTwo` / `\oneVoice` for stem direction. |
58
+ | `\markup`, `\times`, `\ottava #1` | `^"Label"` / `_"Label"`, `\tuplet N/D { ... }`, `\ottava 1` |
59
+ | `\ch "Dm(add9)"`, `_\ch "Dm9"` | Use `c'4\ch "Dmadd9"` above. Parenthesized alterations such as `"D7(b9)"` are valid. |
60
+ | Chord symbols on `r` or `s`. Chord symbols or pedal on barlines or headers. | Attach `\ch` to a note or chord. Attach pedal to a timed event. A spacer may carry pedal, steady dynamics or hairpins. |
61
+ | `\volta 1 { ... }`, an ordinary barline after headers, or a barline after an underfilled spacer | Use bare volta markers, reserve opening bars for repeats, and count spacers toward the bar. |
62
+
63
+ ## Golden templates
64
+
65
+ ### 1. Single-staff melody and Micro-Inline
66
+
67
+ ```notula
68
+ \clef treble \key g \major \time 3/4 \tempo "Andante" 4=96
69
+ \relative c'' { g4\p a8[( b c d]) | fis,4~ fis8[ g a b] | g2.\fermata |. }
70
+ ```
71
+
72
+ `notula:F#` `notula:Bb` `notula:F#m7` `notula:Bbmaj7/D`
73
+ `notula:\note 4.` `notula:\clef alto` `notula:\time 6/8`
74
+ `notula:\rn "V^6_5/V"` `notula:\deg "#4"` `notula:\mf`
75
+ `notula:\fermata` `notula:\trill` `notula:\breathe` `notula:\caesura`
76
+
77
+ ### 2. SATB suspension chorale
78
+
79
+ The chord combines soprano and alto over alto spacers. Soprano C ties into the dominant and resolves to B.
80
+
81
+ ```notula
82
+ \grandStaff {
83
+ \staff { \clef treble \key c \major \time 4/4
84
+ << { c''2 <g' c''~>2 | <g' c''>4 <g' b'>4 g'2 |. }
85
+ \\ { g'2 s2 | s2 e'2 |. } >>
86
+ }
87
+ \staff { \clef bass \key c \major \time 4/4
88
+ << { e2 e2 | d2 c2 |. }
89
+ \\ { c2_"I" c2 | g,2_"V" c2_"I" |. } >>
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### 3. Cross-staff piano with pedal
95
+
96
+ ```notula
97
+ \grandStaff {
98
+ \staff { \clef treble \time 2/4 e''4 s4 |. }
99
+ \staff { \clef bass \time 2/4
100
+ c8\sustainOn[ g \staffUp c' \staffDown e]\sustainOff |.
101
+ }
102
+ }
103
+ ```
104
+
105
+ ### 4. Jazz chords and scale degrees
106
+
107
+ ```notula
108
+ \clef treble \key c \major \time 4/4
109
+ e'4\ch "Cmaj7/E"^\deg "3" g'4
110
+ fis'4^\ch "D7(b9)"^\deg "#4"_\bracket "Secondary dominant" a'4 |
111
+ b'4\ch "G13"\deg "7" g'4\bracketEnd e'2\ch "Cmaj9" |.
112
+ ```
113
+
114
+ ### 5. Free-meter cadenza
115
+
116
+ ```notula
117
+ \clef treble \key a \minor \cadenzaOn
118
+ \acciaccatura { e'32[ f' gis'] } a'4\p\<
119
+ \tuplet 5/4 { b'16[ c'' d'' e'' f''] } e''4\trill |
120
+ \ottava 1 a'''8[ gis''' f''' e'''] d'''4\tremolo 32\f \ottava 0 |
121
+ b'8[ gis'] <a c' e' a'>2\arpeggio\pp\sustainOn r4\sustainOff |.
122
+ ```
123
+
124
+ ### 6. Complete Obsidian Markdown
125
+
126
+ ````markdown
127
+ The dominant is `notula:\rn "V^7"` and resolves to `notula:Cmaj7`.
128
+
129
+ ```notula
130
+ % notula: zoom=1.25 view=panorama speed=0.75 sound=builtin audio=on theme=inherit
131
+ \clef treble \key c \major \time 2/4
132
+ g'4\ch "G7" b'4 | c''2\ch "Cmaj7" |.
133
+ ```
134
+
135
+ Scale degrees in context: `notula-compact:\clef alto \time 2/4 c'4\deg "1" d'\deg "2" |.`.
136
+ ````
137
+
138
+ ## References
139
+
140
+ - [Syntax](docs/SYNTAX.md)
141
+ - [Integrations](docs/INTEGRATIONS.md)
package/package.json CHANGED
@@ -1,6 +1,96 @@
1
1
  {
2
2
  "name": "notula",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.7.0",
4
+ "description": "A TypeScript music notation engine for short scores, standalone SVG, and Web Audio playback.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/ZenithRains/notula.git"
9
+ },
10
+ "homepage": "https://github.com/ZenithRains/notula#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/ZenithRains/notula/issues"
13
+ },
14
+ "keywords": [
15
+ "music-notation",
16
+ "engraving",
17
+ "smufl",
18
+ "bravura",
19
+ "svg",
20
+ "lilypond",
21
+ "web-audio",
22
+ "markdown",
23
+ "obsidian",
24
+ "katex"
25
+ ],
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "main": "./dist-lib/index.js",
29
+ "types": "./dist-lib/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist-lib/index.d.ts",
33
+ "import": "./dist-lib/index.js"
34
+ },
35
+ "./audio": {
36
+ "types": "./dist-lib/audio/index.d.ts",
37
+ "import": "./dist-lib/audio.js"
38
+ },
39
+ "./integrations": {
40
+ "types": "./dist-lib/integrations/index.d.ts",
41
+ "import": "./dist-lib/integrations.js"
42
+ },
43
+ "./obsidian": {
44
+ "types": "./dist-lib/integrations/obsidian.d.ts",
45
+ "import": "./dist-lib/obsidian.js"
46
+ }
47
+ },
48
+ "files": [
49
+ "dist-lib",
50
+ "assets/fonts/OFL.txt",
51
+ "LICENSE",
52
+ "THIRD_PARTY_NOTICES.md",
53
+ "README.md",
54
+ "README.zh-CN.md",
55
+ "llms.txt",
56
+ "CHANGELOG.md",
57
+ "docs/SYNTAX.md",
58
+ "docs/INTEGRATIONS.md",
59
+ "docs/assets/*.svg",
60
+ "examples/obsidian-plugin/README.md"
61
+ ],
62
+ "scripts": {
63
+ "dev": "vite",
64
+ "build": "vite build",
65
+ "build:lib": "node -e \"require('node:fs').rmSync('dist-lib', { recursive: true, force: true })\" && tsc -p tsconfig.lib.json && vite build --config vite.lib.config.ts",
66
+ "build:obsidian": "node scripts/build-obsidian.mjs",
67
+ "prepack": "npm run build:lib",
68
+ "typecheck": "tsc --noEmit",
69
+ "test": "vitest run",
70
+ "test:watch": "vitest",
71
+ "metrics:extract": "node scripts/extract-smufl-metrics.mjs && node scripts/extract-smufl-paths.mjs",
72
+ "metrics:paths": "node scripts/extract-smufl-paths.mjs",
73
+ "docs:assets": "node scripts/generate-readme-assets.mjs"
74
+ },
75
+ "devDependencies": {
76
+ "@types/node": "^22.20.7",
77
+ "@types/react": "^19.3.3",
78
+ "@types/react-dom": "^19.3.0",
79
+ "happy-dom": "^21.0.4",
80
+ "markdown-it": "^15.0.3",
81
+ "obsidian": "1.14.4",
82
+ "opentype.js": "^2.0.0",
83
+ "react": "^19.3.1",
84
+ "react-dom": "^19.3.1",
85
+ "rehype-stringify": "^10.0.1",
86
+ "remark-parse": "^11.0.0",
87
+ "remark-rehype": "^11.1.2",
88
+ "smplr": "^1.2.1",
89
+ "terser": "^5.51.4",
90
+ "typescript": "^5.8.0",
91
+ "unified": "^11.0.5",
92
+ "vite": "^6.2.0",
93
+ "vitest": "^3.1.0",
94
+ "vue": "^3.5.46"
95
+ }
96
+ }