stringcalc 0.1.0.dev17__tar.gz → 0.1.0.dev18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/.pre-commit-config.yaml +1 -1
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/.readthedocs.yaml +2 -2
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/PKG-INFO +2 -2
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/README.md +14 -14
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/api.rst +1 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/examples/compare-data.md +108 -88
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/examples/gauge-suggest.md +75 -75
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/examples/pythagoras-ratios.md +57 -57
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/examples/tension-plot.md +106 -106
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/index.md +54 -54
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/prior-art.md +53 -53
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/pyproject.toml +1 -1
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/__init__.py +1 -1
- stringcalc-0.1.0.dev18/stringcalc/data/daddario-stp.csv +621 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/tension.py +40 -4
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/.flake8 +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/LICENSE +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/cli.rst +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/cli_gauge-suggest_tb23nw.svg +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/cli_gauge-suggest_tb23nw_d.svg +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/conf.py +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/docs/panel.rst +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/cli.py +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/data/__init__.py +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/data/aquila-nng.csv +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/data/daddario-tension.csv +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/data/ghs.csv +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/data/stringjoy.csv +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/data/worth.csv +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/frets.py +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/py.typed +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/stringcalc/util.py +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/tests/test_frets.py +0 -0
- {stringcalc-0.1.0.dev17 → stringcalc-0.1.0.dev18}/tests/test_string.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stringcalc
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev18
|
|
4
4
|
Summary: Calculations for instrument strings
|
|
5
5
|
Author-email: zmoon <zmoon92@gmail.com>
|
|
6
|
-
Requires-Python: ~=3.
|
|
6
|
+
Requires-Python: ~=3.10
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
9
|
License-File: LICENSE
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# stringcalc
|
|
2
|
-
|
|
3
|
-
_Calculations for [string instrument](https://en.wikipedia.org/wiki/String_instrument)s' strings_
|
|
4
|
-
|
|
5
|
-
[](https://pypi.org/project/stringcalc/)
|
|
6
|
-
[](https://github.com/zmoon/stringcalc/actions/workflows/ci.yml)
|
|
7
|
-
[](https://stringcalc.readthedocs.io/en/latest/)
|
|
8
|
-
[](https://www.repostatus.org/#wip)
|
|
9
|
-
|
|
10
|
-
```sh
|
|
11
|
-
stringcalc gauge --suggest -T 17 -L 23 -P G2 -P D3 -P A3 -P E4 -N 6 --type DA:LEW --type DA:LE --no-column-info
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
<img src="./docs/cli_gauge-suggest_tb23nw.svg" alt="CLI gauge suggestion output for 23" TB for D'Addario loop-end nickel-wound strings" width="550">
|
|
1
|
+
# stringcalc
|
|
2
|
+
|
|
3
|
+
_Calculations for [string instrument](https://en.wikipedia.org/wiki/String_instrument)s' strings_
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/stringcalc/)
|
|
6
|
+
[](https://github.com/zmoon/stringcalc/actions/workflows/ci.yml)
|
|
7
|
+
[](https://stringcalc.readthedocs.io/en/latest/)
|
|
8
|
+
[](https://www.repostatus.org/#wip)
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
stringcalc gauge --suggest -T 17 -L 23 -P G2 -P D3 -P A3 -P E4 -N 6 --type DA:LEW --type DA:LE --no-column-info
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
<img src="./docs/cli_gauge-suggest_tb23nw.svg" alt="CLI gauge suggestion output for 23" TB for D'Addario loop-end nickel-wound strings" width="550">
|
|
@@ -29,6 +29,7 @@ https://github.com/zmoon/stringcalc/tree/main/data.
|
|
|
29
29
|
stringcalc.tension.load_data
|
|
30
30
|
stringcalc.tension.load_aquila_data
|
|
31
31
|
stringcalc.tension.load_daddario_data
|
|
32
|
+
stringcalc.tension.load_daddario_stp_data
|
|
32
33
|
stringcalc.tension.load_ghs_data
|
|
33
34
|
stringcalc.tension.load_stringjoy_data
|
|
34
35
|
stringcalc.tension.load_worth_data
|
|
@@ -1,88 +1,108 @@
|
|
|
1
|
-
---
|
|
2
|
-
file_format: mystnb
|
|
3
|
-
kernelspec:
|
|
4
|
-
name: python3
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Compare data
|
|
8
|
-
|
|
9
|
-
In this example, we compare data from different manufacturers
|
|
10
|
-
for
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
data
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
---
|
|
2
|
+
file_format: mystnb
|
|
3
|
+
kernelspec:
|
|
4
|
+
name: python3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Compare data
|
|
8
|
+
|
|
9
|
+
In this example, we compare data from different manufacturers
|
|
10
|
+
for common ball-end string types:
|
|
11
|
+
|
|
12
|
+
- plain steel
|
|
13
|
+
- phosphor bronze
|
|
14
|
+
- nickel-wound
|
|
15
|
+
|
|
16
|
+
```{code-cell} ipython3
|
|
17
|
+
import pandas as pd
|
|
18
|
+
|
|
19
|
+
from stringcalc.tension import load_data
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
First we load all of the available data with the {func}`~stringcalc.tension.load_data` function.
|
|
23
|
+
|
|
24
|
+
```{code-cell} ipython3
|
|
25
|
+
data = load_data()
|
|
26
|
+
data
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Plain steel
|
|
30
|
+
|
|
31
|
+
Plain steel ball-end strings.
|
|
32
|
+
|
|
33
|
+
```{code-cell} ipython3
|
|
34
|
+
group_ids = ["DA:PL", "STP:PL", "GHS:PL", "SJ:PL"]
|
|
35
|
+
(
|
|
36
|
+
data.query("group_id in @group_ids")
|
|
37
|
+
.pivot_table(
|
|
38
|
+
index="gauge",
|
|
39
|
+
columns="group_id",
|
|
40
|
+
values=["uw"],
|
|
41
|
+
observed=True,
|
|
42
|
+
)
|
|
43
|
+
.mul(1000)
|
|
44
|
+
.style
|
|
45
|
+
.set_caption("Plain steel")
|
|
46
|
+
.background_gradient(axis=1, cmap="RdBu_r")
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```{note}
|
|
51
|
+
We multiplied `uw`, the unit weight (mass per unit length) [lbm/in]
|
|
52
|
+
by 1000 to facilitate easier comparison.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```{note}
|
|
56
|
+
Within a given row, a red cell background indicates higher values and blue lower.
|
|
57
|
+
For example, Stringjoy plain steel strings are generally heavier than the others (red),
|
|
58
|
+
and D'Addario original and STP are always quite close (same color).
|
|
59
|
+
The lack of a number in a cell indicates that we don't have data for that gauge.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Phosphor bronze
|
|
63
|
+
|
|
64
|
+
Phosphor bronze ball-end strings.
|
|
65
|
+
|
|
66
|
+
```{code-cell} ipython3
|
|
67
|
+
group_ids = ["DA:PB", "STP:PB", "GHS:B", "SJ:PB"]
|
|
68
|
+
(
|
|
69
|
+
data.query("group_id in @group_ids")
|
|
70
|
+
.pivot_table(
|
|
71
|
+
index="gauge",
|
|
72
|
+
columns="group_id",
|
|
73
|
+
values=["uw"],
|
|
74
|
+
observed=True,
|
|
75
|
+
)
|
|
76
|
+
.mul(1000)
|
|
77
|
+
.style
|
|
78
|
+
.set_caption("Phosphor bronze")
|
|
79
|
+
.background_gradient(axis=1, cmap="RdBu_r")
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Nickel-wound
|
|
84
|
+
|
|
85
|
+
Nickel-wound ball-end strings.
|
|
86
|
+
|
|
87
|
+
- `DA:NW` and `STP:NW`: D'Addario nickel-plated steel
|
|
88
|
+
- `GHS:N`: GHS Nickel Rockers (pure nickel, semi-flattened)
|
|
89
|
+
- `GHS:DY`: GHS Boomers (nickel-plated steel)
|
|
90
|
+
- `SJ:N`: Stringjoy nickel ("Signatures"; nickel-plated steel?)
|
|
91
|
+
- `SJ:PN`: Stringjoy pure nickel ("Broadways")
|
|
92
|
+
|
|
93
|
+
```{code-cell} ipython3
|
|
94
|
+
group_ids = ["DA:NW", "STP:NW", "GHS:N", "GHS:DY", "SJ:N", "SJ:PN"]
|
|
95
|
+
(
|
|
96
|
+
data.query("group_id in @group_ids")
|
|
97
|
+
.pivot_table(
|
|
98
|
+
index="gauge",
|
|
99
|
+
columns="group_id",
|
|
100
|
+
values=["uw"],
|
|
101
|
+
observed=True,
|
|
102
|
+
)
|
|
103
|
+
.mul(1000)
|
|
104
|
+
.style
|
|
105
|
+
.set_caption("Nickel-wound")
|
|
106
|
+
.background_gradient(axis=1, cmap="RdBu_r")
|
|
107
|
+
)
|
|
108
|
+
```
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
---
|
|
2
|
-
file_format: mystnb
|
|
3
|
-
kernelspec:
|
|
4
|
-
name: python3
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Gauge suggest
|
|
8
|
-
|
|
9
|
-
We can use the {doc}`/api` or the {doc}`/cli` to do this.
|
|
10
|
-
For example, consider this Irish tenor banjo situation
|
|
11
|
-
(also shown in [the GitHub README](https://github.com/zmoon/stringcalc/blob/main/README.md)):
|
|
12
|
-
|
|
13
|
-
- target tension: 17 lbf
|
|
14
|
-
- scale length: 23"
|
|
15
|
-
- tuning: G{sub}`2` D{sub}`3` A{sub}`3` E{sub}`4`
|
|
16
|
-
- string types: D'Addario loop-end nickel-wound and plain steel (`DA:LEW` and `DA:LE`)
|
|
17
|
-
|
|
18
|
-
## API
|
|
19
|
-
|
|
20
|
-
We use the function {func}`stringcalc.tension.suggest_gauge`.
|
|
21
|
-
|
|
22
|
-
```{code-cell} ipython3
|
|
23
|
-
:tags: [hide-output]
|
|
24
|
-
|
|
25
|
-
from stringcalc.tension import suggest_gauge
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
```{code-cell} ipython3
|
|
29
|
-
T = 17
|
|
30
|
-
L = 23
|
|
31
|
-
pitches = ["G2", "D3", "A3", "E4"]
|
|
32
|
-
types = {"DA:LEW", "DA:LE"}
|
|
33
|
-
|
|
34
|
-
for pitch in pitches:
|
|
35
|
-
df = suggest_gauge(T, L, pitch, types=types, n=6)
|
|
36
|
-
display(
|
|
37
|
-
df
|
|
38
|
-
.style
|
|
39
|
-
.set_caption(f'{pitch}, target T = {T} lbf')
|
|
40
|
-
.highlight_min(df.dT.abs().argmin())
|
|
41
|
-
)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Most players would prefer a wound A string.
|
|
45
|
-
The 018w is probably a better choice than the 017p here, tone- and balance-wise,
|
|
46
|
-
even though it is farther from the target tension.
|
|
47
|
-
|
|
48
|
-
## CLI
|
|
49
|
-
|
|
50
|
-
On the command-line, we can do the same thing
|
|
51
|
-
with `stringcalc gauge --suggest`:
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
stringcalc gauge --suggest -T 17 -L 23 -P G2 -P D3 -P A3 -P E4 -N 6 --type DA:LEW --type DA:LE --no-column-info
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```{image} ../cli_gauge-suggest_tb23nw.svg
|
|
58
|
-
:alt: CLI gauge suggestion output for 23" TB for D'Addario loop-end nickel-wound strings
|
|
59
|
-
:width: 550
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
`--no-column-info` suppresses the descriptions of the columns,
|
|
64
|
-
which currently are repeated for each boxed result.
|
|
65
|
-
For a single string query, it looks like this:
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
stringcalc gauge --suggest -T 17 -L 23 -P D3 --type DA:LEW
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
```{image} ../cli_gauge-suggest_tb23nw_d.svg
|
|
72
|
-
:alt: CLI gauge suggestion output for 23" TB D string using D'Addario loop-end nickel-wound strings
|
|
73
|
-
:width: 450
|
|
74
|
-
|
|
75
|
-
```
|
|
1
|
+
---
|
|
2
|
+
file_format: mystnb
|
|
3
|
+
kernelspec:
|
|
4
|
+
name: python3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Gauge suggest
|
|
8
|
+
|
|
9
|
+
We can use the {doc}`/api` or the {doc}`/cli` to do this.
|
|
10
|
+
For example, consider this Irish tenor banjo situation
|
|
11
|
+
(also shown in [the GitHub README](https://github.com/zmoon/stringcalc/blob/main/README.md)):
|
|
12
|
+
|
|
13
|
+
- target tension: 17 lbf
|
|
14
|
+
- scale length: 23"
|
|
15
|
+
- tuning: G{sub}`2` D{sub}`3` A{sub}`3` E{sub}`4`
|
|
16
|
+
- string types: D'Addario loop-end nickel-wound and plain steel (`DA:LEW` and `DA:LE`)
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
We use the function {func}`stringcalc.tension.suggest_gauge`.
|
|
21
|
+
|
|
22
|
+
```{code-cell} ipython3
|
|
23
|
+
:tags: [hide-output]
|
|
24
|
+
|
|
25
|
+
from stringcalc.tension import suggest_gauge
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```{code-cell} ipython3
|
|
29
|
+
T = 17
|
|
30
|
+
L = 23
|
|
31
|
+
pitches = ["G2", "D3", "A3", "E4"]
|
|
32
|
+
types = {"DA:LEW", "DA:LE"}
|
|
33
|
+
|
|
34
|
+
for pitch in pitches:
|
|
35
|
+
df = suggest_gauge(T, L, pitch, types=types, n=6)
|
|
36
|
+
display(
|
|
37
|
+
df
|
|
38
|
+
.style
|
|
39
|
+
.set_caption(f'{pitch}, target T = {T} lbf')
|
|
40
|
+
.highlight_min(df.dT.abs().argmin())
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Most players would prefer a wound A string.
|
|
45
|
+
The 018w is probably a better choice than the 017p here, tone- and balance-wise,
|
|
46
|
+
even though it is farther from the target tension.
|
|
47
|
+
|
|
48
|
+
## CLI
|
|
49
|
+
|
|
50
|
+
On the command-line, we can do the same thing
|
|
51
|
+
with `stringcalc gauge --suggest`:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
stringcalc gauge --suggest -T 17 -L 23 -P G2 -P D3 -P A3 -P E4 -N 6 --type DA:LEW --type DA:LE --no-column-info
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```{image} ../cli_gauge-suggest_tb23nw.svg
|
|
58
|
+
:alt: CLI gauge suggestion output for 23" TB for D'Addario loop-end nickel-wound strings
|
|
59
|
+
:width: 550
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`--no-column-info` suppresses the descriptions of the columns,
|
|
64
|
+
which currently are repeated for each boxed result.
|
|
65
|
+
For a single string query, it looks like this:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
stringcalc gauge --suggest -T 17 -L 23 -P D3 --type DA:LEW
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```{image} ../cli_gauge-suggest_tb23nw_d.svg
|
|
72
|
+
:alt: CLI gauge suggestion output for 23" TB D string using D'Addario loop-end nickel-wound strings
|
|
73
|
+
:width: 450
|
|
74
|
+
|
|
75
|
+
```
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
---
|
|
2
|
-
file_format: mystnb
|
|
3
|
-
kernelspec:
|
|
4
|
-
name: python3
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Pythagoras ratios
|
|
8
|
-
|
|
9
|
-
```{code-cell} ipython3
|
|
10
|
-
from fractions import Fraction
|
|
11
|
-
|
|
12
|
-
from stringcalc.frets import distances
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Define the ratios
|
|
16
|
-
|
|
17
|
-
I first saw these in [this StackExchange post](https://music.stackexchange.com/questions/93731/does-guitar-fret-spacing-solely-depend-on-the-length-of-the-string).
|
|
18
|
-
The same diagram can be found [here](https://passyworldofmathematics.com/guitar-mathematics/), which seems to be the original source.
|
|
19
|
-
I used [this table](https://en.wikipedia.org/wiki/Pythagorean_tuning#Method) to fill in (most of) the gaps (leaving out fret 6 since it is ambiguous).
|
|
20
|
-
|
|
21
|
-
```{code-cell} ipython3
|
|
22
|
-
# This maps the fret number to the relative distance to the saddle.
|
|
23
|
-
ratios = {
|
|
24
|
-
1: "243/256",
|
|
25
|
-
2: "8/9",
|
|
26
|
-
3: "27/32",
|
|
27
|
-
4: "64/81",
|
|
28
|
-
5: "3/4",
|
|
29
|
-
7: "2/3",
|
|
30
|
-
8: "81/128",
|
|
31
|
-
9: "16/27",
|
|
32
|
-
10: "9/16",
|
|
33
|
-
11: "128/243",
|
|
34
|
-
12: "1/2",
|
|
35
|
-
}
|
|
36
|
-
ratios = {k: Fraction(v) for k, v in ratios.items()}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Compare to our equal-temperament calculations
|
|
40
|
-
|
|
41
|
-
We use {func}`stringcalc.frets.distances`.
|
|
42
|
-
|
|
43
|
-
```{code-cell} ipython3
|
|
44
|
-
df = distances(12, L=1)
|
|
45
|
-
df["Pythagoras"] = df.index.map(ratios)
|
|
46
|
-
df["Pythagoras float"] = df["Pythagoras"].astype(float)
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
df
|
|
50
|
-
.assign(**{
|
|
51
|
-
"Δ": df["Pythagoras float"] - df["d_inv"],
|
|
52
|
-
"Equal temperament": df["d_inv"]}
|
|
53
|
-
)
|
|
54
|
-
[["Pythagoras", "Pythagoras float", "Equal temperament", "Δ"]]
|
|
55
|
-
.fillna("")
|
|
56
|
-
)
|
|
57
|
-
```
|
|
1
|
+
---
|
|
2
|
+
file_format: mystnb
|
|
3
|
+
kernelspec:
|
|
4
|
+
name: python3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pythagoras ratios
|
|
8
|
+
|
|
9
|
+
```{code-cell} ipython3
|
|
10
|
+
from fractions import Fraction
|
|
11
|
+
|
|
12
|
+
from stringcalc.frets import distances
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Define the ratios
|
|
16
|
+
|
|
17
|
+
I first saw these in [this StackExchange post](https://music.stackexchange.com/questions/93731/does-guitar-fret-spacing-solely-depend-on-the-length-of-the-string).
|
|
18
|
+
The same diagram can be found [here](https://passyworldofmathematics.com/guitar-mathematics/), which seems to be the original source.
|
|
19
|
+
I used [this table](https://en.wikipedia.org/wiki/Pythagorean_tuning#Method) to fill in (most of) the gaps (leaving out fret 6 since it is ambiguous).
|
|
20
|
+
|
|
21
|
+
```{code-cell} ipython3
|
|
22
|
+
# This maps the fret number to the relative distance to the saddle.
|
|
23
|
+
ratios = {
|
|
24
|
+
1: "243/256",
|
|
25
|
+
2: "8/9",
|
|
26
|
+
3: "27/32",
|
|
27
|
+
4: "64/81",
|
|
28
|
+
5: "3/4",
|
|
29
|
+
7: "2/3",
|
|
30
|
+
8: "81/128",
|
|
31
|
+
9: "16/27",
|
|
32
|
+
10: "9/16",
|
|
33
|
+
11: "128/243",
|
|
34
|
+
12: "1/2",
|
|
35
|
+
}
|
|
36
|
+
ratios = {k: Fraction(v) for k, v in ratios.items()}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Compare to our equal-temperament calculations
|
|
40
|
+
|
|
41
|
+
We use {func}`stringcalc.frets.distances`.
|
|
42
|
+
|
|
43
|
+
```{code-cell} ipython3
|
|
44
|
+
df = distances(12, L=1)
|
|
45
|
+
df["Pythagoras"] = df.index.map(ratios)
|
|
46
|
+
df["Pythagoras float"] = df["Pythagoras"].astype(float)
|
|
47
|
+
|
|
48
|
+
(
|
|
49
|
+
df
|
|
50
|
+
.assign(**{
|
|
51
|
+
"Δ": df["Pythagoras float"] - df["d_inv"],
|
|
52
|
+
"Equal temperament": df["d_inv"]}
|
|
53
|
+
)
|
|
54
|
+
[["Pythagoras", "Pythagoras float", "Equal temperament", "Δ"]]
|
|
55
|
+
.fillna("")
|
|
56
|
+
)
|
|
57
|
+
```
|