Chord Chart Language - music-markdown/markdown-it-music GitHub Wiki

Overview

Music Markdown combines a set of various javascript plugins that render fenced areas of a markdown file as various music formats. For example, the following markdown renders ABC music:

```abc
X: 1
M: 4/4
L: 1/16
K: Amin
(C16 | C4) B,2C2 D6 CB, | (C16 | C4) B,2C2 D6 CA, | G,8 _A,8 | 
=A,8 (3F4F4F4 | F2 (E6 E8) | z6 ^A2 B4 e4 | e2d2c2(d2d4) .=A4 | 
e2d2c2(d2d4) .A4 | e4 e4 e2d2B2d2 | e4 e4 e2g2e2d2 | .e4 c2 .d4 c2 e4 | 
z2 c2 e2 d6 c2d2 | e2e2e2d2 d2B2B2_A2 | _A2F2F2E2 =A2B2A2G2 |
```

On ultimate guitar, we often see chord tablature rendered as:

                   Am     G  F          G      Esus2 E
All the leaves are brown        and the sky is gray.
F               C     E  Am       F        Esus4  E
I've been for a walk         on a winter's day.

There does not currently exist a well specified language to represent chord tablature. There are several goals for this page:

  1. Formalize a language for chord tablature as it will be used in Music Markdown.
  2. Determine the intermediate JSON representation that the language will parse to, and that will be used to render the final chord tablature.

Requirements

Representations

All of the following chord tablatures should have an unambiguous representation in our language and should be representable with our intermediate JSON representation:

1 Chord Line, 1 Lyric Line (most common):

                   Am     G  F          G      Esus2 E
All the leaves are brown        and the sky is gray.

1 Chord Line, 2 Lyric Lines (e.g. 2nd voice or chorus):

        G       G/F# Em       D    C   Cadd9
until I hear it from you
                    (hear it from you)

1 Chord Line, No Lyric Line (e.g. instrumental section):

G  Em  Bm  D   x2
C  D   C   D

No Chord Line, Lyric Line (e.g. rap, no chords):

Not too long ago, I was dancing for dollars (eeoow)
Know it's really real if I let you meet my mama (eeoow)

Events and Sequences

All of the representations imply a notion of timing. For example, chords are played at a certain time. Lyrics are sung at a specific time. Chords and lyrics can therefore be thought of as events that occur in a sequence.

The significance of a chord appearing above a lyric implies that those two events occur simultaneously. Our representation should incorporate a notion of events occurring in a sequence, where some events may occur at the same time. The sequence does not need to have a duration associated with it.

Rendered Output

It would be nice to support various output formats. For example:

                   Am     G  F          G      Esus2 E
All the leaves are brown        and the sky is gray.

Or inline:

All the leaves are [Am]brown [G] [F] and the sky is [Esus2]gray. [E]

Simultaneous events should always be rendered together and sequences should be correctly ordered. For example, if the display window is narrow, the chords should wrap with their corresponding lyrics:

                   Am   
All the leaves are brown
G  F          G      Esus2 E
      and the sky is gray.

Ideally, rendered output should be made as compact as possible. For example, if lyrics wrap to the next line and don’t have any chords associated with any of them, they shouldn’t take up the extra room that chords would normally take.

Design

Markdown Representation

The markdown representation for a Chord Chart consists of a set of phrases. Each phrase consists of several voice lines prefixed with an instrument and voice. Each voice line specifies the events for a specific instrument's voice. The phrase represent a single simultaneous event stream. Phrases are delimited by one or more empty line breaks.

The grammar for a voice line is:

<instrument>[<voice>]: <content>

Where an instrument is a string that matches the regex:

[a-zA-Z-_]+

And a voice is a number. If the voice number is omitted, then it takes the value 1 by default. The instrument name 'c' has the special meaning of being a chord line.

Here's an example Chord Chart for a phrase:

```chord-chart
c1:     G       F       Am       G          F      C
c2:     C       D       Cm       F          G      B
l1: The longest word is supercalifragilisticexpialidocious
l2:                                         supercalifragilisticexpialidocious
a1:     crash!
```

Why not JSON? Might be obnoxious. Why not plain old Chord Chart notation? Can be ambiguous. There should only be one correct way to represent a chord chart.

Intermediate JSON Representation

The JSON will be a list of verse JSON representations. Each verse will be represented as a map of voice to a object storing the index and content of the event. Index will specify the starting location of the event in the string. The voice will denote the type of object we are looking at, which will come from above representation. The final section will store the string, or object, associated with this location and voice. Here the grammar:

{
  voice(<instrument><voice number>):
    { index: <event start index>, content: <string or object> }
} 

Here is an example of this JSON representation using the markdown representation displayed in the section above.

[
  {
    c1: [
      { index: 4, content: Chord('G') },
      { index: 12, content: Chord('F') },
      { index: 20, content: Chord('Am') },
      { index: 29, content: Chord('G') },
      { index: 40, content: Chord('F') },
      { index: 47, content: Chord('C') },
    ],
    c2: [
      { index: 4, content: Chord('C') },
      { index: 12, content: Chord('D') },
      { index: 20, content: Chord('Cm') },
      { index: 29, content: Chord('F') },
      { index: 40, content: Chord('G') },
      { index: 47, content: Chord('B') },
    ],
    l1: [
      { index: 0, content: 'The' },
      { index: 4, content: 'longest' },
      { index: 12, content: 'word' },
      { index: 17, content: 'is' },
      { index: 20, content: 'supercalifragilisticexpialidocious' },
    ],
    l1: [
      { index: 40, content: 'supercalifragilisticexpialidocious' },
    ],
    a1: [
      { index: 4, content: 'crash!' },
    ]
  },
  ... // any additional verses would follow
]
⚠️ **GitHub.com Fallback** ⚠️