Godtone (talk | contribs)
→Novation Launchpad Pro MK3 isomorphic keyboard code: avoid needing to reassign midi output in (EG) scaleworkshop
Godtone (talk | contribs)
→My Python 3 code: AGS-generating function "ags" and CS-checking function "cs"
Line 1,090: Line 1,090:
def mulmediant(r, k):
def mulmediant(r, k):
return (r[0]*k, r[1]*k)
return (r[0]*k, r[1]*k)
def ags(gs,n=0,ave=2):
if n==0:
n = len(gs)*2 + 1
scale = [(1,1)]
gi = 0
while len(scale) < n:
scale.append(reduce(mul_iv( scale[-1], gs[gi] ),ave))
gi = (gi+1)%len(gs)
scale.sort(key=lambda x: as_float(x))
scale.append((ave,1))
return scale[1:]
# returns [] if cs or details of earliest counterexample if not;
# "earliest" is defined as "search all 1-steps from beginning to end, then all 2-steps, etc."
def cs(scale_in):
stepmap = dict()
scale = scale_in.copy()
n = len(scale)
scale = scale + [ mul_iv(x,scale[-1]) for x in scale ]
for j in range(1,(n+1)//2):
for i in range(n):
interval = div_iv( scale[i], scale[i+j] )
if interval in stepmap:
if stepmap[interval] != j:
return [interval, i, j]
else:
stepmap[interval] = j
return []
</syntaxhighlight>
</syntaxhighlight>