My New Year's project for 2016 is described in the attached writeup (which looks like finished documentation, but mostly describes a program not yet written).
Some items are shown in struck-out letters. Those are the ones I do not plan to work on soon. Anybody who would like to have a stab at writing the necessary components is invited to contact me off-list. The requirements are: 1. A desire to have those components available. 2. Reasonable Lua programming skills.Title: PanSong
PanSong
Dirk Laurie
January 2016
PanSong is a tool for converting from one music-from-text notation to another. It can read (subsets of) ABC, M-Tx, MusicLua, PMW, PMX, and Tonic/Solfa, and write ABC, M-Tx, MusicLua, MusiXTeX, PMW, PMX, Solfa and Tonic.
PanSong is modelled after John Macfarlane's remarkable program PanDoc, a general markup converter that at the time of writing1 can read 22 and write 39 document formats. Apart from the hat-tipping gesture of starting its name with "Pan", PanSong borrows the following ideas from PanDoc:
- A native format represented by a single object coded in a widely used computer language.
- Modular design, in which conversion from one format to another is a two-stage process: input to native, native to output. The subprograms that perform the two stages are called readers and writers.
- A text-like input notation that closely resembles a well-known existing notation and implements, or nearly so, a one-to-one mapping to the native format. In this notation, there is no such thing as invalid input.
- Documentation almost entirely at the level of the input notation, so that the native format can be regarded as an implementation detail.
The native format is in Lua, and almost all of PanSong is available as a Lua module musiclua. MusicLua is merely a convenient name for Lua code that exploits this module, and the pansong program is little more than a front-end to MusicLua.
The main input notation is Tonic/Solfa, an ASCII adaptation of the Tonic Sol-fa (note the spelling difference!) notation invented in the 19th century by Sarah Glover and John Curwen, and still in use by communities with a strong tradition of a capella folk singing. Tonic/Solfa has two dialects, Tonic and Solfa, which do not interfere with each other at the syntax level and are therefore read by the same reader.
- MusicLua
Here is a typical _expression_ in MusicLua.
mtx{"c4 c c2 | d4 d d2 | e4 f g c- | b c d g-", "Sur le Pont d'Av-i-gnon l'on y dan-se, l'on y dan-se"}: tonic{align=true,UTF8=true,syllabize=false}The call to
mtxconverts its input to native format, assuming M-Tx notation for music and lyrics. After that, the methodtonicconverts native format to two lines of prettyprinted Tonic.|d :d ;d:- |r :r ;r:-|m :f ;s :d |t₁ :d ;r :s₁| |Sur le Pont|d'Avignon|l'on y danse,|l'on y dan-se|It is perfectly feasible for a human programmer to write MusicLua directly, but one would only do so for the sake of extra flexibility.
- Tonic
As the example demonstrates, this is very close to Curwen's notation. In particular, it retains:
- the movable-doh system,
- layout with one line per voice,
- lyrics lines interspersed with music lines,
- the use of punctuation to imply duration.
To paraphrase the words of John Gruber, the inventor of Markdown:
A Tonic-formatted piece of music should be publishable as-is, without looking like it's been marked up with tags or formatting instructions. It should be singable by an unaccompanied choir with no formal training beyond knowing the song Do Re Mi.
Without prettyprinting, there are some obtrusive differences, mostly unavoidable because of the constraint of using ASCII.
- Solfa
Differs from Tonic only in replacing the movable-doh system by an ABC system. Solfa is more convenient than Tonic when transcribing printed sheet music, with which it shares some conventions.
- Sharping and flatting are implied by the key.
- Explicit accidentals have one-measure scope.
As in the case of Tonic, free format is allowed in which blanks and tautological punctuation are optional. Here is the music line of the above example in minimal Solfa, as a programmer might type it.
|CC:C|DD:D|EFGC|B_CDG_|
This document is mainly a specification of Tonic/Solfa. No attempt has been made to highlight any remaining differences between prettyprinted Tonic and Curwen Tonic Sol-fa, in part because the present author is not sufficiently knowledgeable on the latter to do so.
Paragraphs, lines, measures and beats
A paragraph contains one or more non-blank lines, and is separated from other paragraphs by one or more blank lines. A line may contain:
- information;
- lyrics;
- music.
There are no invalid lines, since information lines may contain anything whatsover — key signature, time signature, title, composer, tempo, interpretation hints, markup for typesetting, crude jibes at Leutgeb, anguished pleas to Alma, etc. Some of these are recognized by the reader and made available to writers.
Each music line represents one voice. The following punctuation marks give a conspicuous Tonic Sol-fa look-and-feel.
| ; : . ,
The original meaning of these symbols in Curwen's Tonic Sol-fa is to indicate strength of accent. In Tonic/Solfa, there is a subtle difference: they are regarded as delimiters that split the line into smaller and smaller pieces, called "units". The largest possible unit is the part of the line between the first and last bar lines. What comes before it is called the preamble of the line and is treated as information. The other units are:
- Measures, delimited by bar lines.
- Sub-measures, delimited by semicolons.
- Beats, delimited by colons.
- Sub-beats, delimited by periods.
- Sub-sub-beats, delimited by commas.
Any selection of delimiters is equally legal; all that matters is their relative priority. The following two lines mean exactly the same.
| A ,B ;C |
| A .B :C |
All delimiters except bar lines are optional, unless required in order to enable a lower level of subdivision. Thus even sub-sub-sub beats are possible, although there is no delimiter for them.
Blanks have no meaning on music lines, and can freely be used between (but not inside) notes and delimiters to improve the visual appearance of a score. The Tonic/Solfa writer follows traditional usage in putting no space between a delimiter and its following note.
A line is considered to be a music line if it has the same number of measures as the previous music line (if any), and the contents of each measure is recognized as notes separated by delimiters. Thus the first legal music line determines the number of measures in all music lines in the whole paragraph.
A line is considered to be a lyrics line if it is not a music line, but contains at least two bar lines and has either the correct number of measures or the correct number of syllables. A lyrics line always applies to the music line directly above it, and sometimes does duty for the music line directly below it too, when that line does not have its own lyrics.
All other lines are information lines.
Duration
There is just one simple principle: sub-units have equal duration. Thus all the measures in a line are equal, all the sub-measures in a measure are equal, etc. The actual duration is implied by the number of sub-units. This allows Tonic/Solfa an easy and intuitive notation for any kind of triplet etc, unlike traditional Tonic Sol-fa where a different accent symbol is needed for triplets.
For example, | C .G .F .E .D | is a normal quintuplet of five equal notes in the time of one measure, whereas | C .G :F .E .D | is a Bruckner quintuplet in which the first two notes have the same total duration as the last three.
A note may continue past the end of the unit in which it starts: see Notes.
Absolute note names
Notes in the key of C are named from low to high as C0,D0,E0,F0, G0,A0,B0,C1,…,F9,G9,A9,B9 so that middle C is C4. They can be sharped or flatted, and in some situations, given a courtesy natural, e.g. C#4, D$4, E%3. UTF-8 characters for the accidentals are recognized.
Note names in Tonic
Tonic presumes a central major scale, in which the pitch symbols are d r m f s l t, written out as "do, re, mi, fa, sol, la, ti" and pronounced "doh, ray, me, fah, soh, lah, te" in English. The absolute note corresponding to d can be specified in the preamble.
An extra e or i raises pitch by a semitone; an extra a (pronounced aw) lowers it.
There are two minor scales commonly associated with a major scale.
The parallel minor (which has its first tone on
d) can be recognized by the frequent occurrence ofmaandla, and the absence ofmandl. The explicit sharping and flatting assists the singers to think in minor. If a key is indicated (see Keys and Modulation), this is what is meant.The relative minor (which its third tone on
d) can be recognized by the occasional occurrence ofse. This is treated as a mere mode and the indicated key would be that of the relative major.
Note names in Solfa
Solfa note names are absolute note names with modifications.
- Solfa presumes a central octave
C D E F G A B, which is redefined every time that a note name with an explicit octave number is found, e.g.GafterA4meansG4. - As in sheet music, some note names can be implicitly sharped or flatted by the key, e.g. if the key is
A(A major) orf#(F sharp minor),F,CandGstand forF#,C#andG#respectively. - Explicit sharps and flats are relative, and sharping and flatting continues implicitly for the rest of the measure in the voice where it occured, unless cancelled. E.g. in the key of
Gwhere normallyFstands forF#, the nameF$unsharps F, andF%after that restores the meaning ofFto stand forF#.
Notes
First construct the note name, whether in Tonic or Solfa. It is bad practice to use both in the same voice, but not actually illegal.
- After the name, octave modifiers may follow. In Tonic, UTF-8 characters may be used instead. In Solfa, only the ASCII modifiers are recognized.
- An accent, as in
fe'orE', indicates that the note is in the next octave higher than the reference octave. An underscore, as in
d_'orF#_', indicates that the note is in the next octave lower than the reference octave. This allows the subsubcontra octave to be represented, thus extending Solfa to the full rangeC0_toG9allowed in a Midi file.Accents and underscores may be repeated.
The combination of all of these must not contain any embedded blanks. The note name plus octave modifier is translated internally to an absolute note name, but unless you request MusicLua output with the
nativeoption, you will never see that.
Instead of a note name, a hyphen may appear to indicate that the previous note is continued.
Rests normally need no notation: two consecutive delimiters without a note in between implies a rest. If there are no delimiters, a tilde indicates a rest.
Notes enclosed in parentheses, written together or delimited by blanks, form a chord.
Keys and Modulation
The first information line of a piece may contain key information, given in uppercase for major keys and in lowercase for minor keys, e.g.
Key G
If no key is given, Key C is assumed.
Modulation is recorded in the first information line of the paragraph by simply listing the two keys, separated by a slash. In every voice, the position of the modulation is marked by a note having two names, separated by a slash. Alignment is not necessary, but looks nice.
After the slash, further notes are named in the new key. There is an important difference between Tonic and Solfa. In Tonic, the letter in the key name implies the position of "doh"; in Solfa, it implies which notes are automatically sharped and flatted.
For example, a modulation to the relative minor has no effect in Solfa, but changes the note names in Tonic.
G/e
| d :s_ ;d :r | m :m ;m/s :-.f | ma :r ;d :t | d ;- : |
On the other hand, a modulation to the parallel minor has no effect in Tonic, but changes the note names in Solfa.
Lyrics
All that is needed for a lyrics line to be valid is that it contains the correct number of measures. However, some of the export formats will only work properly if the lyrics lines have the same number of syllables as their music lines.
Syllable breaks are marked by a blank, comma, semicolon, hyphen or equals sign. Blanks immediately after a syllable break are ignored. An equals sign not only marks the end of a syllable, but indicates a melisma: the preceding syllable consumes an extra note. For a syllable that spans several notes, extra signs can be added. I.e. the number of notes consumed equals one more than the number of equals signs.
An underscore does not mark a syllable break, and can be used to combine two words to reduce the number of syllables.
If a line contains the wrong number of measures, an attempt is still made to interpret it as a lyrics line. The measure count is ignored and bar lines count as syllable breaks. If the number of syllables equals the number of notes in the preceding music line, the line is a valid lyrics line, and correct implied bar lines are inserted by the reader.
Information
The following items on information lines are recognized by the Tonic/Solfa reader.
Key
Key, followed by exactly one blank, followed by a key name, i.e. a lowercase or uppercase letter, optionally followed by a flat or sharp.
Modulation
Two key names with no octave number, separated by a slash, with no embedded spaces.
Time signature
Two numbers separated by a slash, e.g. 6/8. If not given, it is guessed intelligently based on the two top-level delimiters.
4/2 |
| ; ; ; | |
2/2 |
| . ; . | |
4/4 |
| : ; : | |
4/4 (reader only) |
| : : : | |
3/4 |
| : : | |
2/4 |
| , : , | |
6/8 |
| . . : . . | |
6/4 |
| : : ; : : | |
Items that apply to one voice only are looked for in the preamble (the part before the first bar line) of a music line.
Doh
doh= followed by an absolute note name.
Part name
Everything up to the first period. Some part names are recognized by the reader as implying information about clef, doh, central octave, transposition etc.
UTF-8 characters
The following UTF8 characters are emitted by some writers if the UTF8 option is requested. They are acceptable on input too.
♭ ♮ ♯ ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉
$ % # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
In Tonic notes, subscripts and superscripts (within reasonable limits) are translated to the appropriate octave modifiers, e.g. the reader treats l² as a synonym of l''. In all other cases, the UTF-8 character is considered to be a synonym of the character shown below it.
PanDoc 1.16, downloaded from http://pandoc.org/ and built on Ubuntu 14.04 LTS in December 2015.↩
------------------------------- [email protected] mailing list If you want to unsubscribe or look at the archives, go to http://tug.org/mailman/listinfo/tex-music

