User:Fastaro/Generalized Pythagorean tuning: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Fastaro (talk | contribs)
Fastaro (talk | contribs)
Blanked the page
Tag: Blanking
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''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]].<ref>Fustero, Robert. [https://robertfustero.medium.com/fourier-series-of-music-902c9dd57629 "The Fourier Series of Music"]</ref>


== 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 (its octave complement). 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\]
\[ S = \left\{ \frac{p^x}{q^n},\frac{q^{n+1}}{p^x} \mid x \in \mathbb{Z}, 0 \leq x \leq 6 \right\} \]
=== 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 ===
<nowiki>Using the derived value of 'n':
\[ n = \left\lfloor \frac{x\ln(p)}{\ln(q)} \right\rfloor \]
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:</nowiki>
\[ \prod_{x=0}^{k} R_{x_1} \cdot R_{x_2} = q^{k+1} \]
=== Set notation for Pythagorean ratios ===
Given the definitions of \[ R_{x_1} \text { and } \ R_{x_2} \] (where p=3 and q=2) the set of pythagorean ratios for integer values of x from 0 to 6 is:
\[ S = \left\{ R_{x_1}, R_{x_2} \mid x \in \mathbb{Z}, 0 \leq x \leq 6 \right\} \]
<nowiki>This notation provides a compact and precise way to represent the set of all such tuples within the specified range of 'x'.</nowiki>
=== Generating the ratios with Python code ===
<syntaxhighlight lang="python">
from math import log, floor
from fractions import Fraction
# Define 'p' and 'q'(q is the octave term, to keep everything within an octave keep q = 2)
p = 3
q = 2
# Format fractions so 1 can be in denominator
def format_fraction(frac):
    if frac.denominator == 1:
        return f"{frac.numerator}/1"
    else:
        return str(frac)
# 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 = 7
# Initialize lists to store the results
ratios1 = []
ratios2 = []
# Calculate and store the values of 'n' and the ratios for each 'x'
for x in range(limit):
   
    n = calculate_n(x, p, q)
    ratio1 = Fraction(p**x, q**n)
    ratios1.append(ratio1)
    # Must have this check so an extra note is not placed in for specific limit
    if (x != limit-1):
        ratio2 = Fraction(q**(n+1), p**x)
        ratios2.append(ratio2)
combined_ratios = ratios1 + ratios2
# Sort the combined list from lowest to highest
sorted_combined_ratios = sorted(combined_ratios, key=lambda x: float(x))
# Convert the sorted ratios to strings, remove the first item (1/1), and put it in scaleworkshop format
formatted_ratios_as_fractions = '\n'.join([format_fraction(ratio) for ratio in sorted_combined_ratios][1:])
print(formatted_ratios_as_fractions)
</syntaxhighlight>256/243
9/8
32/27
81/64
4/3
729/512
3/2
128/81
27/16
16/9
243/128
2/1
=== Finding Potential MOS ===
<syntaxhighlight lang="python">
from math import log, floor
from fractions import Fraction
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))
mos_limit = 100  # This can be adjusted as needed
# Initialize lists to store the results
ratios = []
# Calculate and store the values of the ratios for each 'x'
for x in range(mos_limit + 1):
    n = calculate_n(x, p, q)
    ratio1 = Fraction(p**x, q**n)
    ratio2 = Fraction(q**(n+1), p**x)
    ratios.append((ratio1, ratio2))
# Find Moments of Symmetry (MOS)
threshold = 0.1  # Define how close the absolute difference must be to 0 or 1 to qualify as MOS
mos_values = []
for i, (ratio1, ratio2) in enumerate(ratios):
    abs_diff = abs(float(ratio1) - float(ratio2))
    if abs_diff < threshold:
        mos_values.append((i, abs_diff))
    elif abs(1 - abs_diff) < threshold:
        mos_values.append((i, abs(1 - abs_diff)))
# Sort MOS values by the error term
mos_values_sorted = sorted(mos_values, key=lambda x: x[1])[1:]
# Format the sorted MOS values for printing
formatted_mos_values = ['MOS val: {} Error: {:.10f}'.format(mos_val, error) for mos_val, error in mos_values_sorted]
print('\n'.join(formatted_mos_values))
</syntaxhighlight>MOS val: 53 Error: 0.0062622215
MOS val: 100 Error: 0.0073518030
MOS val: 47 Error: 0.0132579735
MOS val: 6 Error: 0.0191642018
MOS val: 59 Error: 0.0250705137
MOS val: 94 Error: 0.0280807744
MOS val: 41 Error: 0.0343237563
MOS val: 12 Error: 0.0405625277
MOS val: 88 Error: 0.0456818909
MOS val: 65 Error: 0.0467971156
MOS val: 35 Error: 0.0515888953
MOS val: 18 Error: 0.0574961246
MOS val: 71 Error: 0.0634036047
MOS val: 82 Error: 0.0685206233
MOS val: 29 Error: 0.0747367642
MOS val: 24 Error: 0.0809488707
MOS val: 76 Error: 0.0840203675
MOS val: 77 Error: 0.0871569698
MOS val: 23 Error: 0.0899292905
MOS val: 30 Error: 0.0958386057
== 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.
=== Chain of fifths / fourths ===
The original pythagorean tuning using the ratios from the chain of fifths and chain of fourths in a tuple.  The generalized pythagorean ratios shows us how you can generate a scale of kth EDO with only the chain of fifths or it's octave complement, the chain of fourths.
<nowiki>
\[ S_{p_5} = \left\{ \frac{p^{x}}{q^n}  \mid x \in \mathbb{Z}, 0 \leq x \leq k \right\} \]
\[ S_{p_4} = \left\{ \frac{q^{n+1}}{p^x}  \mid x \in \mathbb{Z}, 0 \leq x \leq k \right\} \]
</nowiki>
== See also ==
* [[Harmonic lattice diagram]]
* [[Just intonation subgroup]]
* [[Chain of fifths]]
* [[Pythagorean tuning]]
== References ==
<references/>
[[Category:Tuning]]
[[Category:Lattice]]
[[Category:Subgroup]]
{{Todo| review }}

Latest revision as of 05:55, 2 February 2024