a whole heap of crap
This commit is contained in:
parent
f937547991
commit
a6aed4fcc5
3 changed files with 202 additions and 56 deletions
119
run.py
119
run.py
|
@ -3,56 +3,79 @@
|
|||
from strings import print_ideal_stock
|
||||
|
||||
in_mm = 25.4
|
||||
scale_length = 648/in_mm
|
||||
default_scale_length = 648/in_mm
|
||||
|
||||
string_sets = {
|
||||
'regular light': (
|
||||
# (desired note, tension, and type)
|
||||
('E4' , 16, 'P'),
|
||||
('B3' , 16, 'P'),
|
||||
('G3' , 16, 'P'),
|
||||
('D3' , 16, 'W'),
|
||||
('A2' , 16, 'W'),
|
||||
('E2' , 16, 'W'),
|
||||
),
|
||||
'jazz light': (
|
||||
('E4' , 24, 'P'),
|
||||
('B3' , 24, 'P'),
|
||||
('G3' , 24, 'W'),
|
||||
('D3' , 24, 'W'),
|
||||
('A2' , 24, 'W'),
|
||||
('E2' , 24, 'W'),
|
||||
),
|
||||
'regular light (DADGAD)': (
|
||||
('D4' , 16, 'P'),
|
||||
('A3' , 16, 'P'),
|
||||
('G3' , 16, 'P'),
|
||||
('D3' , 16, 'W'),
|
||||
('A2' , 16, 'W'),
|
||||
('D2' , 16, 'W'),
|
||||
),
|
||||
'regular light (open G, 6)': (
|
||||
('D4' , 16, 'P'),
|
||||
('B3' , 16, 'P'),
|
||||
('G3' , 16, 'P'),
|
||||
('D3' , 16, 'W'),
|
||||
('B2' , 16, 'W'),
|
||||
('D2' , 16, 'W'),
|
||||
),
|
||||
'regular light (open G, 7)': (
|
||||
('D4' , 16, 'P'),
|
||||
('B3' , 16, 'P'),
|
||||
('G3' , 16, 'P'),
|
||||
('D3' , 16, 'W'),
|
||||
('B2' , 16, 'W'),
|
||||
('G2' , 16, 'W'),
|
||||
('D2' , 16, 'W'),
|
||||
),
|
||||
}
|
||||
sets = """
|
||||
regular light
|
||||
E4 16 PD
|
||||
B3 16 PD
|
||||
G3 16 PD
|
||||
D3 16 WD
|
||||
A2 16 WD
|
||||
E2 16 WD
|
||||
|
||||
print('for a scale length of {:>5.2f} inches'.format(scale_length))
|
||||
for name, strings in string_sets.items():
|
||||
jazz medium
|
||||
E4 24 PD
|
||||
B3 24 PD
|
||||
G3 24 WD
|
||||
D3 24 WD
|
||||
A2 24 WD
|
||||
E2 24 WD
|
||||
|
||||
regular light (DADGAD)
|
||||
D4 16 PD
|
||||
A3 16 PD
|
||||
G3 16 PD
|
||||
D3 16 WD
|
||||
A2 16 WD
|
||||
D2 16 WD
|
||||
|
||||
fanned-fret bass
|
||||
G2 35 WC 34.00
|
||||
D2 35 WC 34.75
|
||||
A1 35 WC 35.50
|
||||
E1 35 WC 36.25
|
||||
B0 35 WC 37.00
|
||||
|
||||
regular light (Open G 7-string)
|
||||
D4 16 PD
|
||||
B3 16 PD
|
||||
G3 16 PD
|
||||
D3 16 WD
|
||||
B2 16 WD
|
||||
G2 16 WD
|
||||
D2 16 WD
|
||||
"""
|
||||
|
||||
string_sets = {}
|
||||
sets = sets+'\n\n'
|
||||
title = None
|
||||
for line in sets.splitlines():
|
||||
if not line:
|
||||
title = None
|
||||
continue
|
||||
if not title:
|
||||
title = line
|
||||
string_sets[title] = []
|
||||
else:
|
||||
fields = line.split()
|
||||
note, tension = fields[0:2]
|
||||
tension = int(tension)
|
||||
|
||||
req = ''
|
||||
if len(fields) > 2:
|
||||
req = fields[2]
|
||||
|
||||
length = None
|
||||
if len(fields) > 3:
|
||||
length = float(fields[3])
|
||||
|
||||
string = (note, tension, req, length)
|
||||
string_sets[title].append(string)
|
||||
|
||||
print('for a scale length of {:>5.2f} inches'.format(default_scale_length))
|
||||
for name, strings in sorted(string_sets.items()):
|
||||
print()
|
||||
print('"{}"'.format(name))
|
||||
print_ideal_stock(strings, scale_length)
|
||||
print_ideal_stock(strings, default_scale_length)
|
||||
|
||||
|
|
84
run2.py
Executable file
84
run2.py
Executable file
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from strings import print_tensions
|
||||
|
||||
in_mm = 25.4
|
||||
default_scale_length = 648/in_mm
|
||||
|
||||
sets = """
|
||||
E standard (super light balanced)
|
||||
E4 DAPL009
|
||||
B3 DAPL012
|
||||
G3 DAPL015
|
||||
D3 DANW022
|
||||
A2 DANW030
|
||||
E2 DANW040
|
||||
|
||||
E standard (medium balanced)
|
||||
E4 DAPL011
|
||||
B3 DAPL015
|
||||
G3 DAPL019
|
||||
D3 DANW028
|
||||
A2 DANW037
|
||||
E2 DANW050
|
||||
|
||||
C standard (medium balanced)
|
||||
C4 DAPL011
|
||||
G3 DAPL015
|
||||
D#3 DAPL019
|
||||
A#2 DANW028
|
||||
F2 DANW037
|
||||
C2 DANW050
|
||||
|
||||
C standard (jazz medium)
|
||||
C4 DAPL013
|
||||
G3 DAPL017
|
||||
D#3 DANW026
|
||||
A#2 DANW036
|
||||
F2 DANW046
|
||||
C2 DANW056
|
||||
|
||||
C standard (CKS-G6-14-59mb)
|
||||
C4 CKPL014
|
||||
G3 CKPL019
|
||||
D#3 CKHW025
|
||||
A#2 CKHW033
|
||||
F2 CKHW045
|
||||
C2 CKHW059
|
||||
|
||||
B standard (CKS-G6-14-59mb)
|
||||
B3 CKPL014
|
||||
F#3 CKPL019
|
||||
D3 CKHW025
|
||||
A2 CKHW033
|
||||
E2 CKHW045
|
||||
B1 CKHW059
|
||||
|
||||
D standard drop C (medium balanced)
|
||||
D4 DAPL011
|
||||
A3 DAPL015
|
||||
F3 DAPL019
|
||||
C3 DANW028
|
||||
G2 DANW037
|
||||
C2 DANW050
|
||||
"""
|
||||
|
||||
string_sets = {}
|
||||
sets = sets+'\n\n'
|
||||
title = None
|
||||
for line in sets.splitlines():
|
||||
if not line:
|
||||
title = None
|
||||
continue
|
||||
if not title:
|
||||
title = line
|
||||
string_sets[title] = []
|
||||
else:
|
||||
note, string = line.split()
|
||||
string_sets[title].append((note, string))
|
||||
|
||||
print('for a scale length of {:>5.2f} inches'.format(default_scale_length))
|
||||
for name, strings in sorted(string_sets.items()):
|
||||
print()
|
||||
print('"{}"'.format(name))
|
||||
print_tensions(strings, default_scale_length)
|
55
strings.py
55
strings.py
|
@ -6,8 +6,8 @@ from notes import note2freq
|
|||
stock = []
|
||||
stock += daddario_plain_steel
|
||||
stock += daddario_nickle_wound
|
||||
#stock += circle_k_plain
|
||||
#stock += circle_k_hybrid_wound
|
||||
stock += circle_k_plain
|
||||
stock += circle_k_hybrid_wound
|
||||
|
||||
uw_const = 386.4
|
||||
def uw2tension(uw, freq, SL):
|
||||
|
@ -16,21 +16,39 @@ def uw2tension(uw, freq, SL):
|
|||
def tension2uw(t, freq, SL):
|
||||
return (t*uw_const)/(2*SL*freq)**2
|
||||
|
||||
outfmt = '{:<8} at {:> 5.2f} lb ({:>+4.2f})'
|
||||
finalfmt = 'total: {:>7.2f} lb ({:>+5.2f})'
|
||||
outfmt = '\
|
||||
{:<8} at {:>6.2f} lb ({:>+4.2f})'
|
||||
finalfmt = '\
|
||||
average: {:>7.2f} lb ({:>+5.2f})\n\
|
||||
total: {:>7.2f} lb ({:>+5.2f})'
|
||||
tension_outfmt = '\
|
||||
{:<3} {:<8} at {:>6.2f} lb'
|
||||
tension_finalfmt = '\
|
||||
average: {:>7.2f} lb\n\
|
||||
total: {:>7.2f} lb'
|
||||
|
||||
def print_ideal_stock(strings, scale_length=25.512):
|
||||
SL = scale_length
|
||||
total_tension = 0
|
||||
total_desired_tension = 0
|
||||
for note, tension, kind in strings:
|
||||
for note, tension, req, length in strings:
|
||||
freq = note2freq(note)
|
||||
if length:
|
||||
SL = length
|
||||
else:
|
||||
SL = scale_length
|
||||
uw = tension2uw(tension, freq, SL)
|
||||
|
||||
kind = len(req) > 0 and req[0]
|
||||
brand = len(req) > 1 and req[1]
|
||||
|
||||
closest = ('n/a', 0)
|
||||
for name, stock_uw in stock:
|
||||
if kind == 'P' and name[2] != 'P':
|
||||
if kind and kind == 'P' and name[2] != 'P':
|
||||
continue
|
||||
if kind == 'W' and name[3] != 'W':
|
||||
if kind and kind == 'W' and name[3] != 'W':
|
||||
continue
|
||||
if brand and brand[0] != name[0]:
|
||||
continue
|
||||
if abs(stock_uw - uw) < abs(closest[1] - uw):
|
||||
closest = (name, stock_uw)
|
||||
|
@ -43,7 +61,28 @@ def print_ideal_stock(strings, scale_length=25.512):
|
|||
total_desired_tension += tension
|
||||
|
||||
error = total_tension - total_desired_tension
|
||||
print(finalfmt.format(total_tension, error))
|
||||
average_tension = total_tension/len(strings)
|
||||
average_error = error/len(strings)
|
||||
print(finalfmt.format(average_tension, average_error, total_tension, error))
|
||||
|
||||
def print_tensions(strings, scale_length=25.512):
|
||||
SL = scale_length
|
||||
total_tension = 0
|
||||
for note, name in strings:
|
||||
freq = note2freq(note)
|
||||
uw = 0
|
||||
for stock_name, stock_uw in stock:
|
||||
if name == stock_name or name + '*' == stock_name:
|
||||
uw = stock_uw
|
||||
break
|
||||
if uw:
|
||||
tension = uw2tension(uw, freq, SL)
|
||||
else:
|
||||
tension = 0
|
||||
print(tension_outfmt.format(note, name, tension))
|
||||
total_tension += tension
|
||||
|
||||
print(tension_finalfmt.format(total_tension/len(strings), total_tension))
|
||||
|
||||
if __name__ == '__main__':
|
||||
# DAd's data is all screwy so we use change scale lengths for a best-fit
|
||||
|
|
Loading…
Reference in a new issue