Xenharmlib (music theory library) adds support for Just Intonation

retooth2 pts0 comments

What’s new in xenharmlib 0.4.0? — xenharmlib documentation

What’s new in xenharmlib 0.4.0?¶

As far as new features are concerned, version 0.4.0 is not a step<br>but a leap forward. Xenharmlib’s core has been refactored to allow<br>not only equal-division temperaments but also tunings with multiple<br>generator intervals. This means that it now supports the entire range<br>of regular temperaments, including Just Intonation.

With the sole exception of irregular temperaments (such as the<br>“Werckmeister temperaments”), xenharmlib can finally represent<br>the entire cosmos of musical traditions in mathematical form.<br>It can now be used for the accurate analysis of music from the<br>Byzantine Empire, the European Renaissance, Indian classical<br>music, the Indonesian gamelan tradition, Arabic Maqam and<br>20th-century American experimental music (such as the<br>compositions of Harry Partch or Ben Johnston)

In keeping with its holistic approach, xenharmlib allows the use<br>of existing analytical tools for all regular temperaments, provided<br>they are mathematically compatible with them.<br>For example, Prime Form and Normal Form calculations can also be<br>performed on (multi-dimensional) regular temperaments.

In addition, the documentation has been completely revamped:<br>feature examples are organized by tuning and notation, and<br>comprehensive, dedicated documentation is provided for all<br>harmonic primitives.<br>We will give a brief overview of the aforementioned (and other)<br>features hereinafter. (For the full Changelog see<br>here)

Just Intonation / Prime Limit Tunings¶

Just Intonation refers to tunings that are based on “pure intervals”.<br>A pure interval is characterized by a fraction of two integers, e.g.<br>\(\frac{3}{2}\). Historically, most tuning systems were based on<br>Just Intonation. It was not until the 18th and 19th centuries that<br>equal temperament systems began to gain widespread acceptance in<br>practice.<br>Xenharmlib now introduces support for Just Intonation with<br>the Prime Limit Tuning construct:

from xenharmlib import PrimeLimitTuning

limit11 = PrimeLimitTuning(11)

A Pythagorean 12-tone chromatic scale can, for example, now be generated<br>by stacking 5 ascending pure fifths and 6 descending pure fifths from<br>the root pitch:

from xenharmlib import PrimeLimitTuning<br>from xenharmlib import periodic

pythagorean = PrimeLimitTuning(3)

C0 = pythagorean.rs_pitch('1/1')<br>P5 = pythagorean.rs_interval('3/2')

iseq_a = pythagorean.interval_seq([P5] * 5)<br>iseq_b = pythagorean.interval_seq([-P5] * 6)<br>chromatic_scale = (<br>C0.scale(iseq_a) | C0.scale(iseq_b)<br>).pcs_normalized()<br>print(chromatic_scale)

PrimeLimitPitchScale([1, 256/243, 9/8, 32/27, 81/64, 4/3, 1024/729, 3/2, 128/81, 27/16, 16/9, 243/128], 3-Limit)

Most software programs implement functions for Just Intonation not as a<br>complete arithmetic system, but as a system of scalar transposition.<br>In the case of a transposition by a fifth, for example, a definition<br>of the chromatic scale (such as the one mentioned above) is typically<br>used as a basis, and the transposition is understood as a shift of 7<br>scale degrees:

for i in range(0, 12):<br>pitch = chromatic_scale[i]<br>result = periodic.scalar_transpose(chromatic_scale, pitch, 7)<br>interval = pitch.interval(result)<br>print(f'{pitch.short_repr} --> {result.short_repr} ({interval.short_repr})')

1 --> 3/2 (3/2)<br>256/243 --> 128/81 (3/2)<br>9/8 --> 27/16 (3/2)<br>32/27 --> 16/9 (3/2)<br>81/64 --> 243/128 (3/2)<br>4/3 --> 2 (3/2)<br>1024/729 --> 512/243 (3/2)<br>3/2 --> 9/4 (3/2)<br>128/81 --> 64/27 (3/2)<br>27/16 --> 81/32 (3/2)<br>16/9 --> 8/3 (3/2)<br>243/128 --> 2048/729 (262144/177147)

As you can see with the last pitch of the output (\(\frac{243}{128}\)),<br>transposition by scale degree in a Pythagorean chromatic scale does<br>not always result in an actual transposition of the interval in question.<br>This is a common problem when tuning a keyboard instrument (such as a<br>piano or harpsichord) that has only a limited number of notes per octave.<br>Mathematically speaking, this definition of transposition by a fifth is<br>irregular: the size of the fifth changes depending on which note is chosen<br>as the starting point.

Unlike a keyboard instrument, a stringed instrument without frets or the<br>human voice does not have the problem of limited note selection.<br>Xenharmlib therefore implements its default transposition not as scalar<br>transposition, but as regular transposition, with the effect that the<br>result of transposing the last note of the above scale has a pitch<br>class no longer represented in the scale itself.

for i in range(0, 12):

pitch = chromatic_scale[i]<br>result = pitch.transpose(P5)<br>interval = pitch.interval(result)

try:<br>scale_degree = periodic.index(chromatic_scale, result)<br>except ValueError:<br>scale_degree = 'not in scale'

print(f'{pitch.short_repr} --> {result.short_repr} ', end='')<br>print(f'({interval.short_repr}) - degree: {scale_degree}')

1 --> 3/2 (3/2) - degree: 7<br>256/243 --> 128/81 (3/2) - degree: 8<br>9/8 --> 27/16 (3/2) - degree: 9<br>32/27 --> 16/9 (3/2) - degree: 10<br>81/64 --> 243/128 (3/2) - degree:...

xenharmlib pitch scale transposition result interval

Related Articles