Repository navigation
Conversation
pytta.iso532_2.loudness(frequencies, levels, field, ears) gives the loudness and loudness level of stationary sounds by the Moore-Glasberg method of ISO 532-2:2017, for monaural, diotic and dichotic listening: transfer to the tympanic membrane (free field, diffuse field or eardrum) and to the oval window (Table 1), excitation patterns from rounded-exponential filters whose lower slope depends on the level (Formulae (1) to (6)), specific loudness from 1.8 to 38.9 Cam (Tables 2 to 4, Formulae (7) to (9)), binaural inhibition (Formulae (10) to (13)) and the loudness level of Table 5. noise_band_components and third_octave_components give the components of noise bands (5.3) and of one-third octave band levels, the latter as the program of Annex C does. Written from the text of the standard, with its program (Annex C, downloadable from the ISO portal) read to settle the one-third octave components, where the program and the examples of Annex B use base-2 bands with 10 or 20 components while the text of 5.5 describes components every 10 Hz or 1 Hz. Tests check every result of Annex B and all 28 rows of Table 5 within one unit of the last printed digit, that the same sound at both ears is 1.5 times as loud as at one ear, that a sound at one ear only is not inhibited, and the rejection of invalid input. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
pytta.iso532_2, the loudness of stationary sounds by the Moore-Glasberg method of ISO 532-2:2017, for monaural, diotic and dichotic listening. The ITA-Toolbox reaches this method throughita_psychoacoustic_loudness, a wrapper of the MATLAB Audio Toolbox.loudness(frequencies, levels, field='free', ears='both'): the sound is given as sinusoidal components (Clause 5), with levels of shape (n,) for the same sound at both ears or (n, 2) for the left and right ears.fieldis'free','diffuse'or'eardrum', andears='one'gives the monaural loudness. It returns N (sone), LN (phon), the specific loudness from 1.8 to 38.9 Cam and the loudness of each ear.noise_band_components(f1, f2, spectrum_level, pink=False): the components of a band of white or pink noise (5.3).third_octave_components(levels): the components of 29 one-third octave band levels from 25 Hz to 16 kHz.loudness_level(N): Table 5, linear in lg N.The method follows the text of the standard. The sound is carried to the tympanic membrane and to the oval window (Table 1). The excitation patterns come from rounded-exponential filters whose lower slope depends on the level (Formulae (1) to (6)). The specific loudness follows Tables 2 to 4 and Formulae (7) to (9), and the binaural inhibition Formulae (10) to (13). The earphone correction files of 7.2.3 are not included. A flat response at the tympanic membrane is
field='eardrum'.Regarding the one-third octave levels, the program of Annex C (C source, downloadable from the ISO portal) does not do what the text of 5.5 describes. The text places components every 10 Hz (or 1 Hz up to 125 Hz) in base-10 bands. The program uses base-2 bands with 10 components up to 315 Hz and 20 from 400 Hz, and it produced the examples of Annex B.
third_octave_componentsfollows the program, which is also the scheme closer to those examples. The program was only read, to settle this point.The tests in
tests/test_iso532_2.pyuse the standard as the oracle. Its values are printed with two to four significant digits, so a value passes when it lies within one unit of the last printed digit:The MATLAB function
acousticLoudnesswithMethod='ISO 532-2'and one-third octave input, whichita_psychoacoustic_loudnesscalls, gives other values than the program of the standard. For example, it gives 5.59 sone for a single 1 kHz band at 63 dB, where this module gives 5.52, and 9.32 sone for a spectrum that falls 10 dB per octave from 80 dB at 25 Hz, where this module gives 6.01. For tones, the values of this module are those of Annex B. So that function was not used as the oracle.Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of
development(3 intest_h5io.py, 4 intest_pyttasave.py) are the same with and without this change.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com