Godtone
Joined 17 December 2020
WARNING: breaking change: previous instances of weighting=1 should be replaced with weighting=0, in favour of the weighting argument being the exponent of the odd-limit complexity by default |
m helper function i wrote for finding useful commas in sets of intervals |
||
| Line 1,524: | Line 1,524: | ||
mincomplexity = min(mincomplexity,len(mediant_path( mul_iv(x,(2**octs,1)) ))) | mincomplexity = min(mincomplexity,len(mediant_path( mul_iv(x,(2**octs,1)) ))) | ||
return mincomplexity | return mincomplexity | ||
# showmode: minimum number of equated interval pairs (incl. distinct octave-complements). | |||
# if minimum isnt reached, only the spacing interval is shown. 0 means dont print anything. | |||
# for odd-limits, to look for "multiple indistinction commas", use 3 for showmode. | |||
def spaces_in_set(ivs,max_cents = 100,showmode = 1): | |||
spaces = dict() | |||
if type(max_cents) in [tuple,float,int]: | |||
max_cents = steps(max_cents,ed(1200)) | |||
for lower in ivs: | |||
for upper in ivs: | |||
diff = div_iv(upper,lower) | |||
if 0 < steps(diff,ed(1200)) <= max_cents: | |||
if diff not in spaces: | |||
spaces[diff] = [(upper,lower)] | |||
else: | |||
spaces[diff].append((upper,lower)) | |||
commas = [comma for comma in spaces] | |||
commas.sort(key=lambda x: steps(x,1)) | |||
if showmode: | |||
for comma in commas: | |||
print(striv(comma)+':',', '.join([ | |||
'('+striv(ivpair[0])+')/('+striv(ivpair[1])+')' for ivpair in spaces[comma] | |||
if len(spaces[comma])>=showmode | |||
])) | |||
print() | |||
return spaces | |||
</syntaxhighlight> | </syntaxhighlight> | ||