[rec.music.synth] MIDI pitch inversion

rickp%pedxing@Sun.COM (Rick Palkovic) (09/02/89)

I stumbled on the following observations while playing with the
"Reverse" editing feature on my Roland MIDI sequencer.  The 
article may be of general interest, so I present it here
for your information.  An earlier version, complete with examples,
was submitted to the Roland newsletter, but remains unpublished.
Copyright 1989 by Rick Palkovic.

		Inverting Pitches in MIDI Music Sequences
		-----------------------------------------
At music schools they tell a joke about the graduate student who asks
his favorite professor for advice on composition.  "I just can't come
up with any good ideas," the student complains.

The professor purses his lips thoughtfully, gazes at the ceiling, hems
and haws, and finally admits, "The same thing happens to everyone
occasionally -- even me.  Confidentially, I sometimes get inspiration
by turning a score upside down and playing it -- just to see how it
sounds, of course.  Even though the inversion isn't really music, I
occasionally get a few new ideas from it."

The student thought this was such a good idea that he went home and did
just as the professor suggested.  And, because he admired the
professor, he chose one of the professor's own compositions to turn
upside down. To his delight, it sounded even better when he played it
that way than it did right-side-up!

Without changing a note, he submitted the inverted piece as his
doctoral dissertation.  He was very surprised when the graduate
committee threw him out of school for plagarism -- not because he had
inverted his professor's score, but because he had submitted a
note-for-note transcription of an obscure piano piece by Gluck!

While no successful composer resorts to the blatant rip-offs of the
professor and student in the story, most composers occasionally resort
to theory or algorithmic manipulation to help construct music when the
Muse fails. (Even Mozart is said to have experimented with composing
music by rolling dice.)  Still, the very idea of algorithmic
composition is enough to inspire rage in many musicians and composers.
If you are one of these, spare your blood vessels and read no further.

Inverting MIDI Pitches
----------------------
Today's sequencers let you invert your own music, or that of others,
and hear the results immediately.  Whether the result is music or not
depends a lot on how much thought you put into the process before you
invert the sequence.

When the unfortunate music student in the story turned his professor's
music upside down, he inverted the song around middle C, the midpoint
of the grand staff.  Middle C is C3, or MIDI note 60 (this article uses
Yamaha numbering convention throughout).  Sequencers like Roland's
MC500 MkII running SMRC software invert around E3 (MIDI note 64).  The
actual formula Roland uses to calculate inverted notes is the simplest
possible:

	NewNoteNumber = 128 - OldNoteNumber 

This formula can also be used with microcomputer-based sequencers such
as Vision for the Macintosh (from OpCode Systems) by creating custom
transposition maps.  You can write your own programs to invert standard
MIDI files with this formula.  Other formulas that invert around other
notes are possible, but you must make suitable allowances for end-point
conditions (new notes that calculate to less than 1 or more than 128).
The comments in this article apply to the Roland formula, but can be
extrapolated to other similar formulas.

From now on, I'll call the inversion produced by the formula "reversal"
to distinguish it from more common musical terminology, such as "chord
inversion."  Using the formula, note 64 remains note 64 after reversal,
note 63 becomes 65, note 62 becomes 66, and so on. The intervals
(number of semitones) between reversed notes do not change, only their
pitch order is reversed.

As you experiment with note reversal, you will quickly discover that
reversing notes has the side effect of converting most music to a
different key.  In the rest of this article I use the term "convert"
instead of "transpose" because transposing usually means moving all the
notes up or down by the same amount.  In contrast, reversing the notes
moves each note by a _different_ amount, some up and some down.

Table 1 shows what happens to notes in the vicinity of E3 (MIDI note
64) after reversal.

		Table 1.
		--------

	Original Note	Reversed Note
	--------------- -------------
	MIDI# 	Note	MIDI# 	Note
	--------------- ------------
	59	B 2	69	A 3
	60	C 3	68	Ab3
	61	Db3	67	G 3
	62	D 3	66	Gb3
	63	Eb3	65	F 3
	64	E 3	64	E 3
	65	F 3	63	Eb3
	66	Gb3	62	D 3
	67	G 3	61	Db3
	68	Ab3	60	C 3
	69	A 3	59	B 2	

