gists/string_tensions/run.py
2018-10-11 16:45:37 +02:00

81 lines
1.3 KiB
Python
Executable file

#!/usr/bin/python
from strings import print_ideal_stock
in_mm = 25.4
default_scale_length = 648/in_mm
sets = """
regular light
E4 16 PD
B3 16 PD
G3 16 PD
D3 16 WD
A2 16 WD
E2 16 WD
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, default_scale_length)