16

This is a post that would act as documentation for the ABCjs syntax, which would be a good reference site for help on basic syntax.

Please add aswers here with basic examples for ABCjs syntax to make it easier to get into the world of writing music snippets on Music.SE.

Minimal requirement is to start the code block with X: and also specify key with K: before starting write the notes. I also recommend specifying standard note lenght using L:. Default is eights that would be noted like this: L: 1/8.

Example:

Code:

X: 1  
K: C  
L: 1/4   
ABc

Output:

X: 1
K: C
L: 1/4
ABc

Links to ABCjs references:

We also have the formatting sandbox, which you can use to try out things for yourself:

jTab and ABCjs Formatting Sandbox

ABCjs integration now available

7
X:1
T:Notes
M:C
L:1/4
K:C
C, D, E, F,|G, A, B, C|D E F G|A B c d|e f g a|b c' d' e'|f' g' a' b'|]
X:1
T:Notes
M:C
L:1/4
K:C
C, D, E, F,|G, A, B, C|D E F G|A B c d|e f g a|b c' d' e'|f' g' a' b'|]
7
X:1
T:Rests
M:C
K:C
L:1/4
A z G z/2 G/2 | A2 z2 | z3 G | z4 |]
X:1
T:Rests
M:C
K:C
L:1/4
A z G z/2 G/2 | A2 z2 | z3 G | z4 |]
7

Sharps, flats and naturals

To sharpen a note precede it with the circumflex or caret ^
^c

To flatten a note precede it with an underscore _
_B

Double sharps are shown as ^^ and double flats as __

To naturalise a note precede it with an equals sign =
=c

So a scale of G major could be notated as GABcde^fg

X: 1  
K: C  
L: 1/4 
GABcde^fg

And a scale of G minor as GA_Bcd_efg

X: 1  
K: C  
L: 1/4 
GA_Bcd_efg

Key

However: Just as standard Western musical notation has the key signature, so that the player automatically knows to (for example) play all F's as F♯ in the key of G, the same thing exists in abc, with the K: field.

Example in the key of B major with a B natural accident:

X: 1  
K: _B  
L: 1/4 
GA=BAGFED
X: 1  
K: _B  
L: 1/4 
GA=Bcdefg
7
X:1
T:Note lengths and default note length
M:C
K:C
L:1/16
A/2 A/ A A2 A3 A4 A6 A7 A8 A12 A15 A16|]
L:1/8
A/4 A/2 A/ A A2 A3 A4 A6 A7 A8 A12 A15|]
L:1/4
A/8 A/4 A/2 A/ A A2 A3 A4 A6 A7|]
L:1/16
A2A2 (3 A2A2A2 (5 AAAAA (7 AAAAAAA |]
X:1
T:Note lengths and default note length
M:C
K:C
L:1/16
A/2 A/ A A2 A3 A4 A6 A7 A8 A12 A15 A16|]
L:1/8
A/4 A/2 A/ A A2 A3 A4 A6 A7 A8 A12 A15|]
L:1/4
A/8 A/4 A/2 A/ A A2 A3 A4 A6 A7|]
L:1/16
A2A2 (3 A2A2A2 (5 AAAAA (7 AAAAAAA |]
5

Voices

Systems and clefs

To have multiple systems with parallel-running voices, first declare each system with a statement of the form V:Vᴏɪᴄᴇ clef=Cʟᴇꜰ. Then, when writing out the score, prefix each line with a reference to the voice it belongs to, in the form [V:Vᴏɪᴄᴇ].

X:1
K:C
V:V1 clef=treble
V:V2 clef=treble
V:Va clef=alto
V:Vc clef=bass
[V:V1] c
[V:V2] E
[V:Va] G,
[V:Vc] C,
    X:1
    K:C
    V:V1 clef=treble
    V:V2 clef=treble
    V:Va clef=alto
    V:Vc clef=bass
    [V:V1] c
    [V:V2] E
    [V:Va] G,
    [V:Vc] C,

Multiple voices in a system

You can also have indepent voices within a single system. That requires, in addition to the declaration of voices with their clefs (which must in this case match!) a grouping-declaration in the form %%score (Vᴏɪᴄᴇ₁ Vᴏɪᴄᴇ₂).

X:1
K:Am
%%score (T1 T2)
V:T1 clef=treble
V:T2 clef=treble
[V:T1] c3  B c
[V:T2] AG FG A
    X:1
    K:Am
    %%score (T1 T2)
    V:T1 clef=treble
    V:T2 clef=treble
    [V:T1] c3  B c
    [V:T2] AG FG A

Chords within a single voice

To just write simultaneous notes of the same length, which needn't be considered as belonging to individual voices, you can put those notes in square brackets. Note length can be specified after the closing bracket and will hold for all notes in the chord.

X:1
K:C
G [GB] [EAc]2 [GB] [FBd] [Ec]2
    X:1
    K:C
    G [GB] [EAc]2 [GB] [FBd] [Ec]2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .