<-- previous page     Table of Contents    Index    next page -->


Mup supports custom accidentals: the ability to use any character, including a user-defined symbol, as an accidental. They can be placed on notes, though not in key signatures. Feel free to skip this section; many Mup users will probably never use the features described here.

If you want to generate MIDI for a piece using custom accidentals, a method is provided for defining their frequency offsets. You can also override the default frequency offsets of the standard (built-in) accidentals (#, &, n, x, &&). Also, you can specify a tuning other than the standard equal temperament tuning, and you can define a pitch level different from the standard of the note a4 being 440 Hz.

Note that some MIDI players, including the standard Microsoft Windows Media Player, do not support the special MIDI commands that are needed for these features.

Printing custom accidentals

Although you can use an existing character as a custom accidental, typically you would want to define a new one, as explained in the section on user-defined symbols. When you put a custom accidental on a note, the x axis of the symbol (the place where y is 0) will be aligned vertically with the note. The position of the y axis (the place where x is 0) does not affect the positioning.

The Mup distribution contains two "include" files of symbol definitions that can be used as custom accidentals. The file "quarterstep_accs" defines accidentals intended for use as quarter steps and three quarter steps. The file "helmholtz_accs" defines many of the accidentals needed for a system called the Extended Helmholtz-Ellis Just Intonation Pitch Notation. Even if you don't intend to use these files in your music, you can use them as examples of how to define symbols.

In a Mup input file, a custom accidental is put after a note letter similarly to a standard accidental. It is specified by the name of the accidental as a string inside braces.

include "quarterstep_accs"
1: 8f{"qsharp"}; f#; f{"tqsharp"}; g{"qflat"}; g&; g{"tqflat"};

Picture of Mup output
To reduce the amount of typing, you can define macros for the accidentals. For example:
define QS {"qsharp"} @

You can put up to four accidentals on a note. They can be any combination of standard and custom accidentals. You can put parentheses around the entire set, and parentheses will be drawn around the set. You cannot put parentheses around just a subset of them.

MIDI for custom accidentals and alternate tunings

The parameters and the accidentals context described in this section need not be used if you do not intend to generate MIDI. In that case it is only necessary to define the symbols for the custom accidentals you are using.

Defining custom accidentals for MIDI

To generate MIDI for a piece that uses custom accidentals, their frequency offsets must be defined in an "accidentals" context. A frequency offset tells how much the accidental alters the pitch of the note. It can be specified in any of these ways:

Each line in an accidentals context contains a symbol name in quotes followed by either the word "all" followed by a single offset, or a list of 1 to 7 note letter / offset pairs. In the single offset case, this same offset will be applied when the accidental is used on any of the 7 notes, a through g. In the other case, each offset follows the note letter it is to be applied to. Not all note letters need to be listed, but a custom accidental cannot be used if the value for its note letter has not been defined.

Any of the standard accidentals can also be listed in an accidentals context: "sharp", "flat", "nat", "dblsharp", "dblflat". Offsets are set for them the same way as for custom accidentals. If any notes are not specified in a list of note letter / offset pairs, the default offset (as described in the section below on tuning) is used for them. A standard accidental for which no line is provided will use the default value for all notes.

By default a natural has a ratio of 1 and it doesn't change the pitch. But you can define a different ratio for it. Note also that when a note has no accidental, it is treated the same as if it had a natural on it.

The first line of an accidentals context consists of the word "accidentals" followed by a name you provide in quotes. To make use of it, in a score context you set the acctable parameter equal its name in quotes. It will be used starting at that point in the file until such time as you change acctable. The accidentals context must occur earlier in the file than the place it is referenced. You can define any number of accidentals contexts. If "acctable" is not set, only standard accidentals can be used, and they will have their default offsets.

The following is an example of an accidentals context:

accidentals "mine"
	"acc1"		all 23/22
	"acc2"		all 1.0873
	"acc3"		all +87 cents
	"acc4"		c 17/18  f 0.9103  g -93 cents

It is possible to define an invisible accidental. This is useful in cases where you want to alter the pitch of a note for MIDI but you don't want it to print anything. In the symbol definition for an invisible accidental, you print nothing, and you need to set the bounding box to all zeros.

Setting the pitch level

The standard pitch of the note a4, the A above middle C, is 440 Hz. With the a4freq parameter, you can set this to a different number. The frequencies of all other notes are figured relative to a4, so if you set a4freq to frequency X, their frequencies will be multiplied by X/440.

Setting the type of tuning

The tuning parameter lets you set the tuning system to "equal", "pythagorean", or "meantone". Each tuning sets differently the frequencies of the "white" notes (a through g) and the default offsets of the standard accidentals. Naturals, however, have default ratio 1 (or 0 cents) in all of these tunings.

Equal temperament

The default value of "tuning" is "equal", which means equal temperament, the modern standard for Western music. In this system, all half steps are equal. Since there are 12 half steps in an octave, each has a ratio of the twelfth root of 2, about 1.05946, which is 100 cents by definition. When this tuning is set, the default value of a sharp is this ratio, and a flat is the inverse, 0.94387, or -100 cents. For a double sharp you square the sharp ratio (1.12246) or double the number of cents (200). For a double flat you square the flat ratio (0.890900) or double the number of cents (-200).

Pythagorean tuning

Pythagorean tuning is based on a perfect fifth having a ratio of 3/2 (1.5), which works out to about 702 cents. Starting from the reference note a4, the other notes are determined by going around the circle of fifths, using this ratio. So, if you are using the default 440 for a4, e5 would be 660, b5 would be 990, etc. To get from any natural note to its sharp version in the same octave (like f4 to f#4), you go up 7 fifths and down 4 octaves: (3/2)^7 / 2^4 = 2187/2048, about 1.06787 or 114 cents. So a sharp is defined to be that ratio. A flat is the inverse, 0.93644, or -114 cents. For a double sharp, square the sharp ratio (1.14035) or double the cents (227). For a double flat, square the flat ratio (0.87692) or double the cents (-227).

Pythagorean tuning is usually not used with only its default intervals and accidentals. It is usually used with custom accidentals or redefining the ratios for standard accidentals, as shown in examples below.

Meantone tuning

Meantone tuning is based on a major third being 5/4 (1.25), or about 386 cents. Perfect fifths are the fourth root of 5, so that if you go up 4 fifths and down 2 octaves, you get the 5/4 for the major third. Using this value for a fifth (about 1.49535 or 697 cents), the other notes are determined by going around the circle of fifths, using this ratio. To get from any natural note to its sharp version in the same octave (like f4 to f#4), you go up 7 fifths and down 4 octaves: (5^(1/4))^7 / 2^4, about 1.044907 or 76 cents. So a sharp is defined to be that ratio. A flat is the inverse, 0.95702, or -76 cents. For a double sharp, square the sharp ratio (1.09183) or double the cents (152). For a double flat, square the flat ratio (0.91589) or double the cents (-152).

Meantone is a compromise that lets you approximate the sound of just intonation in any key, without having to use custom accidentals or redefining standard accidentals.

Using just intonation

This section illustrates the use of custom accidentals and the related parameters by showing two ways to set up standard just intonation scales, with all the major, minor and perfect intervals, plus the augmented fourth. For an example, we will use a key note of c, and we will have a4 be 440 Hz.

Here are the ratios for the just intervals from c up to each other note:
Picture of Mup output

For both methods, we'll start with pythagorean tuning. Going around the circle of fifths starting from c, we find that this g and d agree with pythagorean. But a would be 27/16. To arrive at 5/3, we need to multiply the 27/16 by 80/81. This lowers it by a "syntonic comma". It turns out that e, b, and f# also need to be lowered by that amount. Going the other direction, we find that f and b& agree, but e&, a&, and d& need to be raised by 81/80, a syntonic comma.

For the just a to be 440 Hz, the pythagorean a has to be 445.5 (multiply by 81/80). So we set a4freq to 445.5.

First method: redefine standard accidentals

For the first method, we use normal notation (standard accidentals), but redefine their offsets as necessary to achieve the ratios shown above.

Consider e&. The pythagorean e is 81/64. (Up four fifths from c, then down two octaves.) To get to the 6/5 that we need for e&, we have to multiply 81/64 by 128/135. So when they are used on the note e, flats should be 128/135.

Using similar reasoning, we find that flats on a and d should also be 128/135. But flats on b should be 2048/2187. The sharp on f should be 135/128.

Naturals also need to be redefined when they differ from their pythagorean values. We have already found those values: naturals on a, e, and b need to be 80/81. The other natural notes agree, and we can let them default to 1/1. Remember, when a note appears without any accidental on it, is is treated the same as if it had a natural.

So, the following will set up everything as required:

accidentals "key_of_c_just"
	"flat"		d 128/135  e 128/135  a 128/135  b 2048/2187
	"sharp"		f 135/128
	"nat"		e 80/81  a 80/81  b 80/81
	a4freq = 445.5
	tuning = pythagorean
	acctable = "key_of_c_just"

Notes not defined in this table will default to their pythagorean values. We have found that those are the correct values for naturals. But they are probably wrong for sharps, flats, double sharps, and double flats. If you wanted to use any of those notes, you would have to decide what its ratio should be, and then figure out what offset should be put in the table. Especially for notes far from the key center (c), it is not obvious what ratio you would want.

This brings up a problem. You may need multiple versions of some notes, even for ones not far from the key center. For example, the ratio 5/3 is used for a. That works well if you are playing an F major chord, fac+. But if you are playing a D minor chord, dfa, that is not the right ratio. To get a perfect 3/2 fifth from d to a, you would want a to be 27/16. This leads us to the second method.

Second method: use custom accidentals

This method also uses pythagorean tuning as a basis, but instead of redefining the standard accidentals to different values for different notes, it defines custom accidentals for offsets that differ from the pythagorean defaults. Each accidental, standard or custom, has the same offset no matter what note it is applied to.

In simple cases such as the scales we are defining in this section, it turns out that each note either agrees with the pythagorean ratio, or else is higher or lower by a syntonic comma, 81/80 or 80/81. You could define accidentals for up and down commas, and use them alone or together with standard accidentals, as follows:

symbol "commaup"
	bbox = -350, -700, 350, 700
	postscript = "gsave
		0 600 moveto -250 135 lineto -230 135 lineto
		0 420 lineto 230 135 lineto 250 135 lineto fill
		70 setlinewidth 0 500 moveto 0 -600 lineto stroke
symbol "commadn"
	bbox = -350, -700, 350, 700
	postscript = "gsave
		0 -600 moveto -250 -135 lineto -230 -135 lineto
		0 -420 lineto 230 -135 lineto 250 -135 lineto fill
		70 setlinewidth 0 -500 moveto 0 600 lineto stroke
accidentals "just"
	"commaup"	all 81/80
	"commadn"	all 80/81
	a4freq = 445.5
	tuning = pythagorean
	acctable = "just"
	define CU {"commaup"} @
	define CD {"commadn"} @
	rom 1: 1 "C Lydian";
	1: 1c; d; eCD; fCD#; g; aCD; bCD; c+;
	rom 1: 1 "C Phrygian";
	1: 1c; dCU&; eCU&; f; g; aCU&; b&; c+;

Picture of Mup output
Or, you may instead want to define a set of custom accidentals that act as combinations of standard accidentals and commas, and perhaps some accidentals for other ratios. One such set was mentioned earlier: the set defined in the "helmholtz_accs" file that is in the Mup distribution. Using those definitions, the above example looks like this:
include "helmholtz_accs"
	a4freq = 445.5
	tuning = pythagorean
	acctable = "helmholtz"
	define SD {"sharpdn"} @
	define ND {"natdn"} @
	define FU {"flatup"} @
	rom 1: 1 "C Lydian";
	1: 1c; d; eND; fSD; g; aND; bND; c+;
	rom 1: 1 "C Phrygian";
	1: 1c; dFU; eFU; f; g; aFU; b&; c+;

Picture of Mup output

Debugging tuning settings

To help verify that you have specified the correct input, you can run the "mup" command with the debugging option of "-d 512", along with an option to generate MIDI. In addition to some other debugging output, it will print tables to standard error output, which show the frequency being used for each note in your piece. If you change any of the parameters along the way, it will print a table for each section of your piece as delimited by the places where the parameters change.

   <-- previous page    Table of Contents    Index    next page -->