plr.py
The file math/src/tonnetz/plr.py. 76 lines, 8 definitions.
The P, L, R transformations and their compositions.
Composition rule: "PL" means first P, then L. The code and the text use the same rule.
Top of file: imports
P
functionM(x) <-> m(x). The root and the fifth stay.
L
functionM(x) <-> m(x + b). The third and the fifth stay.
R
functionM(x) <-> m(x - a). The root and the third stay.
OPS
constantapply
functionApplies the letters of word from left to right. apply(t, "PL", c) = L(P(c)).
moving_step
functionThe size of the step taken by the single note that moves in a transformation (between 0 and N/2).
cycle
functionStarts from the chord start and applies the letters of word in turn, repeating them.
Returns the chords visited until the start chord (and the start of the word) is reached again.
def cycle(t: Tonnetz, word: str, start: Chord) -> list[Chord]: """start akorundan başlayıp word harflerini sırayla, dönerek uygular. Başlangıç akoruna (ve kelimenin başına) dönülene kadar uğranan akorları verir. """ out = [start] c = start i = 0 while True: c = OPS[word[i % len(word)]](t, c) i += 1 if c == start and i % len(word) == 0: return out out.append(c)cycle_length
functionThe length of the cycle starting from the chord M(0) (the number of chords visited).
translation
functionThe translation that a two-letter composition causes on major chords: M(x) -> M(x + result).