Skip to content

[FEATURE] add the fluctuation strength of Osses et al. to pytta.psychoacoustics - #92

Open
aguirreSL wants to merge 3 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-fluctuation_osses
Open

aguirreSL wants to merge 3 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-fluctuation_osses

Conversation

@aguirreSL

Copy link
Copy Markdown

Builds on #91 (and so on #79), so until those are merged this pull request also shows their commits.

Adds fluctuation_strength_osses2016(signal, time_skip=0.0) to pytta.psychoacoustics, the fluctuation strength model of Osses, Garcia and Kohlrausch (2016). It returns FS(t) every 0.2 s over frames of 2 s, the specific fluctuation strength over 47 half-Bark channels and the mean FSmean, in vacil.

The model is the roughness model of Daniel and Weber, already in roughness_daniel1997, with the changes of the paper:

  1. Frames of 2 s with 90 % overlap, gated with ramps of 50 ms.
  2. A modulation weighting H(fmod), a second-order high-pass times a fourth-order low-pass.
  3. The generalised modulation depth m*, compressed 3:1 above 0.7.
  4. FS = C_FS Σ (m*i)^1.7 |k(i-2) k_i|^1.7 g(z_i), with C_FS set so that a 1 kHz tone at 60 dB, 100 % amplitude modulated at 4 Hz, gives 1 vacil.

The function is written from the paper, because SQAT's FluctuationStrength_Osses2016, with its H(fmod) data, is GPL-3.0. SQAT served only as the test oracle.

The result differs from SQAT, and the docstring says so. The paper gives the passband of H(fmod) (3.1 Hz to 12 Hz) but not the filter type. Read as Butterworth cut-offs, those values miss the AM tones of the paper's own Table 1 by up to 0.5 vacil. The cut-offs used here, 1.75 Hz and 13.5 Hz, were fitted to that table, as the paper fits its filter, which gives C_FS = 0.2480 against the 0.2490 of the paper. SQAT takes H(fmod) from data files that the paper does not describe. Against SQAT:

Signal Difference
1 kHz AM tones at 4 Hz, 48 kHz and 44.1 kHz -0.5 % and -0.7 %
1 kHz AM tone at 16 Hz +4.0 %
FM tone, 1500 Hz ± 700 Hz at 4 Hz +13.9 % (the paper notes that its model overestimates FM tones)
AM tone at 1 Hz about half of SQAT's value (0.21 against 0.38 vacil)

The tests in tests/test_psychoacoustics.py print the measured differences:

  1. The reference AM tone gives 1 vacil (within 1e-5).
  2. The AM tones at 70 dB of Table 1 of the paper, from 1 Hz to 32 Hz, are followed with an rms deviation of 0.09 vacil. The worst point is 1 Hz, at -0.18 vacil.
  3. The comparison with SQAT above, on golden data from tests/golden/make_fluctuation_sqat.m (MATLAB R2026b, same float32 samples), with tolerances of 1 %, 5 % and 15 %. The tone at 1 Hz is left out of this test and covered by test 2.
  4. Invalid input is rejected.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

aguirreSL and others added 3 commits October 31, 2026 21:39
…hness

Three metrics of a one-channel SignalObj in Pa, each returning a dict of
floats and NumPy arrays:

- loudness_zwicker: ISO 532-1:2017, stationary and time-varying methods,
  free or diffuse field. N (sone), LN (phon), the specific loudness over
  240 steps of 0.1 Bark and, time-varying, N(t), LN(t) and N'(t) every
  2 ms with Nmax and N5. Port of SQAT's Loudness_ISO532_1 (BSD-3, Ella
  Manor's AARAE code after the C code of the standard). Signals not at
  48 kHz are resampled as MATLAB's resample does (matches it to 2e-15).
- sharpness_din45692: DIN 45692:2009, Formula (1) on that specific
  loudness, k = 0.11; S, or S(t) and S50 for the time-varying method.
  Written from the standard.
- roughness_daniel1997: Daniel and Weber (1997), R(t), R'(t) over 47
  half-Bark channels and Rmean (asper). Port of SQAT's
  Roughness_Daniel1997 (MIT, Dik Hermes et al.).

The BSD-3 and MIT notices of the ported files are in the module header.

Validation. Against SQAT on golden data from
tests/golden/make_loudness_sqat.m and make_roughness_sqat.m (MATLAB
R2026b, same float32 samples): stationary loudness within 3e-13, time-
varying within 3.1e-8 sone (the nonlinear decay amplifies 3e-14 of
filter rounding on the decay of a burst), roughness within 2.8e-5 asper
(FFT rounding, 32 kHz input). ISO 532-1 Annex B: signal 1 (band levels)
83.2957 sone against 83.296; the standard's files of signals 2 to 5
within 0.034 sone (0.26 %); signals 6 to 25 keep N(t) within 5 % or
0.1 sone at every frame, max deviation 0.068 sone. DIN 45692: the 41 test
signals of Tables A.2 and A.3 within 0.45 of the tolerance (worst 10.5
kHz band, -0.19 acum), reference noise 1.02 acum. 1 kHz at 40 dB gives
0.999976 sone; the reference AM tone 1.000001 asper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
tonality_aures1985(signal, field='free', time_skip=0.0) gives the
tonality K(t) and its mean in tonality units: the tonal components of
Terhardt, Stoll and Seewann (1982) in Hann frames of 160 ms, weighted by
bandwidth, frequency and level excess, and the loudness ratio WGr of the
signal without and with them (Aures 1985).

It is written from the two papers. SQAT's Tonality_Aures1985 is GPL-3.0
and served only as the test oracle. The private helper of the Terhardt
excitation is shared with the roughness port, whose parity with SQAT is
unchanged.

Tests check the unit (a 1 kHz tone at 60 dB is 1 t.u.), the level excess
weighting against its formula, parity with SQAT on golden data from
tests/golden/make_tonality_sqat.m (tones within 3.4e-5 t.u., a tone in
noise within 0.012 t.u.) and the rejection of invalid input.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…oacoustics

fluctuation_strength_osses2016(signal, time_skip=0.0) gives FS(t) every
0.2 s over frames of 2 s, the specific fluctuation strength over 47
half-Bark channels and the mean FSmean, in vacil, after Osses, Garcia
and Kohlrausch (2016): the roughness model of Daniel and Weber with
frames of 2 s, a modulation weighting H(fmod), the generalised
modulation depth compressed above 0.7 and FS = C_FS sum (m*)^1.7
|k k|^1.7 g(z).

It is written from the paper. SQAT's FluctuationStrength_Osses2016 and
its H(fmod) data are GPL-3.0 and served only as the test oracle. The
paper does not give the filter type of H(fmod), so its cut-offs (1.75
and 13.5 Hz) were fitted to the AM tones of the paper's Table 1. The
result differs from SQAT, as the docstring states: within 1 % for AM
tones at 4 Hz, 4 % at 16 Hz, 14 % above for an FM tone, and about half
of SQAT's value for AM at 1 Hz.

Tests check the unit (1 vacil for the reference AM tone), the AM tones
of Table 1 (rms deviation 0.09 vacil), the comparison with SQAT on
golden data from tests/golden/make_fluctuation_sqat.m with the
tolerances above, and the rejection of invalid input.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant