Muscript is a language for typesetting music, and a Perl script which translates this language either into PostScript, or into Encapsulated PostScript, or into MIDI, or into MusicXML, and there is a script muscriptps2svg to translate muscript into SVG. Muscript was written by Peter Billam to typeset his own compositions and arrangements; it started life as an awk script, and was announced to the world in 1996. The current version of muscript is 2.8v. There is some backward-incompatibility of syntax with 2.7 and previous, because of the new, stricter note syntax.
This page describes the text input syntax: boundarybox, systems, barlines, new bar, staves, clefs, keysigs, timesigs, rhythms, rests, notes, pitches, accidentals, stems, beams, ties and slurs, note-options, chords, words, MIDI and comments
It ends with details of how to download and install muscript, on page size issues, some tools for manipulating muscript files, and working in other languages. Then after a history of changes and a list of proposed enhancements, there are some pointers to some of the other free music-typesetting software. In a separate directory, there are some samples available to get you started with muscript syntax.
$ muscript filename > filename.ps (generates PostScript) $ muscript filename | lpr (direct to the printer) $ muscript foo | gs -q -sDEVICE=pdfwrite -sOutputFile=foo.pdf - (generates PDF) $ muscript -letter foo > foo.ps (US Letter pagesize) $ muscript -midi foo > foo.mid (generates MIDI output) $ muscript -xml foo > foo.xml (generates MusicXML output) $ musicxml2ly foo.xml (generates LilyPond) $ muscript -v (version information) $ muscript -h (helpful list of calling options)
The muscript language is designed, in the spirit of eqn and pic, to reflect the way one musician might describe a score in detail over the phone to another musician. The language is quite compact, and a page of music can be described in not much more than a page of ascii text. In fact with a little practice a musician can sight-read the score in its muscript form.
Muscript text input consists of a number of commands,
mostly on separate lines. The Backslash \ as last
character on a line will continue the command on the next line.
Describing a page of music in muscript corresponds to the way you'd write the page; so first you draw the staves, then on each stave you draw the barlines, then for each bar you fill in the clefs, notes, etc.
Each page consists of several systems, each of which consists of one or more bars, each of which consists of one or more staves, each of which contains one or more notes or words.
If the very first line in the file is e.g.:
boundarybox 65 53
then muscript will generate output in Encapsulated PostScript
(EPS) format, 65 points wide and 53 points high in this example.
This EPS output can then be inserted into word-processor or
desktop-publishing documents, or it can be converted into JPG format
and used in web pages. See the eps2jpg script,
and the kdf.txt file in the samples.
The first line on each page draws the systems of staves.
For example, a typical piece for flute, 'cello, etc might be:
12 systems /20/20/20/20/20/20/20/20/20/20/20/20/
The numbers between slashes are the height of each stave, in point.
Or a typical piece for piano might be
6 systems /20-40-20/20-40-20/20-40-20/20-40-20/20-40-20/20-40-20/
The intermediate numbers (40 here) are the height of the gaps between
the staves. The dashes cause barlines to join between the staves.
So the piano part of a violin sonata might be:
4 systems /14 30 20-40-20/14 30 20-35-20/14 30 20-40-20/14 30 20-42-20/
A trailing gap in a system is respected, and can be used to reserve
space, for example for low stem-down notes on multiple ledger lines.
A top gap, to be reserved above the first system,
is indicated by a number before the first slash, e.g.
2 systems 80 / 13 30 19-40-19 / 13 30 19-40-19 30/
If there are fewer systems specified than needed, then muscript
repeats the last one as necessary. For example, twelve single-stave systems
can be written:
12 systems / 19 /
Titles use a title Blurb Blurb syntax,
and are printed in big bold font, centered at the top of the page.
Page numbers use a pagenum 7 syntax.
They are printed in the top outer corner;
that is, odd page numbers print in the top right corner,
even page numbers in the top left.
If a number is not specified (e.g. pagenum )
then the number will auto-increment from the previous page number.
Headers use a innerhead Blurb blub syntax.
These are printed in small italic font in the the inner top corner -
the opposite top corner from the page-number.
If there is no page-number on the current page, you can use the explicit
lefthead and righthead commands.
If high notes on the top stave get mixed up with the headers and titles,
then put a gap ahead of the top system, as in the next example.
Left Footers, using a leftfoot Blurb blub syntax,
are printed in small italic font in the bottom left corner.
Right Footers use a rightfoot Blurb blub syntax,
and are printed in small italic in the bottom right corner.
If low notes on the bottom stave of the bottom system are getting mixed up
with the footers, then put a trailing gap into the lowest system, e.g.
6 systems 12/19-30-19/19-35-19/19-33-19/19-30-19/19-30-19/19-33-19 15/ title Squishy Macaroons pagenum 1 innerhead Kylie Bloggs, 2003 rightfoot Typeset by Gina Bloggs, 2005 midi channe1 1 patch 3
These systems specifications are persistent, so if muscript runs off the end of a page, it reuses the previous specification for the new page (except that it increments the page number, and it doesn't reprint the title).
Then, once the systems have been set up, the simple command
/
causes muscript to start typesetting the bars of the next system.
After the / command, the first thing is to draw the barlines.
For this, muscript has to know how many bars, and how they are spaced.
For example, for four bars:
4 bars | 1 | 1.2 | 1 | 1 |
Here the numbers between the | lines are the proportions
of the bar lengths. In the above example, the second bar obviously needs a
bit more space than the others. If just one part of a bar needs stretching
(perhaps because it has a lot of semiquavers) then you put more than one
number in the bar. For example, if there are five bars, but the second
quarter of the fourth bar needs more space, you could use:
5 bars | 2 | 2 | 2 | 0.5 0.7 0.5 0.5 | 2 |
These barline specifications are persistent, so if muscript runs off the end of a system, it reuses the previous specification for the new system.
When muscript works out the proportions, it reserves extra space
automatically for a clef at the beginning of the line. You can also reserve
space for time signatures and key signatures at the beginning of a line (note
that this reserves space, but does not draw anything; they will be
drawn later). For example:
4 bars | 3b 4/4 1 | 1.2 | 1 | 1 |
Double-bars are indicated || and repeat marks with :
5 bars | 10 | 9 :|| 11 | 10 | 9 ||
A Segno sign (to be used by a later "Dal Segno" instruction)
is indicated with Segno
5 bars | 10 :|| Segno 3b 4/4 11 | 10 | 9 |
If there are fewer proportion-numbers than bars needed, then muscript
repeats the last one as necessary. For example, eleven evenly-spaced bars
can be written:
11 bars | 2# 6/8 12 | 12 |
As from version 2.7g, the last barline can be ommitted.
This can be used for bar-less music,
for example:
1 bars | 50
or to split a bar between two systems:
3 bars ||: 16 | 16 | 8
Then, once the barlines have been set up, the simple command
|
causes muscript to start typesetting the next bar within the current
system. As from version 2.3, the | can also be followed by
numbers to tell MIDI about the tempo within the bar; see the
MIDI section below.
Back to the top or to the samples. . .
After the | command, you fill in the staves (of the current
bar) one by one. The first (or only) stave is =1 and the
second is =2 etc. These numbers can be followed with a
, or a ' to set a default stem direction; this is very
useful if two voices share one stave, one tail-up and one tail-down.
For example, a piano piece might begin
| =1' bass 4b 2/4 cro c~ b =1, 4b 2/4 smq [a e a e] [g e g e] =2' bass 4b 2/4 cro A d |
|
Clefs and Key Signatures are persistent, within a given stave-number. Muscript remembers them from bar to bar, and reprints them automatically at the beginning of each new system.
The principal clefs are treble, alto,
tenor and bass.
Also available are treble8va, treble8vab,
and bass8va, bass8vab,
which put a small "8" above or below the clef
to indicate instruments that transpose by one octave.
Clefs can occur within a bar, as well as at the beginning.
The null clef clefspace prints nothing, but
reserves one clef's-width of space; this can be useful for lining
up the other parts when a clef change occurs in one part.
As you can see from the above example, clefspace is
unnecessary at the beginning of a line; muscript reckons
there's always a clef there, so it reserves space anyway.
The are written simply as 1# ,
3b ,
4# etc.
The special key signature 0 means "return to Cmaj", and will
print the natural signs necessary to cancel any previous key signature.
A key signature can only occur at the beginning of a bar,
and before the time signature (if any).
The are written simply as fractions, for example
2/4, 6/8,
12/8, etc. A time signature can only
occur at the beginning of a bar, and after the key signature (if any).
Then we can start writing the rhythms and notes (and in-stave MIDI instructions).
The rhythms are written in abbreviated English syntax:
bre (
breve),
smb (
semibreve),
min (
minim),
cro (
crochet),
qua (
quaver),
smq (
semiquaver)
and
dsq (
demisemiquaver).
If you would prefer to work with a less English-based syntax,
see the languages section.
Dotted notes are written with a dot, e.g. min.
Double-dotted notes are written with two dots,
e.g. min..
Triplet notes are written with a three, for example qua3
or qua3.
Duplet notes are written with a two, for example cro2
(so two duplet crochets last three normal quavers)
Quadruplet notes are written with a four, for example qua4
(so four quadruplet quavers last three normal quavers)
Quintuplet notes are written with a five, for example smq5
(so five quintuplet semiquavers last one normal crochet)
Tremolandi are written with a / or //
or /// suffix, e.g. a minim divided into
semiquavers is min//
Small notes (e.g. ornaments) are written with a -s suffix,
which must be at the end, e.g. smq-s or
qua3.-s
A rhythm remains valid for all notes and rests in that stave, until changed.
A rest in the centre of the stave is written rest
It can be moved to the top line by rest'
or further by rest'' or even rest'''
or to the bottom line by rest,
or further by rest,, or even rest,,,
A blank space on a stave is written blank
Back to the top or to the samples. . .
By default, Quavers, Semiquavers and Demisemiquavers get tails.
For example:
qua F smq A G
You can start a beam with a [ character right at the beginning
of the note-string, or end it with a ] character right at the end.
On each stave, muscript keeps track of two beams, one for stem-up
notes, and one for stem-down; so make sure that all the notes you
wish to be joined by the same beam have the same stem-direction.
For example:
qua [F smq A G]
Simultaneous notes are expressed with angle brackets, for example:
min <C Eb G c'>
or:
qua [<E G> <F A>]
Near the middle of each clef there is a "c".
This note is written c, and the notes above it
are written c# d eb en f f# g g# a bb b c~ c~# d~ e~b
and so on up to b~
and then further with c~~ up to f~~#.
Likewise, the notes below c are
B Bb A Ab G F# F E Eb D C# C B_ B_b A_
and so on down to C_
and then further with B__ and A__.
Thus on each clef you can write a range of nearly five octaves
without "8va" signs.
Flats, sharps, naturals, double-flats and double-sharps are written
b, #, n, bb
and ## after the note, just like they're pronounced.
Where there are accidentals and octave sign on the same note,
the octave sign must be first, e.g. A_b
In chords with neighbouring tones on one stem, one note-blob has to
be moved across to the other side of the note-stem. This is done with
an x
For example: min <C Dx G>
Semibreves have no note-stems,
and the x always shifts them rightwards.
If one note neighbours a note in a different voice, one of them has to be shifted rightwards, together with its stem. (So if the note forms part of a chord, the whole chord gets shifted rightwards.) This is done with an r. For example:
=1' cro rest c# d =1, cro blank min <G Br> |
|
If neigbouring tones both have accidentals, it improves clarity to shift the accidentals leftwards. This is done with an l, for example:
=1' cro rest c#l d =1, cro blank min <Gr Bbl> |
|
By default, stems go up if the note is below the centre line;
otherwise they go down. This default can be changed to all-up or all-down
by the stave command, e.g. =1' or
=1, Stems on individual notes can be forced up with a
' or down with a , after the note: for example
qua A, B c d smq c B A, G#,
Ties unite two notes of the same pitch into one longer note;
they are written with brackets ( ).
Slurs associate a sequence of notes into one melodic phrase,
generally played legato; they are written with curlie-braces { }
Ties and slurs are printed the same, but are handled differently by MIDI.
Ties
above the note are started with (1 or (3 or (5
or (7 or (9 and finished at a later note in the same stave with
)1 or )3 or )5 or )7 or )9 respectively.
Ties below the note are started with (2 or (4 or
(6 or (8 and finished at a later note in the same stave
with )2 or )4 or )6 or )8 respectively.
Slurs
above the note are started with {1 or {3 or {5
or {7 or {9 and finished at a later note in the same stave with
}1 or }3 or }5 or }7 or }9 respectively.
Slurs below the note are started with {2 or {4 or
{6 or {8 and finished at a later note in the same stave
with }2 or }4 or }6 or }8 respectively.
By default, ties and slurs end close to the note-blob. If you want one to end higher, at the top of an upward stem, then insert a ' between the bracket and the number. Or if you want one to end lower, beneath a downward stem, then insert a , between the bracket and the number. For example:
|
=1' treble 5/8 qua rest' [d{'1 f(3] [f)3 d}'1]
=1, treble 5/8 cro. G(2 cro G)2
|
=1 bass b{1-. d-. G-., C}'1-.,
|
|
Ties which are ended without having being begun are deemed to begin at the nearest double-bar, or at the start of the line if there's no double-bar in the way. This copes with a note being tied into a second-time-bar.
Options attaching to a note appear, separated by -'s,
after any ties or slurs, and just before any end-chord or end-beam sign.
For example:
cro rest B-. min c(1-tr-fermata cro3 c)1 B-I3 A
The available options are:
blank (or the empty string, see below),
creNN (crescendo, see below),
dimNN (diminuendo, see below),
down (
),
emph (emphasis,
),
fermata (
),
the guitar-string options gs1
(
)
to gs6
(
),
mordent (
),
stacc or . (staccato),
tr (trill),
turn (
),
ten (tenuto),
up (
),
and the text options
rSomeText,
bSomeBoldText,
iSomeItalicText,
ISomeBoldItalicText,
rsSomeRegularSmallText,
bsSomeBoldSmallText,
isSomeItalicSmallText and
IsSomeBoldItalicSmallText.
Text to be printed can be protected by double-quotes,
e.g. -I"sf"
or -s"3 - 4"
Trills with a flat, natural, or sharpened upper note are expressed by
trb, trn
or tr#
Multiple options on the same note are printed in order, starting close
to the stave and moving away. The blank option does
not print anything, but just leaves a gap where the option would have
been printed; this can be used to avoid options colliding with things
like slurs. An empty option works the same as a blank option,
so that A-blank-blank-s4 can also be written as
A---s4
Options are, by default, printed above the stave.
They can be printed below the stave by appending a comma (,)
to the individual option, e.g.
cro B,-., min c,(1-tr-fermata,
Crescendo and diminuendo within a note can be produced with the
-cre and -dim options.
Currently these do not affect the printed output;
they adjust MIDI's expression controller on the note's MIDI-channel,
The expression parameter starts each note
at a level of 100, and can be varied from 0 to 127. For example,
min. c-cre20 produces a moderate crescendo, or
min. c-cre20-dim30 produces a crescendo for
the first half of the note, followed by a slightly stronger diminuendo
in the second half. You can use the number 0, for example:
min. c-dim0-dim20 produces a note which fades
away during its second half.
Back to the note-syntax, or to the top, or to the samples. . .
Words can be printed above the top stave in the bar, or in the gaps between staves, or beneath the bottom stave.
Font:
The first bit of the command is a letter or two;
r means regular font,
i means italic font,
b means bold font,
I means bold italic font;
and these can be followed by an optional
s which means small, or
l which means large.
These font sizes are relative; they are scaled according
to the average stave height in the current system.
ISO-8859-1 character encoding is respected,
so that e.g. octal 374 is printed as Ü (U-umlaut).
Vertical Spacing: These letters can then be followed immediately (no space !) with a decimal number which determines the vertical position of the words as a proportion of the stave gap. The next space is a separator, and the rest of the command is the text to be printed.
Horizontal Spacing
of text is mostly done by numbers beginning with a decimal point and followed
by one, two or three digits. These numbers are treated as reserved words
within the text strings, and they space the following text to start at
that proportion of the bar's width. Multiple spaces between text-words,
or before the first word, are displayed as such, and this can be used
for small spacings, as in "Freu -" or in
"bl1.1 First"
See the examples:
Examples:
r0.5 .01 Drink .33 to .67 me ( Regular font, good for song words )
r0.5 .01 Freu - .25 de .5 schö - .75 ne ( iso-8859-1 )
I0.9 .97 ff ( Bold Italic font, good for dynamics )
i0.05 .62 rallentando ( Italic font, good for expression )
is0.8 .10 Fred Bloggs, Symphony No. 10, 5th Mvt. ( small italics )
bl1.1 First Movement ( bold large font, good for titles )
Back to the top or to the sample. . .
Within muscript, there are three types of MIDI commands:
Global commands which affect all staves, the
New-Bar command which governs the tempo, and
In-A-Stave commands which affect
just one stave (like either =1 or =2).
Also MIDI-related are the -cre and -dim
note-options,
which do changes of dynamic within the note.
midi channel 2 patch 56 pan 80 reverb 45midi channel 2 vibrato 60 rate 40 delay 70patch and pan and reverb
parameters above.
For note-by-note changes to the vibrato depth there is a corresponding
In-Stave command.
midi channel 5 chorus 90patch, pan, reverb and
vibrato parameters above.
midi pause 3.9
The new-bar command | is the place to tell MIDI about
tempo. First comes a time signature (this is just MIDI's understanding
of the time signature; it doesn't get printed) and then comes the
length of the bar in seconds. For example, the new-bar command
for a piece in 4/4 time at 120 beats/min could be:
| 4/4 2.0
As in the bars command, we can specify the lengths
of parts of the bar. For example, if we wanted a ritardando we
might use:
| 4/4 0.5 0.54 0.6 0.68
This can also be used to generate swung quavers in jazz, or
inégale quavers in Baroque music or in Irish music, or for
Viennese waltzes. For example, an Irish Jig might begin:
| 6/8 .19 .14 .17 .19 .14 .17
=1' treble 2# 6/8 qua [A B A] [A F D]
Upbeats, or in general bars of varying lengths, have to be given their
own ad-hoc lengths. For example:
| 1/4 .55
=1 bass 2b cro F
| 4/4 2.2
=1 min B cro A B
As an alternative to seconds, you can also specify a tempo, in beats per minute. Muscript decides what a "beat" means by consulting its time-signature. In 2/4 or 3/4 or anything/4 then a beat is a crochet, and in 2/2 or 3/2 or anything/2 then a beat is a minim. But in 3/8 or 6/8 or 9/8 etc. the beat is a dotted crochet, whereas in 2/8 or 4/8 or 5/8 or 7/8 etc. the beat is a quaver. (Similarly for 3/16 or 6/16).
You still have to specify the timesignature so this doesn't cure the problem with bars of varying lengths, but a later version of muscript will be able to read through the bar of the first stave and guess a timesignature from it. This won't be infallible; for example different Staves, even in the same Bar of the same System, can have different Time Signatures (e.g. Brahms Paganini Variations bk1 var5 or bk2 var7, Scriabin Etude op8 no7, etc.)
This tempo information is persistent; muscript remembers it from bar to bar, and re-applies it automatically.
These are all one-word commands (no spaces!) that can intermix
with notes and rhythms in a stave line.
They change settings for that particular stave
(like =1 or =2). They take effect immediately,
and remain in force on that same stave in subsequent bars.
All these commands can be abbreviated to their first three letters.
channel2 or cha2transpose-2 or tra-2transpose+12
(unless you've already given it a treble8va clef).
volume73 or vol90 or vol+10
or vol-10vol+10
or vol-5G-emph note-option works the same as
vol+10 G vol-10 except that the note-option
gets printed as part of the score, whereas the vol
command does not get printed, it is part of the interpretation.
The vol command uses MIDI's velocity parameter to
set the starting-volume of each note; changes of dynamic within the note
are done with the -cre and -dim
note-options, which use MIDI's expression
controller.
legato100 or leg85legato100 produces a full legato;
you can actually go beyond 100, producing an over-legato.
The default legato is 85, a sort of medium-détaché.
The -stacc note-option decreases a note's legato by about half.
vibrato80 or vib50Back to the top or to the samples. . .
Any line beginning with % is treated as a comment,
and is passed straight through to the PostScript output
where it also appears as a comment.
In -midi mode it appears as a MIDI "marker" event
at the start of the current bar.
$ muscript -a4 foo > foo.ps ( A4, the default )
$ muscript -letter foo > foo.ps ( US Letter )
$ muscript -compromise foo > foo.ps ( A4 width, Letter height )
$ muscript -auto foo > foo.ps ( autodetect A4 and Letter )
Auto only works as long as the output remains in PostScript
form; if it is translated into PDF the autodetect power is lost
and the page size becomes fixed by the translation process.
Therefore, if you want to generate PDF to publish scores globally,
you should use the -compromise option.
See also the a42us utility script.
Back to the top . . .
The current version of muscript is available by http at www.pjb.com.au/muscript/muscript. To install muscript, save it to disc, move it into your $PATH, make it executable, and if necessary edit the first line to reflect where perl is installed on your system.
If you want to use the -midi option, you'll also need to install
the MIDI-Perl module
written by Sean Burke.
Various tools exist to manipulate muscript input and PostScript output and MIDI output. To install one of the scripts, move it into your $PATH, make it executable, and if necessary edit the first line to reflect where perl is installed on your system.
8va!!8va raises the current bar one
octave, or !!8vab lowers the current bar one octave.
8vab8va;
its behaviour changes according to the name under which it is invoked.)
transposetranspose +7-k option to force a keysignature onto the input.
E.g. in vi, this would transpose the current line up 2 semitones,
considering it to have a 4-flats keysig
even if that's not explicit in the current line
(i.e. if it was set earlier in the file):!!transpose +2 -k 4b-s option to transpose only one stave.
E.g. this might convert a piece for flute and piano,
into a piece for Bb-clarinet and piano:transpose +2 -s 1
tempotempo 1.05 speeds a piece up by 5 percent.
Or, tempo 0.95 makes a piece 5 percent slower.
E.g. to generate multiple practice-versions of a piece, with different tempi:
for t in 0.73 0.81 0.90 1.00 ; do tempo $t a_piece | muscript -midi > a_piece_$t.mid done
4hands2score
muscriptps2svg-p option to convert a particular page.
It needs the SVG Perl module, available from
search.cpan.org
eps2jpgboundingbox command,
then muscript will generate Encapsulated-PostScript (EPS) output,
which can be inserted into word-processing documents.
This script eps2jpg converts this Encapsulated-PostScript
into JPG format, which can be used in web pages.
a42usa42us -c option which
generates the global-distribution compromise format (A4 width and Letter
height). See also PageSize.
midiechomidieditmididumpBack to the top . . .
If you don't enjoy the English-based syntax for
rhythms, I suggest you use m4
as a preprocessor. So instead of:
muscript symphony_1 > symphony_1.ps
you might use:
m4 us_rythms.m4 symphony_1 | muscript > symphony_1.ps
where the file us_rythms.m4 file would contain something like:
define(DN,bre) define(DN3,bre3) dnl define(WN,smb) define(WN3,smb3) dnl define(HN,min) define(HN3,min3) dnl define(QN,cro) define(QN3,cro3) dnl define(EN,qua) define(EN3,qua3) dnl define(SN,smq) define(SN3,smq3) dnl define(TN,dsq) define(TN3,dsq3)
This example assumes you have a U.S.-based musical background,
and think of semibreves as Whole-Notes, quavers as Eighth-Notes etc.
Note that I had to use uppercase letters in this example,
because otherwise en would conflict with e-natural.
When you're writing a rythms.m4 file for your own
language, be careful not to introduce words which conflict
with something else that muscript already uses.
If you develop a rythms.m4 file for another language,
feel free to email it to me
so I can document it here.
Back to the top . . .
What is really needed is an ftp archive of scores in PostScript, so that anyone can print them out and use them. I think it should standardise on gzipped files, and encourage the submission of A4 and USLetter versions of everything. Of course the composers would have to be dead more than 70 years (or the pieces would have to be publicly copiable and redistributable) and someone would have had to re-typeset the pieces. The reward is immortality, a permanent priceless contribution, no less. The way to further the musical art is to make the scores freely and permanently available. End of soapbox.
There do now exist www.gutenberg.org/music, www.mutopiaproject.org, www.classicalmusicarchives.com, icking-music-archive.org, www.free-scores.com, www.cpdl.org, www.saers.com/recorder/ www.triodomine.com.ar/partiturasgratis.htm and www.partiture.org so feel free to support them. Typeset for them !
Back to the top . . .
You might also want to check out
Back to the top . . .
Peter Billam, GPO Box 669, Hobart TAS 7001, Australia http://www.pjb.com.au