User:Xenwolf/Python: Difference between revisions
Jump to navigation
Jump to search
m expanded |
+1 |
||
| Line 28: | Line 28: | ||
1\171 EDO --- 7.01754 | 1\171 EDO --- 7.01754 | ||
</pre> | </pre> | ||
== Generate EDO exposés == | |||
The following script creates most of the parameters for the EDO info boxes (1..99): | |||
<syntaxhighlight lang="python"> | |||
import math | |||
# formatted size string | |||
def ed_interval_size(steps, division=12, equiv=2, digits=0): | |||
return f'{math.log(equiv, 2)/division*steps * 1200:.{digits}f}' | |||
def ed_expose(n): | |||
p5s = round(n*math.log(3/2, 2)) | |||
p5c = round(p5s*1200/n) | |||
p5 = f'{p5s}\{n} ({p5c}¢)' | |||
M2s = (2*p5s) % n | |||
M2c = round(M2s*1200/n) | |||
M2 = f'{M2s}\{n} ({M2c}¢)' | |||
m2s = 3*n - 5*p5s | |||
m2c = round(m2s*1200/n) | |||
m2 = f'{m2s}\{n} ({m2c}¢)' | |||
A1s = M2s - m2s | |||
A1c = round(A1s*1200/n) | |||
A1 = f'{A1s}\{n} ({A1c}¢)' | |||
print(f'{n} EDO ') | |||
print(f'| Step size = {ed_interval_size(1, n, 2, 5)}¢') | |||
print(f'| Fifth = {p5}') | |||
print(f'| Major 2nd = {M2}') | |||
print(f'| Minor 2nd = {m2}') | |||
print(f'| Augmented 1sn = {A1}') | |||
print() | |||
# some examples | |||
for n in range(1, 100): | |||
ed_expose(n) | |||
</syntaxhighlight> | |||
Revision as of 22:20, 12 June 2021
... just snippets ...
Calculate ED step size
import math
# formatted size string
def ed_interval_size(steps, division=12, equiv=2, digits=0):
return f'{math.log(equiv, 2)/division*steps * 1200:.{digits}f}'
# some examples
print('1\\271 EDT --- ', ed_interval_size(1, 271, 3, 5))
print('1\\100 EDF --- ', ed_interval_size(1, 100, 3/2, 5))
print('1\\171 EDO --- ', ed_interval_size(1, 171, 2, 5))
The equivalence intervals are:
Output of above script:
1\271 EDT --- 7.01828 1\100 EDF --- 7.01955 1\171 EDO --- 7.01754
Generate EDO exposés
The following script creates most of the parameters for the EDO info boxes (1..99):
import math
# formatted size string
def ed_interval_size(steps, division=12, equiv=2, digits=0):
return f'{math.log(equiv, 2)/division*steps * 1200:.{digits}f}'
def ed_expose(n):
p5s = round(n*math.log(3/2, 2))
p5c = round(p5s*1200/n)
p5 = f'{p5s}\{n} ({p5c}¢)'
M2s = (2*p5s) % n
M2c = round(M2s*1200/n)
M2 = f'{M2s}\{n} ({M2c}¢)'
m2s = 3*n - 5*p5s
m2c = round(m2s*1200/n)
m2 = f'{m2s}\{n} ({m2c}¢)'
A1s = M2s - m2s
A1c = round(A1s*1200/n)
A1 = f'{A1s}\{n} ({A1c}¢)'
print(f'{n} EDO ')
print(f'| Step size = {ed_interval_size(1, n, 2, 5)}¢')
print(f'| Fifth = {p5}')
print(f'| Major 2nd = {M2}')
print(f'| Minor 2nd = {m2}')
print(f'| Augmented 1sn = {A1}')
print()
# some examples
for n in range(1, 100):
ed_expose(n)