SelfscribeDownloadOpen the app

Sheet music

Type a tune in ABC notation and get an engraved score you can play.

Document · Simple · uses music

Edit it in the playgroundRead the file

What it shows

Write a tune in ABC notation, and let the music plugin engrave it as a score.

What you learn

A fenced block handed to a plugin, chips split from one line, a block that holds another with its caption, a caption that keeps its first word, a reading guide split at ::.

Try this

  • Change a note in the ABC block (the letters after the K: line), and the score is engraved again.
examples/folk-tune.self · 84 lines
~~~ selfscribe
# Lesson: Write a tune in ABC notation, and let the music plugin engrave it as a score.
# You learn: a fenced block handed to a plugin, chips split from one line, a block that holds another with its caption, a caption that keeps its first word, a reading guide split at ::.
# Try this: change a note in the ABC block (the letters after the `K:` line), and the score is engraved again.
# summary: Type a tune in ABC notation and get an engraved score you can play.
# category: fun
# tags: document, simple, creative
# uses: music
use markdown
set title Sheet music
set heading-font Fraunces

# ---- A ```abc block: the music plugin reads the tune and draws the score ------------------
block  ``` abc ... ```   -> music   verbatim

# ---- Colours, each with its shade for dark pages ------------------------------------------
palette
  ink    #1d4f86  dark #8ec2ff
  edge  color-mix(in srgb, var(--ink) 16%, transparent)

# ---- A tune-book page: "No. 42 · Jigs", "= Name", "about a · b · c", then the score ---------
# `keep` leaves the first word on the page, so "No." and "Played" stay in the text.
line   No. _             -> div.tune-no     keep { font: 700 0.74em/1 var(--doc-font-ui); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink) }  as tb-no
line   = _               -> div.tune-name   { font: 600 3em/1.05 var(--doc-font-heading, Georgia, serif); letter-spacing: -0.02em; margin: 0.25em 0 0.3em }  as tb-name
line   about _           -> div.tune-facts  split "·" span.tb-fact  { display: flex; flex-wrap: wrap; gap: 0.4em; margin-bottom: 1.4em }  as tb-facts
class tb-fact  { font: 600 0.74em/1 var(--doc-font-ui); padding: 0.55em 0.85em; border-radius: 999px; border: 1px solid var(--edge); color: var(--ink) }
# "::: score" … ":::" keeps whatever is inside it together: here the abc block and its caption.
block  ::: score ... ::: -> figure.score    { margin: 0 0 2em }  as tb-score
line   Played _          -> figcaption      keep { font-size: 0.85em; font-style: italic; opacity: 0.7; text-align: center; margin: 0.6em 0 0.4em }  as tb-caption

# ---- The reading guide: "`token` :: meaning", split at :: into two columns ----------------
line   _ :: _            -> div.legend      split "::" span  { display: grid; grid-template-columns: 8em 1fr; gap: 1em; align-items: baseline; padding: 0.45em 0; border-bottom: 1px dashed var(--edge); font-size: 0.93em }  as tb-legend
~~~
No. 42 · Jigs
= The Kesh
about Traditional, Irish · Jig in 6/8 · G major · Public domain

::: score
```abc
X:42
M:6/8
L:1/8
Q:3/8=104
K:G
|:"G"GAG GAB|"D"ABA ABd|"G"edd gdd|"Em"edB "D"dBA|
"G"GAG GAB|"D"ABA ABd|"G"edd gdB|"D"AGF "G"G3:|
|:"G"BAB dBd|"C"ege "G"dBA|"G"BAB dBG|"D"ABA AGA|
"G"BAB dBd|"C"ege "G"dBd|"D"gfg aga|"G"bgf g3:|
```
Played AABB: each part twice, then the whole tune again from the top.
:::

One of the first jigs most people learn at a session. Each part is eight bars, and both stay in G, so a newcomer can join in on the second time round.

## Playing it

- Feel it in two: each bar is two groups of three, *one*-two-three *two*-two-three.
- Start slowly, around 80 beats a minute, and keep every note even before you speed up.
- On the long notes at the end of each part (`G3`, `g3`), breathe or take a bow change. The next part starts straight after.
- The chords above the staff are for a guitar or a piano. Strum on the first and fourth eighth note of each bar.

## How it's made

The score is not a picture. It is the `abc` block in the text, and the music plugin engraves it each time the page opens. The number, the name and the chips are three line rules, and `::: score` keeps the block and its caption together.

Each part of the ABC means something simple. The rows below are split at `::` into two columns:

`X:42` :: The tune's number in the book. Every tune starts with one.
`M:6/8` :: Six eighth notes in a bar, felt as two beats.
`L:1/8` :: A letter on its own is an eighth note; `G3` lasts three times as long.
`Q:3/8=104` :: The speed: 104 dotted quarter notes a minute.
`K:G` :: The key: G major, so every F is played as F sharp.
`"Em"` :: A chord name in quotes, printed above the note it falls on.
`d` and `D` :: A lowercase letter is an octave above the capital.
`|:` and `:|` :: The start and end of a part that is played twice.

## Try it yourself

1. In the first bar, change `GAG GAB` to `G3 GAB`. The score is engraved again, with one long G where there were three notes.
2. Change `"Em"edB` to `"C"edB`. The chord above the fourth bar says C.
3. Change `Q:3/8=104` to `Q:3/8=80`. The tempo mark above the score follows.
4. Change `K:G` to `K:D`. The key signature gains a sharp, and every C is now played as C sharp.

Next: *Song with chords* puts chords over lyrics; *Chess games* hands blocks to the chess plugin.