[ ]:
import automuse
import automuse.scale as scale
import automuse.modes as modes
import automuse.transforms as transforms

Transforms

Transforms in music map between sets of notes. From simple triad inversions to Neo-Riemannian [1] processes, all transforms share one common purpose: to discover alternative, possibly more interesting, expressions.

To take from your hand the burden of doing actual music, AutoMuse implements some of these transforms.

Inverting Intervals

To invert a group of notes is to move the lowest note an octave higher. This is easy to implement.

Inverting an interval carries a related meaning. Suppose that inverting C-G gives G-C: inverting the interval between C-G should yield the interval between G-C. The invert_interval function captures this behaviour.

Perfect intervals always invert to perfect intervals. A factoid: inverting the perfect 4th and the perfect 5th give each other.

[2]:
assert transforms.invert(automuse.INTERVALS["perfect 5"])\
           == automuse.INTERVALS["perfect 4"]\
       and transforms.invert(automuse.INTERVALS["perfect 4"])\
           == automuse.INTERVALS["perfect 5"]

Reaching “up” from a note by a given interval, then again by the invert of that interval, should produce that note (albeit an octave higher). Together, reach and invert_interval allows us to test this:

[3]:
from automuse import (same_class,
                    reach)
[4]:
for note, interval in zip(automuse.NOTES,
                          automuse.INTERVALS.values()):
    assert same_class(note,
                      reach(reach(note, interval),
                            transforms.invert(interval)))

Transposition

Transposition moves a set of notes up or down by semitones.

[5]:
transforms.transpose(scale.scale("C", modes.MAJOR), 1)
[5]:
['C#0', 'D#0', 'F0', 'F#0', 'G#0', 'A#0', 'C1']

Neo-Riemannian Transforms

Neo-Riemannian transformations map between harmonies. AutoMuse implements a few.

Some transformations are implemented with reference to, or checked against, other resources. Please see documentation for attributions.

[6]:
from automuse.transforms import\
    (nrt_parallel,
     nrt_relative,
     nrt_slide,
     nrt_leading_tone_exchange,
     nrt_near_fifth,
     nrt_far_fifth,
     nrt_dominant,
     nrt_hexatonic_pole,
     nrt_t6,)