notula 0.0.0-stage → 0.8.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.
- package/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +214 -2
- package/README.zh-CN.md +216 -0
- package/THIRD_PARTY_NOTICES.md +50 -0
- package/assets/fonts/OFL.txt +94 -0
- package/dist-lib/analyze-DJ6p6BkU.js +2 -0
- package/dist-lib/analyze-DJ6p6BkU.js.map +1 -0
- package/dist-lib/audio/browser-fetch.d.ts +2 -0
- package/dist-lib/audio/felt-piano.d.ts +8 -0
- package/dist-lib/audio/highlight.d.ts +14 -0
- package/dist-lib/audio/index.d.ts +10 -0
- package/dist-lib/audio/player.d.ts +70 -0
- package/dist-lib/audio/sampled-piano.d.ts +31 -0
- package/dist-lib/audio/timeline.d.ts +45 -0
- package/dist-lib/audio.js +2 -0
- package/dist-lib/audio.js.map +1 -0
- package/dist-lib/core/color.d.ts +1 -0
- package/dist-lib/core/number.d.ts +2 -0
- package/dist-lib/core/rational.d.ts +20 -0
- package/dist-lib/core/text.d.ts +1 -0
- package/dist-lib/dsl/ast.d.ts +295 -0
- package/dist-lib/dsl/lexer.d.ts +115 -0
- package/dist-lib/dsl/parser.d.ts +7 -0
- package/dist-lib/highlight-B88FnJNW.js +2 -0
- package/dist-lib/highlight-B88FnJNW.js.map +1 -0
- package/dist-lib/index-D4SDrvs8.js +2 -0
- package/dist-lib/index-D4SDrvs8.js.map +1 -0
- package/dist-lib/index.d.ts +16 -0
- package/dist-lib/index.js +2 -0
- package/dist-lib/index.js.map +1 -0
- package/dist-lib/integrations/index.d.ts +1 -0
- package/dist-lib/integrations/markdown-dom.d.ts +8 -0
- package/dist-lib/integrations/markdown.d.ts +45 -0
- package/dist-lib/integrations/obsidian-child.d.ts +16 -0
- package/dist-lib/integrations/obsidian-playback.d.ts +19 -0
- package/dist-lib/integrations/obsidian.d.ts +86 -0
- package/dist-lib/integrations/panorama-scroll.d.ts +7 -0
- package/dist-lib/integrations/resize.d.ts +6 -0
- package/dist-lib/integrations.js +2 -0
- package/dist-lib/integrations.js.map +1 -0
- package/dist-lib/ir/analyze.d.ts +13 -0
- package/dist-lib/ir/types.d.ts +263 -0
- package/dist-lib/layout/accidentals.d.ts +20 -0
- package/dist-lib/layout/annotations.d.ts +163 -0
- package/dist-lib/layout/articulations.d.ts +93 -0
- package/dist-lib/layout/beaming.d.ts +92 -0
- package/dist-lib/layout/grace.d.ts +33 -0
- package/dist-lib/layout/layout.d.ts +3 -0
- package/dist-lib/layout/polyphony.d.ts +20 -0
- package/dist-lib/layout/spacing.d.ts +38 -0
- package/dist-lib/layout/staff.d.ts +60 -0
- package/dist-lib/layout/stems-chords.d.ts +59 -0
- package/dist-lib/layout/systems.d.ts +31 -0
- package/dist-lib/layout/ties-slurs.d.ts +59 -0
- package/dist-lib/layout/tuplets.d.ts +25 -0
- package/dist-lib/layout/types.d.ts +210 -0
- package/dist-lib/metrics/bravura-glyph-paths.d.ts +9 -0
- package/dist-lib/metrics/bravura-metrics.d.ts +52 -0
- package/dist-lib/micro/micro.d.ts +33 -0
- package/dist-lib/obsidian.js +2 -0
- package/dist-lib/obsidian.js.map +1 -0
- package/dist-lib/render.d.ts +20 -0
- package/dist-lib/shared.d.ts +8 -0
- package/dist-lib/svg/dom.d.ts +4 -0
- package/dist-lib/svg/emitter.d.ts +56 -0
- package/docs/INTEGRATIONS.md +200 -0
- package/docs/SYNTAX.md +74 -0
- package/docs/assets/cadenza-dark.svg +497 -0
- package/docs/assets/cadenza-light.svg +497 -0
- package/docs/assets/chords-dark.svg +695 -0
- package/docs/assets/chords-light.svg +695 -0
- package/docs/assets/hero-dark.svg +498 -0
- package/docs/assets/hero-light.svg +498 -0
- package/docs/assets/logo-dark.svg +12 -0
- package/docs/assets/logo-light.svg +12 -0
- package/docs/assets/wordmark-dark.svg +41 -0
- package/docs/assets/wordmark-light.svg +41 -0
- package/examples/obsidian-plugin/README.md +43 -0
- package/llms.txt +141 -0
- package/package.json +94 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { sanitizeXmlChars } from '../core/text.js';
|
|
2
|
+
import { type GlyphPathMap } from '../metrics/bravura-glyph-paths.js';
|
|
3
|
+
import { type SmuflMetrics } from '../metrics/bravura-metrics.js';
|
|
4
|
+
import type { GlyphBox, LayoutTree, LineShape, PolygonShape, TextBox } from '../layout/types.js';
|
|
5
|
+
export interface SvgEmitOptions {
|
|
6
|
+
readonly pxPerSp?: number;
|
|
7
|
+
readonly sizeUnit?: 'px' | 'em';
|
|
8
|
+
readonly emPerSp?: number;
|
|
9
|
+
readonly paddingX?: number;
|
|
10
|
+
readonly paddingY?: number;
|
|
11
|
+
readonly debug?: boolean;
|
|
12
|
+
readonly inline?: boolean;
|
|
13
|
+
/** Emit music glyphs as font-independent SVG paths. Defaults to true. */
|
|
14
|
+
readonly standalone?: boolean;
|
|
15
|
+
readonly glyphPaths?: GlyphPathMap;
|
|
16
|
+
readonly color?: string;
|
|
17
|
+
readonly metrics?: SmuflMetrics;
|
|
18
|
+
}
|
|
19
|
+
export type HastPropertyValue = string | number | boolean | (string | number)[] | null | undefined;
|
|
20
|
+
export interface HastTextNode {
|
|
21
|
+
readonly type: 'text';
|
|
22
|
+
readonly value: string;
|
|
23
|
+
}
|
|
24
|
+
export interface HastElementNode {
|
|
25
|
+
readonly type: 'element';
|
|
26
|
+
readonly tagName: string;
|
|
27
|
+
readonly properties: Record<string, HastPropertyValue>;
|
|
28
|
+
readonly children: (HastElementNode | HastTextNode)[];
|
|
29
|
+
}
|
|
30
|
+
export interface HastNode {
|
|
31
|
+
type: string;
|
|
32
|
+
tagName?: string;
|
|
33
|
+
value?: string;
|
|
34
|
+
properties?: Record<string, unknown>;
|
|
35
|
+
children?: HastNode[];
|
|
36
|
+
data?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface SvgElementNode {
|
|
39
|
+
readonly tagName: string;
|
|
40
|
+
readonly attrs: Record<string, string>;
|
|
41
|
+
readonly children: readonly (SvgElementNode | string)[];
|
|
42
|
+
}
|
|
43
|
+
export declare function fmtSvgNumber(n: number): string;
|
|
44
|
+
export declare function sanitizeFinite(val: number | undefined, fallback: number, min: number, max: number): number;
|
|
45
|
+
export { sanitizeXmlChars };
|
|
46
|
+
export declare function escapeXml(str: string): string;
|
|
47
|
+
export declare function serializeSvgNode(node: SvgElementNode, indent?: number): string;
|
|
48
|
+
export declare function svgNodeToHast(node: SvgElementNode): HastElementNode;
|
|
49
|
+
export declare function buildSvgGlyphNode(item: GlyphBox, gx: number, gy: number, pxPerSp: number, standalone: boolean, metrics: SmuflMetrics, pathMap: GlyphPathMap, includeEventId?: boolean): SvgElementNode;
|
|
50
|
+
export declare function buildSvgPolygonNode(item: PolygonShape, toSvgX: (x: number) => number, toSvgY: (y: number) => number): SvgElementNode;
|
|
51
|
+
export declare function buildSvgRectLineNode(item: LineShape, x: number, y: number, width: number, height: number, includeEventId?: boolean): SvgElementNode;
|
|
52
|
+
export declare function getTextFontFamily(standalone: boolean): string;
|
|
53
|
+
export declare function buildSvgTextNode(item: TextBox, x: number, y: number, pxPerSp: number, textFontFamily: string, includeAlignment?: boolean): SvgElementNode;
|
|
54
|
+
export declare function emitSvgTree(tree: LayoutTree, options?: SvgEmitOptions): SvgElementNode;
|
|
55
|
+
export declare function emitSvg(tree: LayoutTree, options?: SvgEmitOptions): string;
|
|
56
|
+
export declare function emitSvgHast(tree: LayoutTree, options?: SvgEmitOptions): HastElementNode;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Integrate Notula into a site or vault
|
|
2
|
+
|
|
3
|
+
Once Notula is published to npm, install it with `npm install notula`. To install from a checkout, run `npm ci` and `npm pack` in the Notula repository. Copy the tarball to your app and run `npm install ./notula-<version>.tgz`, replacing `<version>` with the version in the generated filename.
|
|
4
|
+
|
|
5
|
+
The package entry points are `notula` for rendering, `notula/integrations` for Markdown and DOM adapters, `notula/audio` for playback, and `notula/obsidian` for the Obsidian adapter.
|
|
6
|
+
|
|
7
|
+
## Static HTML and inline SVG
|
|
8
|
+
|
|
9
|
+
Save this as `score-assets.ts` and run `node score-assets.ts` with Node.js 22.18 or later to produce two SVG files alongside the script. Paste their contents into an HTML template at build time or reference the files with `<img>`. The default, `standalone: true`, embeds music glyphs as SVG `<path>` elements. Pass `{ standalone: false }` to use Bravura font `<text>` elements and load Bravura in the host. Free-form text annotations can still use ordinary text fonts.
|
|
10
|
+
|
|
11
|
+
```ts score-assets.ts
|
|
12
|
+
import { writeFileSync } from 'node:fs';
|
|
13
|
+
import { URL } from 'node:url';
|
|
14
|
+
import { compileMicro, renderToString } from 'notula';
|
|
15
|
+
|
|
16
|
+
const source = String.raw`\clef treble \time 3/4 c'4 e' g' | c''2. |.`;
|
|
17
|
+
writeFileSync(new URL('./score.svg', import.meta.url), renderToString(source, { standalone: true }));
|
|
18
|
+
writeFileSync(new URL('./note.svg', import.meta.url), compileMicro(String.raw`\note 4.`, { standalone: true }).svg);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For a dynamic score, place `<div id="score"></div>` on the page and run this module from your site's browser bundle. `render` creates SVG DOM nodes and replaces the host's contents on each call.
|
|
22
|
+
|
|
23
|
+
```ts mount-score.ts
|
|
24
|
+
import { render } from 'notula';
|
|
25
|
+
|
|
26
|
+
const host = document.getElementById('score');
|
|
27
|
+
if (host) render(String.raw`\time 2/4 c'4 d' | e'2 |.`, host, { standalone: true });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## VitePress and markdown-it
|
|
31
|
+
|
|
32
|
+
In VitePress, add this to `.vitepress/config.ts`, or merge `markdown` into your existing config. In a plain markdown-it project, call `md.use(notulaMarkdownItPlugin)` on your MarkdownIt instance.
|
|
33
|
+
|
|
34
|
+
```ts vitepress-config.ts
|
|
35
|
+
import { notulaMarkdownItPlugin } from 'notula/integrations';
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
markdown: {
|
|
39
|
+
config: notulaMarkdownItPlugin,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use a `notula` fence for a score block, `notula:` for a single inline symbol, or `notula-compact:` for a short inline staff.
|
|
45
|
+
|
|
46
|
+
````markdown
|
|
47
|
+
A secondary dominant is `notula:\rn "V/V"`.
|
|
48
|
+
|
|
49
|
+
```notula display maxWidth=56
|
|
50
|
+
\clef treble \time 2/4 c'4 e' | d'4 g' | c''2 |.
|
|
51
|
+
```
|
|
52
|
+
````
|
|
53
|
+
|
|
54
|
+
## Astro, Next.js, and unified
|
|
55
|
+
|
|
56
|
+
For Astro's unified Markdown processor, use this in `astro.config.mjs`. Exclude `notula` from syntax highlighting so the score fence reaches the rehype plugin intact. [Astro unified processor](https://docs.astro.build/en/reference/markdown-processors/unified/)
|
|
57
|
+
|
|
58
|
+
```js astro.config.mjs
|
|
59
|
+
import { defineConfig } from 'astro/config';
|
|
60
|
+
import { unified } from '@astrojs/markdown-remark';
|
|
61
|
+
import { createRehypeNotulaPlugin } from 'notula/integrations';
|
|
62
|
+
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
markdown: {
|
|
65
|
+
syntaxHighlight: { type: 'shiki', excludeLangs: ['notula'] },
|
|
66
|
+
processor: unified({
|
|
67
|
+
rehypePlugins: [createRehypeNotulaPlugin({ standalone: true })],
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
In a Next.js app with `@next/mdx` and `mdx-components` set up, register the same plugin in `next.config.mjs`. Build with `next build --webpack` for this function-based configuration. [Next.js MDX guide](https://nextjs.org/docs/app/guides/mdx)
|
|
74
|
+
|
|
75
|
+
```js next.config.mjs
|
|
76
|
+
import createMDX from '@next/mdx';
|
|
77
|
+
import { createRehypeNotulaPlugin } from 'notula/integrations';
|
|
78
|
+
|
|
79
|
+
const withMDX = createMDX({
|
|
80
|
+
options: { rehypePlugins: [createRehypeNotulaPlugin({ standalone: true })] },
|
|
81
|
+
});
|
|
82
|
+
export default withMDX({ pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mdx'] });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For a separate Markdown build, including a Next.js app using Turbopack, install `unified remark-parse remark-rehype rehype-stringify` and use this module.
|
|
86
|
+
|
|
87
|
+
```ts markdown-to-html.ts
|
|
88
|
+
import { unified } from 'unified';
|
|
89
|
+
import remarkParse from 'remark-parse';
|
|
90
|
+
import remarkRehype from 'remark-rehype';
|
|
91
|
+
import rehypeStringify from 'rehype-stringify';
|
|
92
|
+
import { renderToHast } from 'notula';
|
|
93
|
+
import { createRehypeNotulaPlugin } from 'notula/integrations';
|
|
94
|
+
|
|
95
|
+
const processor = unified()
|
|
96
|
+
.use(remarkParse)
|
|
97
|
+
.use(remarkRehype)
|
|
98
|
+
.use(createRehypeNotulaPlugin({ standalone: true }))
|
|
99
|
+
.use(rehypeStringify);
|
|
100
|
+
|
|
101
|
+
export async function markdownToHtml(markdown: string) {
|
|
102
|
+
return String(await processor.process(markdown));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function scoreToHtml(source: string) {
|
|
106
|
+
const score = renderToHast(source, { standalone: true });
|
|
107
|
+
return processor.stringify({ type: 'root', children: [score] });
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For container-driven wrapping, keep the original code blocks in that part of the page and mount them on the client. Give the Markdown container the ID `article`. The helper replaces `pre > code.language-notula` blocks and recognized inline code. It observes the layout width when `ResizeObserver` is available. Omit `maxWidthSp` so the measured width controls wrapping.
|
|
112
|
+
|
|
113
|
+
```ts responsive-article.ts
|
|
114
|
+
import { renderNotulaInElement } from 'notula/integrations';
|
|
115
|
+
|
|
116
|
+
export function mountArticle(article: HTMLElement) {
|
|
117
|
+
const handle = renderNotulaInElement(article, { standalone: true, autoResize: true });
|
|
118
|
+
return () => handle.destroy();
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Call `mountArticle` with the container after it mounts and call the returned cleanup function when leaving the page. Build-time SVG is already rendered, so use this path on the original code elements when you need client reflow.
|
|
123
|
+
|
|
124
|
+
## React and Vue
|
|
125
|
+
|
|
126
|
+
Give Notula an empty host element whose contents it can own. In Next.js, the React example can be used directly as a Client Component.
|
|
127
|
+
|
|
128
|
+
```tsx Score.tsx
|
|
129
|
+
'use client';
|
|
130
|
+
|
|
131
|
+
import { useEffect, useRef } from 'react';
|
|
132
|
+
import { render } from 'notula';
|
|
133
|
+
|
|
134
|
+
export function Score({ source }: { source: string }) {
|
|
135
|
+
const host = useRef<HTMLDivElement>(null);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (host.current) render(source, host.current, { standalone: true });
|
|
138
|
+
}, [source]);
|
|
139
|
+
return <div ref={host} />;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```ts VueScore.ts
|
|
144
|
+
import { defineComponent, h, onMounted, ref, watch } from 'vue';
|
|
145
|
+
import { render } from 'notula';
|
|
146
|
+
|
|
147
|
+
export const VueScore = defineComponent({
|
|
148
|
+
props: { source: { type: String, required: true } },
|
|
149
|
+
setup(props) {
|
|
150
|
+
const host = ref<HTMLDivElement | null>(null);
|
|
151
|
+
const draw = () => {
|
|
152
|
+
if (host.value) render(props.source, host.value, { standalone: true });
|
|
153
|
+
};
|
|
154
|
+
onMounted(draw);
|
|
155
|
+
watch(() => props.source, draw);
|
|
156
|
+
return () => h('div', { ref: host });
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
For server rendering into a HAST pipeline, `renderToHast` returns an SVG element tree. See `scoreToHtml` above for a direct serialization example.
|
|
162
|
+
|
|
163
|
+
## Obsidian
|
|
164
|
+
|
|
165
|
+
Add a fenced `notula` block to a note. Use `% notula: zoom=1.25 view=panorama speed=0.75 audio=on sound=builtin theme=inherit` as its first non-empty line to override the vault defaults. Choose `sound=builtin` for the offline synth or `sound=smplr` for the sampled grand piano. Use the `</>` toolbar toggle to switch between source and score. Panorama keeps the music on one scrollable system and follows the active notes during playback.
|
|
166
|
+
|
|
167
|
+
Open **Export image** in the score toolbar for **Copy PNG**, **Save PNG (2×)**, and **Save SVG**. Set **Export theme**, default zoom, view, and playback options in **Settings → Notula Music Scores**. [Installation and plugin controls](../examples/obsidian-plugin/README.md)
|
|
168
|
+
|
|
169
|
+
## Optional sampled piano
|
|
170
|
+
|
|
171
|
+
Importing `notula` and rendering SVG are 100% offline with zero network requests. `notula/audio` ships a zero-dependency on-demand sampled grand piano (`sound: 'grand'`, default) that fetches only the public-domain Steinway samples needed for the current score from `smpldsnds.github.io` when `play()` is called, falling back silently to the built-in offline Felt Piano synth on network/CSP failure or after 2.5 seconds (with a 60-second circuit breaker). Pass `{ sound: 'felt' }` for 100% offline playback, `{ sampleBaseUrl }` to point at a self-hosted mirror, or `{ sampleFetcher }` for non-Fetch transports (such as Obsidian's `requestUrl`). You can still pass a custom `AudioVoiceBackend` (for example, `smplr`) via `{ backend }` to bypass the built-in sampler completely. [smplr piano documentation](https://github.com/danigb/smplr#splendidgrandpiano)
|
|
172
|
+
|
|
173
|
+
```ts sampled-piano.ts
|
|
174
|
+
import { NotulaPlayer, type AudioPlayerOptions, type AudioVoiceBackend } from 'notula/audio';
|
|
175
|
+
import { SplendidGrandPiano } from 'smplr';
|
|
176
|
+
|
|
177
|
+
export async function playSampledScore(ctx: AudioContext, source: string) {
|
|
178
|
+
await ctx.resume();
|
|
179
|
+
const output = ctx.createGain();
|
|
180
|
+
const piano = SplendidGrandPiano(ctx, { destination: output });
|
|
181
|
+
try {
|
|
182
|
+
await piano.ready;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
piano.dispose();
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const backend: AudioVoiceBackend = { sharedOutput: true,
|
|
189
|
+
noteOn(_ctx, dest, note) { output.connect(dest); piano.start({ note: note.midi,
|
|
190
|
+
time: note.startTime, duration: note.durationSec, velocity: Math.round(note.velocity * 127) }); },
|
|
191
|
+
stopAll() { piano.stop(); output.disconnect(); },
|
|
192
|
+
dispose() { piano.dispose(); } };
|
|
193
|
+
const options: AudioPlayerOptions = { backend };
|
|
194
|
+
const player = new NotulaPlayer(ctx);
|
|
195
|
+
player.play(source, options);
|
|
196
|
+
return player;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Call `playSampledScore` from a click handler with an `AudioContext` created or reused by the app. Retain the returned player to stop playback. Call `player.dispose()` when leaving the page and close the app-owned context when it is no longer needed.
|
package/docs/SYNTAX.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Notula syntax
|
|
2
|
+
|
|
3
|
+
Enter a short score in the [local Playground](../README.md#local-playground) (`npm ci && npm run dev`) or pass it to `renderToString`. A percent sign starts a comment that lasts to the end of the line.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
\clef treble \key g \major \time 3/4
|
|
7
|
+
\relative c'' { d4 g,8( a b c) | d4 g,4 g4 | g2. |. }
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Pitch and rhythm
|
|
11
|
+
|
|
12
|
+
| Syntax | Meaning |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `c d e f g a b` | Letter names. `c` is C3, `c'` is middle C, and `c,` is C2. Add apostrophes or commas to change octaves. |
|
|
15
|
+
| `fis`, `ees`, `bes` | F sharp, E flat, and B flat. Use `is` for sharp, `es` for flat, `isis` for double sharp (`fisis`), and `eses` for double flat (`beses`). Spell the pitch you want to hear, including alterations supplied by the key signature. |
|
|
16
|
+
| `fis'!`, `fis'?` | Force an accidental or request a parenthesized courtesy accidental. |
|
|
17
|
+
| `\relative c' { c4 e g c }` | Choose the nearest diatonic octave as the phrase proceeds. Add apostrophes or commas for octave shifts. |
|
|
18
|
+
| `\clef treble`, `\key c \minor`, `\time 6/8` | Set the clef, key, and time signature. `\time C` and `\time C\|` give common and cut time. |
|
|
19
|
+
| `c'4 d' e'8.` | A quarter note, an inherited quarter note, and a dotted eighth note. Base durations are `1 2 4 8 16 32 64 128` with up to two dots. |
|
|
20
|
+
| `<c' e' g'>4 r4 s4` | A chord, a visible rest, and a silent spacer. Use `\measureRest` for a whole-measure rest. |
|
|
21
|
+
| `\tuplet 3/2 { c'8 d' e' }` | Three notes in the time of two. Use `[` and `]` on notes to specify a beam group. |
|
|
22
|
+
| `\partial 8`, `\cadenzaOn` | Set a pickup length or begin a free-meter passage. Pickup base durations are `1 2 4 8 16 32` with up to two dots. `\cadenzaOff` returns to measured time. |
|
|
23
|
+
|
|
24
|
+
## Voices and staves
|
|
25
|
+
|
|
26
|
+
Use `<< { ... } \\ { ... } >>` for two simultaneous voices in one staff. Use `\grandStaff` with two `\staff` blocks for piano notation. Within a grand staff, `\staffUp` and `\staffDown` move subsequent notes and chords to the specified staff, including notes within a beam.
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
\grandStaff {
|
|
30
|
+
\staff { \clef treble \time 2/4 s2 |. }
|
|
31
|
+
\staff {
|
|
32
|
+
\clef bass \time 2/4
|
|
33
|
+
<< { c8[ g \staffUp c' e'] |. } \\ { c,2 |. } >>
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Expression and form
|
|
39
|
+
|
|
40
|
+
| Syntax | Meaning |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `c'8( d' e' f')`, `g'4~ g'8` | Slur a phrase or tie repeated pitches. |
|
|
43
|
+
| `c'4-.`, `c'4->`, `c'4--`, `c'4-^`, `c'4\fermata` | Staccato, accent, tenuto, marcato, and fermata. |
|
|
44
|
+
| `c'4\p\< d' e'\f`, `e'4\> d' c'\!` | Add dynamics and hairpins. Close a hairpin with `\!` or a compatible steady dynamic. Dynamics are `\ppp \pp \p \mp \mf \f \ff \fff \sf \sfz \sffff \fp`. |
|
|
45
|
+
| `\tempo "Andante" 4 = 84`, `c'4\breathe`, `c'4\caesura` | Set tempo or mark a break in the phrase. Tempo beat units are `1 2 4 8 16 32` with at most one dot. |
|
|
46
|
+
| `c'4\trill`, `\prall`, `\mordent`, `\turn` | Add an ornament after a note. Use `\grace { d'16 }` or `\acciaccatura { d'16 }` before its main note. |
|
|
47
|
+
| `c'4\sustainOn d'4\sustainOff` | Press and release the damper pedal. |
|
|
48
|
+
| `\ottava 1`, `\ottava -1`, `\ottava 0` | Start an octave-up or octave-down bracket, or end it. |
|
|
49
|
+
| `c'4\tremolo 16`, `<c' e' g'>4\arpeggioUp` | Add a stem tremolo (`8`, `16`, or `32`) or a rolled chord (`\arpeggio`, `\arpeggioUp`, or `\arpeggioDown`). |
|
|
50
|
+
| `\|`, `\|\|`, `\|.`, `\|:`, `:\|`, `:\|:` | Ordinary, double, final, and repeat barlines. Use `\volta 1` and `\volta 2` for alternate endings. |
|
|
51
|
+
| `\break` | Begin another system in display mode. |
|
|
52
|
+
|
|
53
|
+
## Teaching marks
|
|
54
|
+
|
|
55
|
+
| Syntax | Meaning |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `\hl primary { c'4 d' }` | Color a passage using a named role from the highlight palette. |
|
|
58
|
+
| `c'4\ch "Bbmaj7/D"` | Place a lead-sheet or slash chord symbol above the staff. |
|
|
59
|
+
| `g'4_"V^6_5/V"`, `g'4^"Dominant"` | Place a Roman numeral with inversion figures below the staff, or a text label above it. |
|
|
60
|
+
| `fis'4^\deg "#4"`, `ees'4_\deg "b3"` | Label a scale degree above or below the staff. |
|
|
61
|
+
| `c'4_\bracket "Cadence" d' e'\bracketEnd` | Mark a span with a labeled bracket. Omit the underscore for a bracket above the staff. |
|
|
62
|
+
| `\parenthesize c'4`, `<\parenthesize c' e' g'>4` | Parenthesize an editorial notehead or an individual chord tone. |
|
|
63
|
+
|
|
64
|
+
## Embedding modes
|
|
65
|
+
|
|
66
|
+
| Mode | Use |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `display` | A score block. Set `maxWidth` in staff spaces (`sp`) for automatic system wrapping. The Playground's Panorama control shows the score as a scrollable single system. |
|
|
69
|
+
| `compact` | A staff fragment in running text. Use `sizeUnit: 'em'` to size it with surrounding text. |
|
|
70
|
+
| `micro` | One symbol or theory expression, such as `F#m7`, `\note 4.`, `\rest 8`, `\rn "V^6_5/V"`, `\fig "6/4"`, or `\deg{#4}`. The `\note` and `\rest` commands accept `1 2 4 8 16 32` with up to two dots. |
|
|
71
|
+
|
|
72
|
+
The default, `standalone: true`, embeds music glyph outlines as SVG `<path>` elements. Use `standalone: false` to render music glyphs as Bravura font `<text>` elements and load Bravura in the host. Text annotations can still use text fonts. The README previews use music glyph outlines throughout.
|
|
73
|
+
|
|
74
|
+
Notula supports up to two voices per staff. It is designed for short examples in a single SVG, with system wrapping in display mode. See [Integrations](INTEGRATIONS.md) for embedding in websites and notes.
|