How Reversing Changes Keys
--------------------------
Look at what happens when the notes of a C scale (Ionian mode) are
reversed.  The reversal turns key-of-C notes into key-of-E notes.  Of
course, the reversed scale is descending where the original was
ascending, and the reversed notes are different scale tones in the new
key (for example, C, the tonal center of the original scale, reverses
to G#, the 3rd of the reversed scale).

		Table 2.
		--------

	Original	Reversed
	Key (C)		Key (E)
	----------------------------
	MIDI# 	Note	MIDI# 	Note
	------------	------------
	48	C*	80 	G#
	50 	D	78 	F#
	52 	E	76	E*
	53 	F	75 	D#
	55 	G	73 	C#
	57 	A	71 	B
	59 	B	69 	A

* Tonal center of key.

Table 3 shows the original keys and reversed keys for all 12 major
scales.  As you would expect, Table 3 shows that reversing a song a
second time converts back into the original key.

		Table 3.
		--------

	Original Key	Reversed Key
	------------    ------------
	 C		 E
	 Db		 Eb
	 D*		 D*
	 Eb		 Db
	 E		 C
	 F		 B
	 Gb		 Bb
	 G		 A
	 Ab*		 Ab*
	 A		 G
	 Bb		 Gb
	 B		 F

	* Keys of D and Ab do not change when reversed.

Table 3 shows that there are two diatonic keys in which a melody, when
reversed, yields a melody in the same key as the original. These keys
are D major and Ab major.  If notes in either of these keys are
reversed, the resulting notes will be in the same key as the original
-- that is, the reversed key will have the same *key signature*.  (As
we shall see in the discussion of harmony, these two keys are actually
converted into their relative minors: B minor and F minor,
respectively.)  The important thing to note is that if you reverse a
melody in the key of D or Ab, it has a pretty good chance of
harmonizing with the chord progression of the original piece.

Scale tones in the keys D and Ab remain scale tones when reversed
because they are symmetrical about E3, the scale tone that is
MIDI-mapped to 64 (see Table 4). Other popular scales that are
symmetrical about E are the jazz minor scales in A and Eb (known in
classical music theory as ascending melodic minor scales), the two
whole-tone scales, and the C diminished scale (also known as A, Eb, or
Gb diminished).
				Table 4.
				---------

                                	   Symmetry
                        	             Axis
                	                       |
MIDI note number:  55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
                	                       |
Key of D:           G     A     B    C#  D     E    F#  G     A     B    C#
Key of Ab:          G Ab    Bb     C Db    Eb  |  F     G Ab    Bb     C Db
A jazz minor:         G#  A     B  C     D     E    F#    G#  A     B  C
Eb jazz minor:        Ab    Bb     C     D Eb  |  F Gb    Ab    Bb     C
Whole Tone 1:       G     A     B    Db    Eb  |  F     G     A     B    Db
Whole Tone 2:         Ab    Bb     C     D     E    Gb    Ab    Bb     C   
C diminished:         Ab  A     B  C     D Eb  |  F Gb    Ab  A     B  C   
                	                       |

The symmetry of these scales is more obvious when you look at the
scales in Table 4 as a pattern independent of the names of the notes.
The pattern would be the same if you flipped it over around its axis of
symmetry (Table 5).

				Table 5.
				--------
                                	   Symmetry
                        	             Axis
                	                       |
                    G     A     B  C     D     E  F     G     A     B  C   
                	                       |
MIDI note number:  55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
                                               |
Key of D:           X     X     X     X  X     X     X  X     X     X     X 
Key of Ab:          X  X     X     X  X     X  |  X     X  X     X     X  X
A jazz minor:          X  X     X  X     X     X     X     X  X     X  X 
Eb jazz minor:         X     X     X     X  X  |  X  X     X     X     X 
Whole Tone 1:       X     X     X     X     X  |  X     X     X     X     X 
Whole Tone 2:          X     X     X     X     X     X     X     X     X 
C diminished:          X  X     X  X     X  X  |  X  X     X  X     X  X
                	                       |

What Happens to the Harmony?
-----------------------------
Note reversal often produces interesting theme variations and
counterpoints, but a song's accompanying harmony usually turns into mud
when reversed, even if the reversed music is transposed (by octaves)
back into its original register.

The effect of pitch reversal on harmony is present in all forms of
music when more than one pitch is sounded at once, but the discussion
here focuses on homophonic music, as typified by "fake book"
transcriptions that show a melody line and block chordal
accompanyment.

The problem of interpreting reversed harmony is really twofold.

The first problem has to do with chord voicing.  Modern chords use
extensions and alterations that introduce dissonance and tension.
These tones are often played in close position at the top of the
chord.  When the chord is reversed, the dissonance is moved to the
bottom of the chord.  The chord winds up sounding like someone is
playing a keyboard with his forehead.

The second problem with reversed harmony relates to the way chords
follow one another in a progression.  The fact that some progressions
make "sense" (and that some progressions are strong while others are
weak) is because of the harmonic function of the individual chords.
When a 3-note triad is reversed, it turns from a major chord into a
minor chord, and the function of the chord in the progression changes.
At the same time the chord function changes, the root of the chord is
given a new scale position in the new key.  The result is that a a
strong progression (cycle of fifths, descending half-steps, etc.)
becomes weak (cycle of fourths, ascending half steps, etc.) after
reversal.  Of course, "weak" doesn't mean "bad."  Weak progressions are
used quite often, and the effect may be just what you're looking for.

Here's how simple triad harmonies map into the reversed key:

Original chord:              I  ii  iii   IV    V   vi   vii(b5)
Reversed chord in new key:  vi   V   IV  iii   ii    I   vii(b5)

For example, in the key of D (one of the two major keys that does not
change during reversal), the harmonies are:

Original chord (key of D):  D    Em   F#m   G     A   Bm  C#m(b5)
Reversed chord (key of D):  Bm   A    G     F#m   Em  D   C#m(b5)

So the common ii-V-I cadence reverses to V-ii-vi in the new key, and
the ever-popular iii-vi-ii-V-I reverses to IV-I-V-ii-vi.  Strong
progressions are converted into weak ones.  In addition, major chords
are converted into minor ones, and minor into major.  But the reversed
chords still harmonize the reversed melody (provided, of course, that
they harmonized in the original composition).

[Note that a strong progression becomes a weak one after pitch
reversal, but is restored to a strong progression when it is played
backwards in time!  For example, iii-vi-ii-V-I-IV =>
IV-I-V-ii-vi-iii (reversed) => (iii-vi-ii-V-I-IV (backwards).
Many sequencers allow reversing time order as well as pitch order.]

Jazz Harmonies Reversed
-----------------------
Now let's look at what happens to chords with seventh extensions 
(4-note chords) during reversal:

Original chord:             Imaj7   ii7  iii7  IVmaj7   V7    vi7  vii7b5
Reversed chord in new key: IVmaj7  iii7   ii7   Imaj7 vii7b5  vi7    V7

For example, in the key of D, the 4-note chord harmonies are:

Original chord (key of D):  Dmaj7  Em7   F#m7  Gmaj7  A7       Bm7  C#7(b5)
Reversed chord (key of D):  Gmaj7  F#m7  Em7   Dmaj7  C#7(b5)  Bm7  A7

When the chords formed by the reversed notes are respelled as new
seventh chords, we see that their basic chord names are different from
the chords produced by reversing simple triads.  Once again, the
functional harmony of the progression is altered when the pitches are
reversed.  The venerable ii7-V7-Imaj7 cadence becomes
iii7-vii7b5-IVmaj7 in the new key.

If the progression contains chords with higher extensions or
alterations, it becomes quite difficult to predict how the reversed
chord will sound, or what its function should be in the progression
(examples are C7b9, Cmaj7#11, C13#5b9, and so on).  The name and
function of a reversed chord with alterations depends a lot on the
voicing of the original chord.

Rules for Reversing Pitches
---------------------------
The theory discussed above lets us make some rules about reversing
pitch around MIDI note 64.  First, if you want a reversed song to sound
musical (in the traditional sense), you will have the best results if
you first transpose the song so that the melody is in the key of D or
Ab major (or use one of the other scales in Table 4).

If you want, reverse the whole song to see how it sounds, but keep any
chordal accompanyment in a separate track so that you can reverse it
back if you don't like it.  It will probably sound better in its
original version.

If the piece has moving parts in counterpoint, put the parts in
separate tracks and reverse them one at a time. You can hear how they
sound after each reversal.

Conclusion
----------
Reversing the pitches in a piece of music is a quick way to generate
counterpoint parts, bass lines, variations on a theme, and new chord
progressions.  The simplest formula for reversing pitch maintains
MIDI note 64 constant and does not alter the key center for D major
or Ab major.  Other formulas or mappings will maintain different
tonalities.  Experiment, and always let your ear be your guide.

Just remember, if you start with someone else's music, be sure
the finished piece doesn't get you thrown out of music school!