Godtone
Joined 17 December 2020
m →MOSS names i think are pretty: update orwelloid -> gramitonic |
→My Python 3 code: rename function for converting a text string containing a list of intervals into an actual list of those intervals to "scalestr", and add function for interleaving "interleave" |
||
| Line 1,431: | Line 1,431: | ||
return optimal_edo_sequence(lambda edo: et_badness(ivs,edo,lambda rel_err: rel_err**2,weighting,combine,mapping),edo_set) | return optimal_edo_sequence(lambda edo: et_badness(ivs,edo,lambda rel_err: rel_err**2,weighting,combine,mapping),edo_set) | ||
def | def scalestr(liststr): | ||
commastrs = [] | commastrs = [] | ||
if ',' in liststr: | if ',' in liststr: | ||
| Line 1,439: | Line 1,439: | ||
return [iv( int(comma.split('/')[0]), int(comma.split('/')[1]) ) for comma in commastrs] | return [iv( int(comma.split('/')[0]), int(comma.split('/')[1]) ) for comma in commastrs] | ||
# find positive (possibly contorted) comma for a^n ~ b and by default print the result | |||
def continuumpt(a,b,n,printcomma=1): # assumes n >= 0 | def continuumpt(a,b,n,printcomma=1): # assumes n >= 0 | ||
comma = div_iv( (a[0]**n[0], a[1]**n[0]), (b[0]**n[1], b[1]**n[1]) ) | comma = div_iv( (a[0]**n[0], a[1]**n[0]), (b[0]**n[1], b[1]**n[1]) ) | ||
| Line 1,453: | Line 1,454: | ||
else: | else: | ||
return comma | return comma | ||
# note: the default can be used to get n octaves of an interval set (ivs) contained in the 1/1 to 2/1 range | |||
def interleave(n,ivs,offset=(2,1)): # https://en.xen.wiki/w/Interleaving | |||
totalivs = [] | |||
for i in range(n): | |||
totalivs = totalivs + [mul_iv( *([x] + [equave]*i) ) for x in ivs if x not in totalivs] | |||
totalivs.sort(key=lambda x: as_float(x)) | |||
return totalivs | |||
</syntaxhighlight> | </syntaxhighlight> | ||