Notula renders short music examples to SVG for the web and Markdown.
Local Playground · Syntax · Integrations · llms.txt · 中文
Beethoven, Piano Sonata No. 8 in C minor, Op. 13 (Pathétique), I. Grave, mm. 1 to 4. Breitkopf & Härtel, Leipzig, 1862, p. 121
Notula DSL source
\grandStaff {
\staff {
\clef treble \key c \minor \time C
<ees g c'>4\fp~ <ees g c'>16.[ <g c' g'>32 <g b d'>16. <g c' ees'>32]
<a! c' ees'>4( <b d'>8) r8 |
<b! d' f'>4\fp~ <b d' f'>16.[ <b d' f'>32 <b d' g'>16. <b d' aes'>32]
<b d' aes'>4( <c' ees' g'>8) r8 | \break
<fis' a'! c''>4\fp~ <fis' a' c''>16.[ <fis' a' c''>32
<fis' a' d''>16. <fis' a' ees''>32]
<fis' a' ees''>4\sf( <d' g' d''>16-.) r32
<fis' a' c''>32[ <fis' a' d''>16. <fis' a' ees''>32] |
<fis' a'! ees''>4\sf\>( <d' g' d''>8\p\<[-. <g' c'' e''!>8]
<aes' c'' f''!>8[)-. aes''8\sf]\!~
aes''32[ g''64( aes'' bes'' aes'' g'' f'']
ees''!64[ d'' c'' bes']
\tuplet 9/8 { aes'128[ g' f' ees' d' f' aes' f' d']) } |
}
\staff {
\clef bass \key c \minor \time C
<c, ees, g, c>4~ <c, ees, g, c>16.[ ees32 d16. c32]
fis4( g8) r16. aes,!32 |
aes4~ aes16.[ aes32 g16. f!32] ees4~ ees8 r16. ees32 | \break
ees'4~ ees'16.[ ees'32 d'16. c'32]
c'4( b16-.) r32 ees'32[ d'16. c'32] |
c'4( b8[ <bes c' e'!>8] <aes! c' f'!>8)-. r8 <bes,, bes,>4\sf |
}
}
Once Notula is published to npm, install it in your project.
npm install notulaFor a checkout, see the local tarball installation steps.
import { renderToString } from 'notula';
import { playScore } from 'notula/audio';
const source = String.raw`\clef treble \time 3/4 c'4 e' g' | c''2. |.`;
const svg = renderToString(source);
// Call from a click or other user gesture in the browser.
playScore(source, { bpm: 96 });The npm entry notula/audio defaults to an offline Web Audio synth and has zero runtime dependencies. The npm package includes the AudioVoiceBackend interface for optional sampled instruments. Integration guide
Run these commands from a checkout and open the URL printed in the terminal.
npm ci && npm run devThe Playground defaults to Grand Piano (smplr). Rendering and editing scores make zero sample requests. Pressing Play fetches public-domain Steinway samples from smpldsnds.github.io when needed. If loading fails or reaches the 2.5-second timeout, playback switches automatically to the built-in synth and shows Offline fallback. Select Built-in Piano (Offline) in the sound menu for immediate local playback.
With Node.js 22.18 or later, run npm run docs:assets after npm run build:lib to regenerate the logo and previews.
The Obsidian plugin defaults to Grand piano (smplr). It fetches samples only on Play and falls back to the offline synth if loading fails or reaches the 2.5-second timeout. Choose Built-in synth (offline) under Sound source, select Synth in a block toolbar, or add % notula: sound=builtin to a block for local playback. The toolbar’s Export image menu offers Copy PNG, Save PNG (2×), and Save SVG. Plugin guide and network disclosure
Rachmaninoff, Prelude in C-sharp minor, Op. 3 No. 2, first four bars of Tempo primo. 2-staff piano reduction of the four-staff original, with editorial pedal cues. A. Gutheil, Moscow, 1893 edition, later printing, pp. 4 and 5
Notula DSL source
\grandStaff {
\staff {
\clef treble \key cis \minor \time C
<< {
r8 <cis'' e'' gis'' cis'''>8\fff[-> <e'' gis'' b'' e'''>->
<dis'' fisis'' ais'' dis'''>]-> r8 <d'' fis'' bis'' d'''>8-> r8 <bis' dis'' fis'' bis''!>8-> |
r8 <cis'' e'' gis'' cis'''>8\sffff[-> <e'' gis'' b'' e'''>->
<dis'' fisis'' ais'' dis'''>]-> r8 <d'' fis'' bis'' d'''>8-> r8 <bis' dis'' fis'' bis''!>8-> | \break
r8 <cis'' e'' gis'' cis'''>8[-> <gis'' cis''' gis'''>-> <fis'' cis''' fis'''>]->
r8 <e'' fis'' a'' e'''>8-> r8 <dis'' fis'' a'' dis'''>8-> |
r8 <e'' gis'' b'' e'''>8[-> <b'' e''' b'''>-> <a'' e''' a'''>]->
r8 <gis'' ais'' cis''' gis'''>8-> r8 <fisis'' ais'' cis''' fisis'''>8-> |
} \\ {
<cis e gis cis'>2-> <a! a'!>4-> <gis gis'>4-> |
<cis e gis cis'>2-> <a! a'!>4-> <gis gis'>4-> |
<cis e gis cis'>2-> <c' c''>4-> <b b'>4-> |
<e gis b e'>2-> <e' e''>4-> <dis' dis''>4-> |
} >>
}
\staff {
\clef bass \key cis \minor \time C
<< {
r8 <e gis cis' e'>8[-> <gis b e' gis'>-> <fisis ais dis' fisis'>]->\sustainOff
r8 <fis bis d' fis'>8-> r8 <dis fis bis! dis'>8-> |
r8 <e gis cis' e'>8[-> <gis b e' gis'>-> <fisis ais dis' fisis'>]->\sustainOff
r8 <fis bis d' fis'>8-> r8 <dis fis bis! dis'>8-> | \break
r8 <e gis cis' e'>8[-> <b cis' gis' b'>-> <a cis' fis' a'>]->\sustainOff
r8 <fis a e' fis'>8-> r8 <fis a dis' fis'>8-> |
r8 <gis b e' gis'>8[-> <dis'! e' b' dis''!>-> <cis' e' a' cis''>]->\sustainOff
r8 <ais cis' gis' ais'>8-> r8 <ais cis' fisis' ais'>8-> |
} \\ {
<cis,, e,, gis,, cis,>2->\sustainOn <a,,! a,!>4-> <gis,, gis,>4-> |
<cis,, e,, gis,, cis,>2->\sustainOn <a,,! a,!>4-> <gis,, gis,>4-> |
<cis,, e,, gis,, cis,>2->\sustainOn <c, c>4-> <b,, b,>4-> |
<e,, gis,, b,, e,>2->\sustainOn <e, e>4-> <dis, dis>4-> |
} >>
}
}
Liszt, Liebestraum No. 3 in A-flat major, S. 541, first cadenza. Cross-staff engraving with editorial pedal cues. Fr. Kistner, Leipzig, 1850, p. 18
Notula DSL source
\grandStaff {
\staff {
\clef treble \key aes \major \cadenzaOn
s2. | r16 s8.
<fes' aes'>8[ <ees' g'> <aes' des''> <g' bes'>
<des'' fes''>\< <bes' ees''> <fes'' aes''> <ees'' g''> <aes'' des'''> <g'' bes''>
\ottava 1 <des''' fes'''> <bes'' ees'''> <fes''' aes'''> <ees''' g'''>\!
<aes''' des''''> <g''' bes'''>
<des'''' fes''''>( <bes''' ees''''> <des'''' fes''''> <bes''' ees''''> <aes''' des''''> <g''' bes'''>)
<fes''' aes'''>( <ees''' g'''> <fes''' aes'''> <ees''' g'''> <des''' fes'''> <bes'' ees'''>)] \ottava 0
| \break
<aes'' des'''>8[( <g'' bes''> <aes'' des'''> <g'' bes''> <fes''! aes''> <ees'' g''>)
<des'' fes''>( <bes' ees''> <des'' fes''> <bes' ees''> <aes' des''> <g' bes'>)]
<aes' des''>8\<[ <g' bes'> <aes' des''> <g' bes'> <aes' des''> <g' bes'>
<aes' des''> <g' bes'> <aes' des''> <g' bes'> <aes' des''> <g' bes'>]\!
<aes' des''>8\>[ <g' bes'> <aes' des''> <g' bes'> <aes' des''> <g' bes'>
<aes' des''> <g' bes'> <aes' des''> <g' bes'> <aes' des''> <g' bes'>]\!
r16 r16\fermata d''!4 ||
}
\staff {
\clef bass \key aes \major \cadenzaOn
ees,8\p[( bes, des g \staffUp bes des'] \staffDown |
\clef treble fes'8[ ees')] r16 s8.
fes'8[ ees' aes' g' des'' bes' fes'' ees'' aes'' g'' des''' bes'' fes''' ees'''
\ottava 1 aes'''( g''' aes''' g''' fes''' ees''') des'''( bes'' des''' bes'' aes'' g'')] \ottava 0
| \break
fes''!8[( ees'' fes'' ees'' des'' bes') aes'( g' aes' g' fes' ees')]
fes'8\sustainOn[ ees' fes' ees' fes' ees' fes' ees' fes' ees' fes' ees'8\sustainOff]
fes'8\sustainOn[ ees' fes' ees' fes' ees' fes' ees' fes' ees' fes' ees']
r2.\sustainOff ||
}
}
Four pure stages parse the DSL into an AST, resolve it into Music IR, lay it out as a LayoutTree, and emit SVG or mount it in the DOM. Web Audio derives its playback timeline from Music IR. The layout uses staff spaces (sp), with positive coordinates pointing up from the middle staff line at y = 0. The same geometry supports standalone SVG music glyphs as <path> elements and DOM mounting with createElementNS without innerHTML.
Engraving references include Elaine Gould’s Behind Bars, Ted Ross’s The Art of Music Engraving and Processing, and Gardner Read’s Music Notation. Nonlinear duration spacing draws on John S. Gourlay’s Spacing a Line of Music (1987, OSU-CISRC-10/87-TR35). The scripts in scripts/ reproduce the extraction of glyph metrics and outlines from the W3C Music Notation Community Group’s SMuFL data and Steinberg Bravura 1.482, licensed under SIL OFL 1.1. SMuFL 1.4 · Bravura 1.482 · Third-party notices
Notula is an independent, clean-room implementation released under MIT. The 16 Markdown files in spec/ set out engraving rules and review criteria. Tests check geometric invariants and run deterministic fuzzing and a repertoire suite that includes an original Bach-style chorale.
Notula is designed for web, Markdown, and teaching examples, from one inline symbol to roughly 16 bars with responsive wrapping. Multi-page publishing and part extraction are outside its scope.
Source code is licensed under MIT; bundled Bravura glyph metrics and outlines are licensed under SIL OFL 1.1 (see THIRD_PARTY_NOTICES.md and assets/fonts/OFL.txt). While in 0.x, minor releases (0.x.0) may refine public API defaults or exports; the core music DSL remains backward-compatible unless noted in CHANGELOG.md.