Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > c67286ade4f05f2be65d530517d37cab > files > 218

mup-6.2-1.fc18.x86_64.rpm

<HTML>
<HEAD><TITLE>
Custom Accidentals and Alternate Tunings
</TITLE></HEAD>
<BODY>
<P>
&nbsp;&nbsp;&nbsp;<A HREF="fontfile.html">&lt;-- previous page</A>

&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="index.html">Table of Contents</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="mupindex.html">Index</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="param.html">next page --&gt;</A>
</P>
            
<H1>
CUSTOM ACCIDENTALS AND ALTERNATE TUNINGS
</H1>
<P>
Mup supports custom accidentals: the ability to use any character,
including a
<A HREF="udefsym.html">user defined symbol,</A>
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.
</P>
<P>

If you want to generate
<A HREF="midi.html">MIDI</A>
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 (#, &amp;, n, x, &amp;&amp;).
Also, you can specify a
<A HREF="param.html#tuning">tuning other than the standard equal temperament tuning,</A>
and you can
<A HREF="param.html#a4freq">define a pitch level different from the standard of the note a4 being 440 Hz.</A>
</P>
<P>
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.
</P>
<H2>
Printing custom accidentals
</H2>
<P>
Although you can use an existing character as a custom accidental, typically
you would want to define a new one, as explained in the
<A HREF="udefsym.html">section on user defined symbols.</A>
When you put a custom accidental on a note,
the X axis of the symbol (the place where Y = 0) will be aligned vertically
with the note.
The position of the Y axis (the place where X = 0)
does not affect the positioning.
</P>
<P>
The Mup distribution contains two &quot;include&quot; files of symbol definitions
that can be used as custom accidentals.
The file &quot;quarterstep_accs&quot; defines accidentals intended for use
as quarter steps and three quarter steps.
The file &quot;helmholtz_accs&quot; 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.
</P>
<P>
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.
<BR><PRE>
include &quot;quarterstep_accs&quot;
music
1: 8f{&quot;qsharp&quot;}; f#; f{&quot;tqsharp&quot;}; g{&quot;qflat&quot;}; g&amp;; g{&quot;tqflat&quot;};
bar
</PRE><BR>
<IMG SRC="mugex97.gif" ALT="Picture of Mup output"><BR>
To reduce the amount of typing, you can define
<A HREF="macros.html">macros</A>
for the accidentals.
For example:
<BR><PRE>
define QS {&quot;qsharp&quot;} @
</PRE><BR>
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.
</P>
<H2>
MIDI for custom accidentals and alternate tunings
</H2>
<P>
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.
</P>
<H3>
Defining custom accidentals for MIDI
</H3>
<P>
To generate MIDI for a piece that uses custom accidentals,
their frequency offsets must be defined in an &quot;accidentals&quot; context.
A frequency offset tells how much the accidental alters the pitch of the note.
It can be specified in any of these ways:
<UL>
<LI>
A positive number by which the note's frequency is to
be multiplied. It may include a decimal fraction part (e.g. 0.97 or 1.5).
Of course, a number greater than 1 will raise the pitch, and a number
less than 1 will lower the pitch.
<LI>
A ratio of two positive numbers; that is, two numbers with a / between them.
Mup will divide the numbers and multiply the note's frequency by the result.
The numbers may include decimal fraction parts,
though whole numbers are more often used
when stating ratios for this.
<LI>
A + or - sign followed by a number and the word &quot;cents&quot;.
The number may include a decimal fraction.
A cent is 1/100 of an equally tempered halfstep, or in other words,
1/1200 of an octave.
The note's frequency will be multiplied by 2 to the cents/1200 power.
So a positive cents value will raise the pitch, and a negative cents value
will lower the pitch.
</UL>
</P>
<P>
Each line in an accidentals context contains a symbol name in quotes
followed by either the word &quot;all&quot; 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.
</P>
<P>
Any of the standard accidentals can also be listed in an accidentals context:
&quot;sharp&quot;, &quot;flat&quot;, &quot;nat&quot;, &quot;dblsharp&quot;, &quot;dblflat&quot;.
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.
</P>
<P>
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.
</P>
<P>
The first line of an accidentals context consists of the word &quot;accidentals&quot;
followed by a name you provide in quotes.
To make use of it, in a score context you set
<A HREF="param.html#acctable">the acctable parameter</A>
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 &quot;acctable&quot; is not set, only standard accidentals can be used, and
they will have their default offsets.
</P>
<P>
The following is an example of an accidentals context:
<BR><PRE>
accidentals &quot;mine&quot;
	&quot;acc1&quot;		all 23/22
	&quot;acc2&quot;		all 1.0873
	&quot;acc3&quot;		all +87 cents
	&quot;acc4&quot;		c 17/18  f 0.9103  g -93 cents
</PRE><BR>
</P>
<P>
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.
</P>
<H3>
Setting the pitch level
</H3>
<P>
The standard pitch of the note a4, the A above middle C, is 440 Hz.
With the
<A HREF="param.html#a4freq">a4freq parameter,</A>
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.
</P>
<H3>
Setting the type of tuning
</H3>
<P>
The
<A HREF="param.html#tuning">tuning parameter</A>
lets you set the tuning system to &quot;equal&quot;,
&quot;pythagorean&quot;, or &quot;meantone&quot;.
Each tuning sets differently the frequencies of the &quot;white&quot; 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.
</P>
<H4>
Equal temperament
</H4>
<P>
The default value of &quot;tuning&quot; is &quot;equal&quot;, 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).
</P>
<H4>
Pythagorean tuning
</H4>
<P>
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).
</P>
<P>
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.
</P>
<H4>
Meantone tuning
</H4>
<P>
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).
</P>
<P>
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.
</P>
<H3>
Using just intonation
</H3>
<P>
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.
</P>
<P>
Here are the ratios for the just intervals from c up to each other note:
<BR>                
<IMG SRC="mugex98.gif" ALT="Picture of Mup output"><BR>
</P>
<P>
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 &quot;syntonic comma&quot;.
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&amp; agree, but
e&amp;, a&amp;, and d&amp; need to be raised by 81/80, a syntonic comma.
</P>
<P>
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.
</P>
<H4>
First method: redefine standard accidentals
</H4>
<P>
For the first method, we use normal notation (standard accidentals),
but redefine their offsets as necessary to achieve the ratios shown above.
</P>
<P>
Consider e&amp;.  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&amp;, we have to multiply 81/64 by 128/135.
So when they are used on the note e, flats should be 128/135.
</P>
<P>
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.
</P>
<P>
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.
</P>
<P>
So, the following will set up everything as required:
<BR><PRE>
accidentals &quot;key_of_c_just&quot;
	&quot;flat&quot;		d 128/135  e 128/135  a 128/135  b 2048/2187
	&quot;sharp&quot;		f 135/128
	&quot;nat&quot;		e 80/81  a 80/81  b 80/81
