Godtone (talk | contribs)
m My Python 3 code: make sort order ascending for increased intuitiveness
Godtone (talk | contribs)
My Python 3 code: FIX OLD BUG FINALLY (i just wasnt looking very carefully apparently)
Line 721: Line 721:
p = prime_lim(prime_idx( len(f)-1 ))
p = prime_lim(prime_idx( len(f)-1 ))
return sum([ f[i]*round(steps(p[i],et2)) for i in range(len(f)) ])
return sum([ f[i]*round(steps(p[i],et2)) for i in range(len(f)) ])
def map_iv(val_map, x): # assumes same harmonic subgroup
def map_iv(val_map, x, sg=None): # assumes same harmonic subgroup
x = convert(x,list)
if not sg:
x = convert(x,list)
elif type(x)!=list:
x = fact(x,sg)
return sum([ x[i]*val_map[i] for i in range(len(x)) ])
return sum([ x[i]*val_map[i] for i in range(len(x)) ])
# returns the signed error of an interval according to a val map
# returns the signed error of an interval according to a val map, afterwards optionally specifying a specific subgroup and/or equave;
def iv_map_err(x, m, equave=2): # assumes m[0] = period/equave
# note that the equave can be used to compare to a tempered-octave/tritave tuning as it doesn't affect the mapping by map_iv
return map_iv(m,x) - steps(x,ed(m[0],equave))
# (which under normal usage should always output an integer, though you can make it output floats too but the codebase isn't designed for handling that)
def iv_map_err(x, m, sg_or_equave_1=None, sg_or_equave_2=None): # assumes m[0] = period/equave
sg = sg_or_equave_1 if type(sg_or_equave_1)==list else sg_or_equave_2 if type(sg_or_equave_2)==list else None
equave = sg_or_equave_1 if type(sg_or_equave_1) in [int,float] else sg_or_equave_2 if type(sg_or_equave_2) in [int,float] else 2
return map_iv(m,x,sg) - steps(x,ed(m[0],equave))
def sgn(x):
def sgn(x):
if x > 0:
if x > 0: