Commit baece1e
committed
Create working THD analyzer script
Mimic the structure of the "measure frequency" script. Previously the
THD functions just printed their results, but now that they return
values that isn't going to work.
Clarify that THD+N is (R) by default and THD is (F) by default.
Keep `thd_analyzer()` so that `thd_analyzer_launcher.py` works, too.
Verified that both THD+N(R) and THD(F), in both percent and dB, match my
XLS calculator:
```shell
λ python scripts\thd_analyzer.py "whine noise test -10 -20 -15 -25 -30 -20 -35 dBFS.wav"
Analyzing "whine noise test -10 -20 -15 -25 -30 -20 -35 dBFS.wav"...
THD+N(R): 59.9492% or -4.4 dB
THD(F): 74.9008% or -2.5 dB
```
And these match the claimed values as well:
```
File Claimed
Reference (440Hz) 0.0%
Single-ended triode (440SE) 5.0%
Solid state (440SS) 0.5%
```
```shell
λ python scripts\thd_analyzer.py tests\thd_files\440Hz.wav
Analyzing "tests\thd_files\440Hz.wav"...
-- Left and Right channels are identical --
THD+N(R): 0.0022% or -93.3 dB
THD(F): 0.0013% or -98.0 dB
λ python scripts\thd_analyzer.py tests\thd_files\440SE.wav
Analyzing "tests\thd_files\440SE.wav"...
-- Left channel --
THD+N(R): 5.0649% or -25.9 dB
THD(F): 5.0714% or -25.9 dB
-- Right channel --
THD+N(R): 5.0648% or -25.9 dB
THD(F): 5.0713% or -25.9 dB
λ python scripts\thd_analyzer.py tests\thd_files\440SS.wav
Analyzing "tests\thd_files\440SS.wav"...
-- Left channel --
THD+N(R): 0.5124% or -45.8 dB
THD(F): 0.5062% or -45.9 dB
-- Right channel --
THD+N(R): 0.5124% or -45.8 dB
THD(F): 0.5061% or -45.9 dB
```1 parent 48657be commit baece1e
2 files changed
+38
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 5 | + | |
32 | 6 | | |
33 | 7 | | |
34 | | - | |
35 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
36 | 19 | | |
| 20 | + | |
| 21 | + | |
37 | 22 | | |
38 | 23 | | |
39 | 24 | | |
40 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
41 | 28 | | |
42 | 29 | | |
43 | 30 | | |
44 | 31 | | |
45 | 32 | | |
46 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments