Skip to content

Commit

Permalink
adapt score computations to be closer to other reviewers
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreaubert committed Aug 11, 2023
1 parent 1586fd5 commit 695d0a3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ repos:
- id: fix-encoding-pragma
- id: requirements-txt-fixer
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-csslint
Expand All @@ -26,6 +26,6 @@ repos:
- id: csslint
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.275'
rev: 'v0.0.282'
hooks:
- id: ruff
22 changes: 10 additions & 12 deletions datas/eq/Donner Dyna 4/iir-autoeq.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
EQ for Donner Dyna 4 computed from ASR data
Preference Score 2.75 with EQ 5.76
Preference Score 2.58 with EQ 5.27
Generated from http://github.com/pierreaubert/spinorama/generate_peqs.py v0.24
Dated: 2023-08-05-01:27:14
Dated: 2023-08-08-11:48:53

Preamp: -1.9 dB
Preamp: -1.8 dB

Filter 1: ON PK Fc 125 Hz Gain -2.98 dB Q 1.28
Filter 2: ON PK Fc 187 Hz Gain -2.63 dB Q 1.03
Filter 3: ON PK Fc 584 Hz Gain +1.32 dB Q 2.77
Filter 4: ON PK Fc 844 Hz Gain +1.83 dB Q 2.00
Filter 5: ON PK Fc 2380 Hz Gain -2.97 dB Q 2.99
Filter 6: ON PK Fc 3325 Hz Gain +2.98 dB Q 1.58
Filter 7: ON PK Fc 6937 Hz Gain -2.82 dB Q 1.49
Filter 8: ON PK Fc 8199 Hz Gain -2.91 dB Q 1.05
Filter 9: ON PK Fc 10020 Hz Gain -1.50 dB Q 1.28
Filter 1: ON PK Fc 125 Hz Gain -4.13 dB Q 1.28
Filter 2: ON PK Fc 200 Hz Gain -1.93 dB Q 1.45
Filter 3: ON PK Fc 625 Hz Gain +1.86 dB Q 2.20
Filter 4: ON PK Fc 873 Hz Gain +1.54 dB Q 2.72
Filter 5: ON PK Fc 3555 Hz Gain +3.94 dB Q 1.86
Filter 6: ON PK Fc 6069 Hz Gain -1.68 dB Q 0.27
Filter 7: ON PK Fc 7669 Hz Gain -4.82 dB Q 1.10
5 changes: 4 additions & 1 deletion src/spinorama/c_compute_scores.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ cpdef double c_lfx(const double[:] freq, const double[:] lw, const double[:] sp)
lfx_list = list(next(lfx_grouped))
if len(lfx_list) <= 1:
return LFX_DEFAULT
return math.log10(lfx_list[-1][1])
pos = lfx_list[-1][0]
if len(freq) < pos-1:
pos = pos +1
return math.log10(freq[pos])

cpdef double c_sm(const double[:] freq, const double[:] spl):
"""Compute SM see details in compute_scores.py"""
Expand Down
20 changes: 14 additions & 6 deletions src/spinorama/compute_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def nbd(dfu: pd.DataFrame, min_freq: float) -> float:
[
mad(dfu.loc[(dfu.Freq >= bmin) & (dfu.Freq <= bmax)].dB)
for (bmin, bcenter, bmax) in octave(2)
if bmin_freq <= bmin and bmax <= 12000
if bmin_freq <= bcenter and bcenter <= 12000
]
)

Expand All @@ -124,15 +124,23 @@ def lfx(lw, sp) -> float:
lw_ref = np.mean(lw_data) if not lw_data.empty else 0.0
lw_ref -= 6.0
# find first freq such that y[freq]<y_ref-6dB
lfx_range = sp.loc[(sp.Freq < 300) & (sp.dB <= lw_ref)].Freq
if len(lfx_range.values) == 0:
lfx_range = sp.loc[(sp.Freq <= 300) & (sp.dB <= lw_ref)].Freq
if lfx_range.shape[0] == 0:
# happens with D&D 8C when we do not have a point low enough to get the -6
return math.log10(sp.Freq.to_numpy()[0])

# trying to deal with oscillating bass range
# trick is: index is contiguous, the filter above make creates hole
lfx_grouped = consecutive_groups(lfx_range.items(), lambda x: x[0])
try:
lfx_hz = list(next(lfx_grouped))[-1][1]
# grab the last group and return freq
lfx_last = list(next(lfx_grouped))[-1]
lfx_pos = lfx_last[0]
# get the next freq to be more inlined with the other people computing the code
# nothing wrong if you remove the +1
lfx_hz = (sp.Freq)[lfx_pos + 1]
except Exception:
# some speaker measurements start above 300Hz
return LFX_DEFAULT
return math.log10(lfx_hz)

Expand Down Expand Up @@ -252,13 +260,13 @@ def speaker_pref_rating(cea2034, pir, rounded):
"nbd_pred_in_room": round_down(nbd_pred_in_room, 3),
"sm_pred_in_room": round_down(sm_pred_in_room, 3),
"sm_sound_power": round_down(sm_sound_power, 3),
"pref_score_wsub": round_down(pref_wsub, 1),
"pref_score_wsub": round_down(pref_wsub, 2),
}
if aad_on_axis != -1.0:
ratings["aad_on_axis"] = round_down(aad_on_axis, 3)
ratings["lfx_hz"] = int(pow(10, lfx_hz)) # in Hz
ratings["lfq"] = round_down(lfq_db, 3)
ratings["pref_score"] = round_down(pref, 1)
ratings["pref_score"] = round_down(pref, 2)
else:
ratings = {
"nbd_on_axis": nbd_on_axis,
Expand Down

0 comments on commit 695d0a3

Please sign in to comment.