A CLI tool for exploring the twelve-tone technique (dodecaphony): generating row forms, building the 12x12 matrix, and analyzing row properties.
- A prime row is a permutation of the twelve chromatic pitch classes 0-11, each used exactly once.
- Pitch class mapping: C=0, C#=1, D=2, D#=3, E=4, F=5, F#=6, G=7, G#=8, A=9, A#=10, B=11
- Every row has four basic operations, each of which can also be transposed (Tn, n = 0-11):
- Prime (P): the row as given
- Retrograde (R): the row read backwards
- Inversion (I): each interval from the first note mirrored in direction
- Retrograde Inversion (RI): the inversion read backwards
- Applying all four operations at all twelve transpositions yields the row's full set of 48 forms.
dodecaphonism/
├── row.py # ToneRow class: row validation
├── transform.py # prime / retrograde / inversion / retrograde_inversion + transposition, 48-form lookup
└── cli.py # command-line entry point (row input, basic-form output)
tests/
└── test_row.py
pip install -e ".[dev]"
python -m dodecaphonism.cliProgrammatic use:
from dodecaphonism import ToneRow, get_form, all_forms
row = ToneRow([0, 1, 4, 8, 3, 7, 9, 11, 2, 5, 10, 6])
get_form(row, "RI7") # a single named form
all_forms(row) # all 48 forms, keyed "P0".."RI11"- Phase 1 - Transposition & the 48 row forms: add a transposition parameter to each transform function and a unified way to look up any of the 48 forms (P0-P11, I0-I11, R0-R11, RI0-RI11).
- Phase 2 - 12x12 matrix: a
Matrixclass that generates all 48 forms from a prime row, with row/column access, plus amatrixCLI subcommand (numeric or note-name display). - Phase 3 - Set theory analysis: interval vector, normal form, prime form, and hexachordal combinatoriality checks.
- Phase 4 - music21 integration: convert a
ToneRowto amusic21stream and export to MusicXML/MIDI. - Phase 5 - CLI refactor: move from a single interactive prompt to argparse/click subcommands (
matrix,analyze, ...), keeping the interactive prompt as the default when no subcommand is given.