# Check how to install FoxDot here. Video content explained below.

This article is dedicated to my fellow Xenharmonic enthusiasts.

On the Xenharmonic wiki, there is a lot of resource invested on how to train one’s ear. One other nice medium I have found, is to code the right tunings and scales in a live coding environment such as FoxDot, then play them via a SynthDef. To perform that, we first need a function. Take care, as we work in python, the white spaces have their importance :

def cumulative(exp):
    if (isinstance(exp, list)):
        for index in range(len(exp)):
            if index != 0:
                exp[index] = exp[index-1]+exp[index]
        return exp
        return exp

This function can take care of the modes we often see on the Xenharmonic wiki, and turns them to scales.

Let’s try some should we ?

Say we want to discover the different heptatonic Mavila modes in ET11 or 11-EDO. First we can, for example, open a class called ET11, containing the tuning list (in cents/100 : 1 octave is 12), and all our modes :

class ET11:
    tuning = PRange(12)*12/11
    chromatic = PRange(12)
    mavilaC = cumulative([0,1,1,1,3,1,1])
    mavilaD = cumulative([0,1,1,3,1,1,3])
    mavilaE = cumulative([0,1,3,1,1,3,1])
    mavilaF = cumulative([0,3,1,1,3,1,1])
    mavilaG = cumulative([0,1,1,3,1,1,1])
    mavilaA = cumulative([0,1,3,1,1,1,3])
    mavilaB = cumulative([0,3,1,1,1,3,1])
# Prange generates a list of n-1 numbers, so a PRange of 12 it gives P[0,1,2,3,4,5,6,7,8,9,10,11]
# The Pattern P[] from FoxDot allow us to operate on each list item.
# Multiplying by 12/11 gives the exact values needed.

Then, I have taken every mode, and removed the last number. Indeed, when building a scale from a mode, we need the degree 0 to be there. Then the scale loops on the higher iteration (octive, tritave,…, you name it).

Example given for the first line of Mavila (let’s call it Mavila C) :

# 1 1 1 3 1 1 3
# removing last degree
# 0 1 1 1 3 1 1

# Applying cumulative function
print(cumulative([0,1,1,1,3,1,1]) # >>> [0,1,2,3,6,7,8] | 8+3 equals 11

We see that our tuning and our scale are well built, so now we need to give them as default Scale to play :

Scale.default.set(ET11.mavilaC, tuning=ET11.tuning)

Now, lets play this scale in a player, and let’s feel all the good sounds :

sc >> blip(PTri(8),dur=1/2)
# The PTri generates a pattern going up and down n-1, here P[0,1,2,3,4,5,6,7,6,5,4,3,2,1,0]
# dur=1/2 means we play notes 1/2 beat each

And with this method, my friends, we can virtually listen to any tuning or scale anyone ever has dreamt of.

Cheers !