Godtone (talk | contribs)
My Python 3 code: correct function argument deduction
Godtone (talk | contribs)
My Python 3 code: add default badness measures for patent edos (& assuming pure-octave tunings), for arbitrary sets of intervals
Line 1,291: Line 1,291:


patent_vals = dict()
patent_vals = dict()
def et_badness(ivs,v,badness=lambda rel_err,x,et2: rel_err,combine=lambda badnesses: sum(badnesses),et2=0):
# the default badness is the sum of the squares of the errors with each interval's contribution weighted proportional to its odd-limit complexity,
# in terms of absolute (cent/octave) error (corresponding to the multiplication by et2).
def et_badness(ivs,v,badness=lambda rel_err,x,et2: rel_err**2 * iv_complexity(x) * et2,combine=lambda badnesses: sum(badnesses),et2=0):
global patent_vals
global patent_vals
if type(v)==int:
if type(v)==int:
Line 1,314: Line 1,316:
ivs = odd_lim(1,[],ivs)
ivs = odd_lim(1,[],ivs)
return combine([ badness3args(abs( map_iv(v,x) - steps(x,et2) ), x, et2) for x in ivs ])
return combine([ badness3args(abs( map_iv(v,x) - steps(x,et2) ), x, et2) for x in ivs ])
# if you just give a list or set of intervals (a,b), the default behaviour is to judge the badness of an edo as:
# * sum of squares of errors with each interval's contribution weighted proportional to its odd-limit complexity,
#  in term of absolute error (cent/octave) error
# * for edos in the 2 to 311 range (inclusive)
def optimal_edo_sequence(edo_badness,up_to=311):
def optimal_edo_sequence(edo_badness,up_to=311):
if type(edo_badness)==list or type(edo_badness)==set:
ivs = edo_badness
edo_badness = lambda edo: et_badness(ivs,edo)
best_edo = edo_badness(1)
best_edo = edo_badness(1)
best_edos = []
best_edos = []