User:Fastaro/Generalized Pythagorean tuning

From Xenharmonic Wiki
Revision as of 06:09, 5 January 2024 by Fredg999 (talk | contribs) (Cleanup)
Jump to navigation Jump to search

Generalized Pythagorean tuning is an extension of the traditional Pythagorean tuning method, which is based on chains of perfect fifths and fourths. This method extends the Pythagorean ratios to any two numbers, not just 3 and 2, allowing for a more versatile approach to musical tuning.[1]

Theory

The basics of Pythagorean tuning

Pythagorean tuning is a system based on the ratio of 3/2, known as a perfect fifth. The method involves generating scales through a chain of fifths, multiplying the frequency by 3/2 until passing an octave. This system is limited by the specific ratios it employs and does not return to the unison ratio of 1/1.

Generalization of ratios

The generalized Pythagorean ratios considers 'q'(2) as the octave term and 'p'(3) as the term usually associated with the fifth, such as in the traditional 3/2 ratio for a perfect fifth. The idea is to extend the Pythagorean tuning by generalizing the standard chain of fifths and fourths (using 3 and 2) method.

Every pair of Pythagorean ratios with 3^x in the numerator and 3^x denominator always equals 2. In fact, Pythagorean tuning can be viewed as one particular case of the equation below where p=3 and q =2.

\[\frac{p^x}{q^n} \cdot \frac{q^{n+1}}{p^x} = q\]

Derivation of 'n'

In generalized Pythagorean tuning, the goal is to find values of 'n' that keep the ratio \[ \frac{p^x}{q^n} \] within an octave. This is achieved by ensuring that the ratio does not exceed 2 (the frequency doubling that marks the octave). When the ratio \[ \frac{3^x}{2^n} \] is greater than 2, we add 1 to 'n' to bring the ratio back within the octave range. To avoid using an 'if' statement and make the function linear, we derive 'n' as follows:

1. Start with the inequality that keeps the ratio within an octave: \[ \frac{3^x}{2^n} \leq 2 \]

2. To find when 'n' needs to increase, we set up the next inequality: \[ \frac{3^x}{2^{n+1}} \leq 1 \]

3. Solving for 'n', we take logarithms of both sides: \[ 2^{n+1} \geq 3^x \] \[ \ln(2^{n+1}) \geq \ln(3^x) \] \[ (n + 1)\ln(2) \geq x\ln(3) \]

4. Isolate 'n' and solve: \[ n \geq \frac{x\ln(3)}{\ln(2)} - 1 \]

5. Since 'n' must be an integer, we apply the ceiling function to get the largest integer less than or equal to the expression: \[ n = \left\lceil \frac{x\ln(3)}{\ln(2)} - 1 \right\rceil \]

6. Simplify: \[ n = \left\lfloor \frac{x\ln(3)}{\ln(2)} \right\rfloor \]

Generating tuple of ratios

Using the derived value of 'n', we can generate a tuple of ratios \[ R_{x_1} \text {and}\ R_{x_2} \text{ , where } R_{x_1} = \frac{p^x}{q^n} \text { and}\ R_{x_2} = \frac{q^{n+1}}{p^x} \]. This pair of ratios represents the upper and lower bounds of a frequency range for a given 'x'. The product of \[ R_{x_1} \cdot R_{x_2} \] for all 'x' from 0 to 'k' yields the result:

\[ \prod_{x=0}^{k} R_{x_1} \cdot R_{x_2} = q^{k+1} \]

Generating the ratios with Python code

from math import log, floor

# Define 'p' and 'q'(q is the octave term, to keep everything within an octave keep q = 2)
p = 3
q = 2

# Define the function to calculate 'n' using the floor function
def calculate_n(x, p, q):
    return floor(x * log(p) / log(q))

# Define the range/edo for 'x'
limit = 12

# Print out the values of 'n' and the ratio for each 'x'
for x in range(limit):
    n = calculate_n(x, p, q)
    ratio1 = (p**x) / (q**n)
    print(f'For x={x}, n={n}, the ratio p^x/q^n is: {ratio1}')
    ratio2 = (q**(n+1)) / (p**x)
    print(f'For x={x}, n={n}, the ratio q^n+1/p^x is: {ratio2}')
  1. For x=0, n=0, the ratio p^x/q^n is: 1.0000000000000000
  2. For x=0, n=0, the ratio q^(n+1)/p^x is: 2.0000000000000000
  3. For x=1, n=1, the ratio p^x/q^n is: 1.5000000000000000
  4. For x=1, n=1, the ratio q^(n+1)/p^x is: 1.3333333333333333
  5. For x=2, n=3, the ratio p^x/q^n is: 1.1250000000000000
  6. For x=2, n=3, the ratio q^(n+1)/p^x is: 1.7777777777777777
  7. For x=3, n=4, the ratio p^x/q^n is: 1.6875000000000000
  8. For x=3, n=4, the ratio q^(n+1)/p^x is: 1.1851851851851851
  9. For x=4, n=6, the ratio p^x/q^n is: 1.2656250000000000
  10. For x=4, n=6, the ratio q^(n+1)/p^x is: 1.5802469135802468
  11. For x=5, n=7, the ratio p^x/q^n is: 1.8984375000000000
  12. For x=5, n=7, the ratio q^(n+1)/p^x is: 1.0534979423868314
  13. For x=6, n=9, the ratio p^x/q^n is: 1.4238281250000000
  14. For x=6, n=9, the ratio q^(n+1)/p^x is: 1.4046639231824416
  15. For x=7, n=11, the ratio p^x/q^n is: 1.0678710937500000
  16. For x=7, n=11, the ratio q^(n+1)/p^x is: 1.8728852309099222
  17. For x=8, n=12, the ratio p^x/q^n is: 1.6018066406250000
  18. For x=8, n=12, the ratio q^(n+1)/p^x is: 1.2485901539399482
  19. For x=9, n=14, the ratio p^x/q^n is: 1.2013549804687500
  20. For x=9, n=14, the ratio q^(n+1)/p^x is: 1.6647868719199308
  21. For x=10, n=15, the ratio p^x/q^n is: 1.8020324707031250
  22. For x=10, n=15, the ratio q^(n+1)/p^x is: 1.1098579146132872
  23. For x=11, n=17, the ratio p^x/q^n is: 1.3515243530273438
  24. For x=11, n=17, the ratio q^(n+1)/p^x is: 1.4798105528177163

Implications and applications

The generalized Pythagorean tuning provides a more versatile framework for musical tuning, allowing composers and musicians to explore scales and harmonies beyond the traditional limits. This approach can lead to new musical expressions and better alignment with various musical traditions and instruments.

See also

References