Skip to main content

Music Tonnetz-Transform

Perform Neo-Riemann operations on musical chords

DESCRIPTION

This class generates transposed and Neo-Riemann chord progressions.

Calling the generate() and circular() methods returns three lists:

  1. The generated chord progression (in either the default midi-number or named "ISO" format)
  2. The transformations used in the generation
  3. The list of pitch names, comprising the chords that were generated

The generate() method generates a linear series of transformed chords, from beginning to end.

The circular() method generates a circular series of transformed chords. This describes movement around a circular list ("necklace") of chord transformations. Starting at position zero, we move randomly, forward or backward along the necklace, transforming the current chord.

SYNOPSIS

from music_tonnetztransform import Transform

t = Transform( # defaults:
    base_note='C', # used to construct the base_chord, if not given
    base_octave=4, # "
    base_chord=None, # set as a list of midi numbers or named notes
    chord_quality='', # '': major, 'm': minor, '7': 7th
    format='midinum', # or ISO for names
    semitones=7, # transposition semitones
    max=4, # number of circular transformations
    allowed=None, # [T], [N], [T,N], None
    transforms=4, # either a list or a number of computed transformations
    verbose=False,
)

generated, transforms, chords = t.generate()
# [[63, 67, 70], [70, 74, 77], [70, 75, 79], [70, 75, 79]],
# ['T3', 'T7', 'RL', 'I'],
# [['Eb', 'G', 'Bb'], ['Bb', 'D', 'F'], ['Bb', 'Eb', 'G'], ['Bb', 'Eb', 'G']])

t = Transform(format="ISO")
generated, transforms, chords = t.generate()
# [['G4', 'B4', 'D5'], ['D4', 'F#4', 'A4'], ['C#4', 'F4', 'G#4'], ['D4', 'F4', 'Bb4']],
# ... as above

t = Transform(format='ISO', transforms=['R','L','P'])
generated = t.generate()[0] # [['C4', 'E4', 'A4'], ['C4', 'F4', 'A4'], ['C4', 'F4', 'G#4']]

t = Transform(transforms=['R','L','P','T2'], max=6)
generated, transforms, chords = t.circular()

MUSICAL EXAMPLES

from music_tonnetztransform import Transform
from music21 import chord, stream

s = stream.Stream()
p = stream.Part()

t = Transform()
generated = t.generate()[0]

for notes in generated:
    c = chord.Chord(notes, type='whole')
    p.append(c)

s.append(p)
s.show()
from music21 import duration, chord, stream
from music_tonnetztransform import Transform
from random_rhythms import Rhythm

s = stream.Stream()
p = stream.Part()

r = Rhythm(durations=[1, 3/2, 2])
motif = r.motif()

t = Transform(max=len(motif))
generated = t.circular()[0]

for i,dura in enumerate(motif):
    c = chord.Chord(generated[i])
    c.duration = duration.Duration(dura)
    p.append(c)

s.append(p)
s.show()
from music21 import duration, chord, stream
from chord_progression_network import Generator
from music_tonnetztransform import Transform
from random_rhythms import Rhythm

s = stream.Stream()
p = stream.Part()

r = Rhythm(durations=[1, 3/2, 2])
motifs = [ r.motif() for _ in range(3) ]

g = Generator(
    net={
        1: [3,4,5,6],
        2: [4,5,6],
        3: [2,4,5,6],
        4: [1,5,6],
        5: [2,3,4,7],
        6: [3,4,5],
        7: [3,5],
    }
)

for _ in range(2):
    for i,motif in enumerate(motifs):
        g.max = len(motif) # set the number of chord changes to the number of motifs
        g.tonic = i == 0 # only start on the tonic if on the 1st motif
        g.resolve = i == len(motif) - 1 # only end with the tonic on the last motif
        phrase = g.generate()
        for j,dura in enumerate(motif):
            c = chord.Chord(phrase[j])
            c.duration = duration.Duration(dura)
            p.append(c)

    t = Transform(
        format='ISO', # using named notes
        base_chord=phrase[-1], # last chord of the previous phrase
        max=len(motifs[0]), # number of durations in the first motif
        verbose=True,
    )
    generated = t.circular()[0]

    for i,dura in enumerate(motifs[0]):
        c = chord.Chord(generated[i])
        c.duration = duration.Duration(dura)
        p.append(c)

    for motif in motifs + [motifs[0]]: # repeat the motifs
        g.max = len(motif)
        phrase = g.generate()
        for i,dura in enumerate(motif):
            c = chord.Chord(phrase[i])
            c.duration = duration.Duration(dura)
            p.append(c)

s.append(p)
s.show()

SEE ALSO

https://metacpan.org/pod/Music::NeoRiemannianTonnetz

https://en.wikipedia.org/wiki/Neo-Riemannian_theory

https://viva.pressbooks.pub/openmusictheory/chapter/neo-riemannian-triadic-progressions/

Metadata

Release files for music-tonnetztransform 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for music-tonnetztransform 0.1.7
File Size Uploaded Provenance Actions
music_tonnetztransform-0.1.7.tar.gz 45.3 kB Without provenance Details for music_tonnetztransform-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for music-tonnetztransform 0.1.7
File Interpreter ABI Platform Actions
music_tonnetztransform-0.1.7-py3-none-any.whl Python 3 none any Details for music_tonnetztransform-0.1.7-py3-none-any.whl

Total release size: 77.0 kB

Release files / music_tonnetztransform-0.1.7.tar.gz

Download URL music_tonnetztransform-0.1.7.tar.gz
Size 45.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bf85b8e608d615fb042d89dbfb6a7a5613eec9719925294a38d8421c38c5609b
BLAKE2b-256 checksum
How to use checksums
4b462baec45ac86ba625f54fcb4bed615f4a5c961b858ed2662cd8b0de5440a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / music_tonnetztransform-0.1.7-py3-none-any.whl

Download URL music_tonnetztransform-0.1.7-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0a09147a9a26663b152bfe8fd5e1bc8cb3f408bef81ba9752a8ee646fe825bd
BLAKE2b-256 checksum
How to use checksums
61a3812f722236d142c2e5bb51094dae8b0238c5e74c6a4e4b26370b68360e07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for music-tonnetztransform 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page