# neumaRk — Full specification (v0.6.0) > Complete specification of the neumaRk language (version 0.6.0), concatenated into a single AI-readable file. Source: https://neumark.dev/ ## Contents - neumaRk - Overview - Formal specification - Header - Datapack - Notes and Durations - Chords - Second voice per staff - Grace notes (appoggiaturas and acciaccaturas) - Articulations (`A)` line) - Dynamics and text annotations - Lyrics (`L)` line) - Text markup - Markers - Flow, Measures, and Repeats - PLAY) and FORM) - Play directive - Song versions - Collections (book / playlist) - Formats - Official Changelog # neumaRk **A textual language for music, human-readable and machine-interpretable.** neumaRk is a textual way of writing music — clear for people and precise for computers. It sits between traditional music notation and modern digital workflows, making music easy to write, share, analyze, transform, and version. It is designed to be written **directly from the keyboard**, with no mouse and no graphical palettes, and is optimized for **lead sheets**, musical sketches, and harmonic structures — content with one or a few voices, chords, and structure. It is not intended for large orchestral scores, nor to replace traditional notation: it is a complementary foundation, focused on musical **meaning** rather than graphical rendering. If you can read chord symbols and rhythmic patterns, you can already read neumaRk. --- ## Where to start - **What it is, goals, and use cases** → **Overview** (`neumaRk_overview.md`) - **The language, in normative detail** → **Specification** (`neumaRk_specification.md`) and the related documents (notes and durations, chords, flow and repeats, dynamics, text markup, voices, book/playlist collections, …) - **The language's evolution** → **Changelog** (`neumaRk_changelog.md`) > The underlying concepts — levels of detail (Compact / Human / Verbose), > formal and informal syntax, relationship with traditional notation, > design goals — are covered in the **Overview**. --- # Overview ## 1. What neumaRk is **neumaRk** is a formal system for the textual representation of music. It is designed to be simultaneously **human-readable** and **machine-readable**, with defined syntax and semantics that allow musical events, temporal structures, harmony, dynamics, lyrics, and formal sections to be described. neumaRk is, at the same time: - a **musical markup language**; - a **DSL (Domain Specific Language)** oriented toward musical notation; - a **pure textual format**, usable as a standalone file. The language was created to bridge the gap between traditional music writing and the needs of modern software systems: versioning, reliable parsing, compactness, sharing, and automatic transformation. --- ## 2. Design goals neumaRk is designed around the following main goals: 1. **Semantic clarity** Every construct has a precise and unambiguous meaning. 2. **Human readability** A neumaRk file can be read and understood directly by a musician or an author. 3. **Efficiency and speed of writing** neumaRk is designed to favor fast and efficient musical writing, based on textual input and contextual deduction, minimizing redundant information. 4. **Parsing reliability** The syntax allows deterministic parsing, even in the presence of implicit information. 5. **Expressive flexibility** The same musical content can be expressed in more compact or more verbose forms. 6. **Rendering neutrality** The language describes _what_ the music is, not _how_ it must be drawn. 7. **Compatibility with modern workflows** Text files, diff-friendly, suited to versioning systems and exchange via URL. --- ## 3. neumaRk as a musical DSL neumaRk is a DSL: a specialized language, with a well-defined domain. The domain of neumaRk includes: - tempo and meter; - pitches and durations; - articulations and dynamics; - harmony and chord symbols; - lyrics; - formal structure (markers, sections, repeats); - layout and formatting hints. The language does not attempt to replicate every graphical aspect of traditional music notation, but rather to provide a coherent and transformable textual representation. --- ## 4. Human-readable and Machine-readable neumaRk is designed to be: - **human-readable**, without the need for dedicated tools; - **machine-interpretable**, without fragile heuristics. This result is achieved through: - a line-based syntax; - a reduced set of symbols with stable meaning; - explicit rules for the deduction of implicit information. A neumaRk file can be written quickly by hand, but also generated, validated, and transformed automatically. --- ## 5. Formal syntax and informal syntax One of the central elements of neumaRk is the coexistence of **two levels of syntax**: - **Formal syntax** Rigorous, fully disambiguated, designed to guarantee reliable parsing in any situation. - **Informal syntax** More compact and natural to write, based on common conventions and contextual deduction. The two syntaxes are not separate languages: they are two expressive modes of the same language. The author can decide, case by case, whether to favor: - maximum semantic precision; - maximum speed and readability. --- ## 6. File formats and levels of detail neumaRk supports several **levels of explicitness**, which influence the amount of information present in the file: - **Compact** Information reduced to the essential. Maximum compactness. - **Human** A compromise between compactness and clarity. Oriented toward human reading. - **Verbose** All information is explicit. No semantic ambiguity. These levels do not define different languages, but modes of using the same language. --- ## 7. Typical use cases neumaRk is intended to support, among others, the following scenarios: - writing and sharing lead sheets; - textual representation of scores; - embedding music in URLs or messages; - automatic parsing and rendering; - collaborative editing and versioning; - conversion to graphical or audio formats. --- ## 8. Relationship with traditional music notation neumaRk is not a direct transcription of staff notation. Many concepts are shared (durations, measures, ties, chords), but the language: - favors **semantics** over graphics; - allows implicit information that cannot easily be made explicit on paper; - separates the musical description from the visual rendering. Traditional notation is one possible _output representation_, not the internal model. --- ## 9. Non-goals neumaRk does **not** aim to: - replace traditional music notation in the editorial domain; - define a single graphical standard; - represent calligraphic micro-details; - cover every possible existing musical practice. The language is intentionally focused and modular. --- ## 10. Organization of the specification The neumaRk documentation is divided into several files, each with a specific responsibility: this conceptual overview, the normative specification, and the detail documents (header, datapack, notes and durations, chords, flow, dynamics, markup, voices, grace notes, etc.). The complete and up-to-date list of normative documents is in `neumaRk_specification.md` §7. For the entry page and navigation, see `index.md`. This division allows a progressive reading and an evolutionary maintenance of the specification. --- # Formal specification ## 1. Purpose of the document This document defines the **formal specification** of the neumaRk language. It establishes normatively: - which constructs are valid - how they must be interpreted - which rules must be respected by parsers, validators, and rendering tools Everything described in this document is to be considered **binding**. --- ## 2. Levels of the specification The neumaRk specification is organized into several levels, each with precise responsibilities: 1. **Syntactic level** - defines the textual grammar - establishes which sequences of characters are valid 2. **Structural level** - defines the logical structure of the document - establishes the relationships between the various sections 3. **Semantic level** - defines the musical meaning of the constructs - clarifies ambiguities and edge cases 4. **Validation level** - defines the validity conditions - establishes errors and invalid states ## 2.1 Persistent musical context The parsing of a neumaRk document takes place within a **persistent musical context**. The musical context retains the most recent relevant explicit information (pitches, durations, metric state) and **persists across the entire document**, crossing: - lines; - measures; - consecutive datapacks. The musical context is **not automatically reset** at the beginning of a new datapack. A datapack represents a structural and vertical-synchronization unit, but **does not constitute a semantic boundary for musical deduction**. In the absence of explicit values, the deduction rules always refer to the current state of the musical context. --- ## 3. Normative terminology In this document the following terms are used with normative meaning: - **must** / **must not**: mandatory requirement - **may** / **may not**: optional behavior - **is invalid**: the document must be rejected - **is interpreted as**: deterministic behavior --- ## 4. Contextual use of symbols Some textual symbols of neumaRk have **contextual** semantics, determined by the type of musical line in which they appear. The normative algorithm by which the **line type** itself is deduced (in the absence of an explicit marker) is in `neumaRk_datapack.md §3.bis`. In particular: - the symbol `.` (dot) - the symbol `!` (exclamation mark) take on different meanings depending on whether they appear in: - note lines (`N) `); - chord lines (`C) `). They take on different meanings, even within the same lines, depending on their position. The line context and the position relative to the other elements of the line are always sufficient to resolve the meaning of the symbol deterministically. There is no valid case in which a symbol can be ambiguous within the same line context. ## 5. Document identification and extension A neumaRk document is a text file encoded in UTF-8. The recommended file extension for neumaRk documents is: ``` .nrk ``` The use of the `.nrk` extension allows tools, editors, and operating systems to reliably recognize neumaRk documents. The extension is **recommended but not mandatory**. A document is considered valid as a neumaRk document based on its content, and not based on the file name or its extension. Tools **may** assume the `.nrk` extension as the default when reading or writing neumaRk files. ## 6. General structure of a neumaRk document A neumaRk document may contain, in order: 1. Header (metadata) 2. Musical content and formatting content The order of the sections is significant and must be respected. ### Structural delimitation In neumaRk, a **blank line has structural value**. Blank lines delimit logical blocks of the document, in particular: - the end of the header; - the separation between consecutive musical datapacks. A structural block (header or datapack) always consists of one or more consecutive non-blank lines. --- ## 7. References to related documents This specification refers to the following documents: - `neumaRk_overview.md` - `neumaRk_formats.md` - `neumaRk_header.md` - `neumaRk_datapack.md` - `neumaRk_markers.md` - `neumaRk_chords.md` - `neumaRk_notes_and_durations.md` - `neumaRk_grace_notes.md` - `neumaRk_voices.md` - `neumaRk_articulations.md` - `neumaRk_lyrics.md` - `neumaRk_flow_and_repeats.md` - `neumaRk_dynamics.md` - `neumaRk_text_markup.md` - `neumaRk_play_and_form.md` - `neumaRk_play_directive.md` - `neumaRk_versions.md` - `neumaRk_collections.md` Each document elaborates normatively on a specific aspect of the language. --- ## 8. Compatibility and versioning Every neumaRk document must explicitly declare the version of the language used. The first line of the document must report the sequence `nrk:` followed by the reference version in the form major.minor example ``` nrk:0.6 ``` The compatibility rules between versions and the evolution of the language are documented in `neumaRk_changelog.md`. --- ## 9. Extensions The neumaRk language may be extended only within the limits explicitly allowed by the specification. Undefined or unrecognized constructs make the document **invalid**, unless otherwise explicitly indicated. --- # Header ## 1. Definition and role of the header The **header** is an optional section of a neumaRk document, located at the beginning of the file, after the version declaration. Its purpose is to contain all **non-strictly musical information** required to: - identify the piece; - provide contextual information (composer, style, tempo, key, etc.); - supply global indications valid for the entire document. In neumaRk, the header **fully coincides with the file metadata**. There are no external, distributed, or separately declared metadata. --- ## 2. `nrk:version` and its relation to the header Each neumaRk file **must** start with a version line in the form: nrk:. Example: ``` nrk:0.6 ``` Characteristics: - it is **mandatory**; - it must be the **first line of the file**; - it **is not part of the header**. After the `nrk:version` line, one or more blank lines may appear, followed by: - a header, or - directly by the first musical datapack. --- ## 3. Header block and recognition criteria ### 3.1 Initial block If present, the header consists of a **block of consecutive lines** that: - follows the `nrk:version` line (after any blank lines); - precedes any musical datapack; - **contains no blank lines**. The header **ends at the first blank line**. Any subsequent content is interpreted as musical datapack. --- ### 3.2 “All-or-nothing” criterion (conservative parsing) The initial block is recognized as a header **only if all its lines are valid** according to the rules defined in this document. If even a single line: - violates a syntactic rule; - contains an unsupported element; - or can be interpreted as a musical line, the entire block is classified as **not a header**. In this case: - header parsing fails; - the block is subsequently analyzed as musical datapack content. Partial parsing of the header is not allowed. --- ### 3.3 Conservative deduction and anti-collision principle Implicit deduction in the neumaRk header is governed by a fundamental principle: > **A header element must never be confusable with a musical element.** In particular, a header line **must not semantically collide** with: - a note line; - a chord line; - a marker line; - any line valid as musical datapack content. This principle aims to: - avoid structural ambiguities; - make parsing reliable; - guarantee that deduction does not produce incorrect interpretations. Deduction is therefore **conservative**: - if a line can be interpreted both as a header element and as a musical line, **the musical interpretation prevails**; - in such cases, header parsing fails and the block is treated as musical datapack. The specification **does not impose a complete formal grammar** to absolutely distinguish header and musical content. Some aspects of deduction may rely on implementation heuristics, provided that they respect the non-collision principle and the conservative strategy described above. #### Deduction of _style_ In implicit header deduction, weakly typed textual elements (such as _style_) must always avoid collisions with structurally stronger elements such as `Key`, `Meter`, and `BPM`. ## 5. Formal and informal syntax The header supports two syntactic modes: **formal (explicit)** and **informal (implicit)**. ### 5.1 Formal (explicit) syntax Characteristics: - use of explicit line markers; - no syntactic ambiguity; - **arbitrary line order**; - each element occupies a dedicated line. This is the mode recommended for automated use. --- ### 5.2 Informal (implicit) syntax Characteristics: - minimal or absent use of markers; - deduction based on content and position; - **constrained line order**; - deduction based on conservative rules. Informal syntax prioritizes readability and rapid writing. --- ### 5.3 Precedence rules In case of ambiguity or conflict, the following prevails: 1. formal syntax; 2. positional rules; 3. semantic deduction; 4. header parsing failure. --- ## 6. Elements allowed in the header The header recognizes **only** the following elements: - **Title** - **Credits** - Music by - Lyrics by - Arranger - Transcriber - **Year** - **Style** - **Key** - **Meter** - **BPM** - **Versions** (explicit form `HV)` only, see §11.6) All elements are optional. Any other content invalidates the entire header. --- ## 7. Header markers ### 7.1 Definition Header markers are uppercase alphabetic sequences followed by the character `)` and a space. - the first character is always `H`; - the length ranges from two to three letters. --- ### 7.2 List of markers | Marker | Meaning | | ------- | --------------- | | `HT) ` | Title | | `HC) ` | Generic credits | | `HCM) ` | Music by | | `HCL) ` | Lyrics by | | `HCA) ` | Arranger | | `HCT) ` | Transcriber | | `HY) ` | Year | | `HS) ` | Style | | `HK) ` | Key | | `HM) ` | Meter | | `HB) ` | BPM | | `HV) ` | Versions | --- ## 8. Title ### 8.1 Explicit form - marker: `HT) `; - the **first** `HT)` (or the implicit title, §8.2) is the **primary title**; - **additional `HT)` lines** declare **alternative titles** — search aliases: the piece is findable by the primary *or* any alternative title (e.g. *Chega de Saudade* / *No More Blues*); - a title (primary or alternative) may carry an **optional trailing language tag** `[code]` (e.g. `HT) No More Blues [EN]`), linking it to a lyrics language (`neumaRk_lyrics.md` §8.8) — the **title↔language bridge**: opening the piece by that title preselects that language. The tag is recognized by **syntactic shape**: a final bracketed token matching a language-code shape (`[A-Za-z]{2,3}` optionally followed by `-region`, case-insensitive, normalized to lowercase). A trailing `[…]` that is **not** a language-code shape is literal title text — titles rarely end in brackets (unlike parentheses), so the collision risk is negligible. The tag is **stripped** from the stored/searched title text; - alternative `HT)` lines may appear on any header line (order-independent); the serializer emits them at the end of the header block; - may contain any text. --- ### 8.2 Implicit form In the absence of a marker, the title: - must be the **first header line**; - must begin with an uppercase letter or a digit (after any spaces); - **must not be interpretable as a musical line** (notes, chords, or markers). Implicit title deduction is **conservative**: in case of doubt, the header fails. --- ### 8.3 Title and credits on the same line Credits may be indicated on the same line as the title **only in implicit form**. In this case: - credits must be enclosed in parentheses; - no explicit marker may appear on the line. --- ## 9. Credits ### 9.1 Role Credits identify the contributors to the piece. --- ### 9.2 Credits with specific markers Each element appears on its own line with a dedicated marker: - `HCM) ` — Music by - `HCL) ` — Lyrics by - `HCA) ` — Arranger - `HCT) ` — Transcriber The order is arbitrary. > **Note (text editions).** `HCL)` gives the author of the **default text** > (the neutral edition). The author of a tagged **edition** is written with > the `<…>` group on the `LYRICS)` block (`neumaRk_lyrics.md` §8.8), not here. > The old per-language credit `HCL) … [language]` is **removed**: an `HCL)` > line always sets only the primary lyricsBy. --- ### 9.3 Credits with generic marker - marker: `HC) `; - a single line; - parentheses optional; - elements separated by `/`. Assignment: - first unprefixed element → Music by; - second unprefixed element → Lyrics by; - `arr:` → Arranger; - `trans:` → Transcriber; - subsequent unprefixed elements are ignored. --- ### 9.4 Implicit credits Without an explicit marker, credits: - must be enclosed in parentheses; - must appear on a single line; - must be separated by `/`. Allowed positions: - same line as the title; - or the immediately following line. --- ## 10. Year, Style, Key, Meter, BPM ### 10.1 Common rules - all optional; - may appear **only after title and credits** (if present); - in explicit form, order is arbitrary. --- ### 10.2 Explicit form - each element on a dedicated line; - use of the corresponding marker. --- ### 10.3 Implicit form - elements may be combined on the same line; - no markers; - recognition based on pattern matching. --- ## 11. Element-specific rules ### 11.1 Year Indicates the year of composition: a 4-digit number between 1000 and 2999. ### 11.2 Style _Style_ is a textual description of the musical character of the piece (e.g. `swing`, `bossa`, `latin`, `rock ballad`). The value declared in the header initializes `currentStyle` and may be **overridden locally** in any measure via a play directive `(=Style,…)` in the `M)` line (see `neumaRk_play_directive.md`). #### Implicit form In implicit form, style: - must begin with a lowercase letter (after any spaces); - must not collide with valid patterns for: - key (`Key`); - meter (`Meter`); - tempo (`BPM`). If a text fragment can be interpreted both as style and as another structured header element, **the structured interpretation always prevails**. If ambiguity cannot be resolved, style deduction fails without invalidating the entire header. --- ### 11.3 Key Form: - note `A–G`; - optional accidental `b` or `#`; - major mode implicit; - `m` or `-` for minor. Special value: ``` X ``` indicating no key, polytonality, or atonality. --- ### 11.4 Meter Fractional form: N/D with `N` and `D` being one- or two-digit integers. Examples: ``` 4/4 3/8 ``` An extended form with internal numerator subdivision (clave) is allowed: Example: ``` [3+3+2]/8 ``` --- ### 11.5 BPM - integer value with two or three digits; - in implicit form, must be followed by `BPM` (case-insensitive); - in explicit form (`HB) `), the suffix is optional; - decimal values are not allowed. The value declared in the header initializes `currentBPM` and may be **overridden locally** in any measure via a play directive `(=…,Nbpm)` or metric modulation `(=…,figure=figure)` in the `M)` line (see `neumaRk_play_directive.md`). ### 11.6 Versions Declares the **alternative versions** of the piece. Available only in **explicit** form (`HV) `). ``` HV) versions: [original, miles, jarrett] default=original ``` - `versions:` mandatory keyword. - List of labels in square brackets, separated by commas. - `default=