Pythagorean (or other) tunings

I received an e-mail from someone asking about using a Pythagorean tuning in SCAMP, so I thought I’d answer it here and let you all see!

If you want to play back pitches in a 12-step Pythagorean tuning you can use the Scale object from scamp_extensions to do the work for you. Here’s how that might work:

# defining the scale; could put this in a separate file and import the pg object
from scamp_extensions.pitch import ScaleType, Scale

# specify the tuning (you can also load scales from a scala file with `ScaleType.load_from_scala`
pythagorean_scale_type = ScaleType("2187/2048", "9/8", "32/27", "81/64", "4/3", "729/512", "3/2",  "6561/4096", "27/16", "16/9", "243/128", "2/1")

pg = Scale(pythagorean_scale_type, 0)


# main script
from scamp import *

s = Session()

clarinet = s.new_part("clarinet")

# play individual notes
for pitch in range(60, 73):
    clarinet.play_note(pg[pitch], 0.7, 0.5)

# play sequence of perfect 5ths
for pitch in range(60, 73):
    clarinet.play_chord(pg[pitch, pitch + 7], 0.7, 0.5)

By having the scale start on MIDI pitch 0, you can just index in with the standard MIDI pitch, and it will give you the Pythagorean-tuned version. Also, as demonstrated with the play_chord call above, you can can index into a scale with multiple values and get a list of Pythagorean-tuned pitches in return.

If you want to center the pythagorean tuning on a different pitch, you can do, e.g.:

pythagorean_scale_type.rotate(5) 

Hope that’s helpful to you all!

Marc

P.S. If this is useful to you, maybe join my Patreon (https://www.patreon.com/marcevanstein)?