score
	a4freq = 445.5
	tuning = pythagorean
	acctable = &quot;key_of_c_just&quot;
</PRE><BR>
</P>
<P>
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.
</P>
<P>
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.
</P>
<H4>
Second method: use custom accidentals
</H4>
<P>
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.
</P>
<P>
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:
<BR><PRE>
symbol &quot;commaup&quot;
	bbox = -350, -700, 350, 700
	postscript = &quot;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
	grestore&quot;
symbol &quot;commadn&quot;
	bbox = -350, -700, 350, 700
	postscript = &quot;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
	grestore&quot;
accidentals &quot;just&quot;
	&quot;commaup&quot;	all 81/80
	&quot;commadn&quot;	all 80/81
score
	a4freq = 445.5
	tuning = pythagorean
	acctable = &quot;just&quot;
	define CU {&quot;commaup&quot;} @
	define CD {&quot;commadn&quot;} @
music
	rom 1: 1 &quot;C Lydian&quot;;
	1: 1c; d; eCD; fCD#; g; aCD; bCD; c+;
	bar
	rom 1: 1 &quot;C Phrygian&quot;;
	1: 1c; dCU&amp;; eCU&amp;; f; g; aCU&amp;; b&amp;; c+;
	bar
</PRE><BR>
<IMG SRC="mugex99.gif" ALT="Picture of Mup output"><BR>
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 &quot;helmholtz_accs&quot;
file that is in the Mup distribution.
Using those definitions, the above example looks like this:
<BR><PRE>
include &quot;helmholtz_accs&quot;
score
	a4freq = 445.5
	tuning = pythagorean
	acctable = &quot;helmholtz&quot;
	define SD {&quot;sharpdn&quot;} @
	define ND {&quot;natdn&quot;} @
	define FU {&quot;flatup&quot;} @
music
	rom 1: 1 &quot;C Lydian&quot;;
	1: 1c; d; eND; fSD; g; aND; bND; c+;
	bar
	rom 1: 1 &quot;C Phrygian&quot;;
	1: 1c; dFU; eFU; f; g; aFU; b&amp;; c+;
	bar
</PRE><BR>
<IMG SRC="mugex100.gif" ALT="Picture of Mup output"><BR>
</P>
<H3>
Debugging tuning settings
</H3>
<P>
To help verify that you have specified the correct input,
you can run the &quot;mup&quot; command with the
<A HREF="cmdargs.html#dbgoption">debugging option</A>
of &quot;-d 512&quot;, along with an
<A HREF="cmdargs.html#moption">option to generate MIDI.</A>
In addition to some other debugging output, it will print tables to standard
error ouput,
that 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.
</P>
<HR><P>
&nbsp;&nbsp;&nbsp;<A HREF="fontfile.html">&lt;-- previous page</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="index.html">Table of Contents</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="mupindex.html">Index</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="param.html">next page --&gt;</A>
</P>
</BODY></HTML>