# LoudnessModel

> Part of [LISQM](https://zhenxianli.github.io/LISQM/) (List of Implementations of Sound Quality Metrics), a list of open-source implementations of psychoacoustic metrics. Data as of 2026-10-28. Web page: https://zhenxianli.github.io/LISQM/projects/loudnessmodel.html

Python translation of the Cambridge MATLAB code for the TVL2018 loudness model: Moore et al. (2016) with the revised time constants of Moore et al. (2018). Computes instantaneous, short-term and long-term loudness, in a NumPy version and a JAX version.

- **Repository:** https://github.com/MalcolmSlaney/LoudnessModel
- **Language:** Python
- **Kind:** Research code (Code published with a study, a thesis or a student project, to run or adapt; not packaged as a library.)
- **Group:** developing (Public for more than a year, but without a publication or documented use by others: research, teaching or personal code.)
- **Licence:** BSD-2-Clause — The README also says "The source code is provided free for any research purposes"; the readme of the Cambridge MATLAB code tv2018.m (see iso532-3) uses similar wording and asks commercial users to contact Brian C. J. Moore.
- **Latest release:** no release
- **Last commit:** 2025-03-20 (inactive since 2025-03)
- **GitHub stars:** 19
- **Maintainers:** Jeremy JX Hsiao, Malcolm Slaney
- **AI assistance:** not stated
- **How to cite:** The project does not say how to cite it. Cite the repository with the version or commit you used.
- **Entry checked:** 2026-10-06

## What it implements

| Metric | Edition | Functions | Status | Validation (as stated) | Notes |
|---|---|---|---|---|---|
| [Time-varying loudness (Moore–Glasberg–Schlittenlacher)](https://zhenxianli.github.io/LISQM/metrics/loudness-moore-glasberg-time-varying.html) | [Moore et al. (2018)](https://doi.org/10.1121/1.5027246) (instantaneous, short-term and long-term loudness; binaural) | `tvl2018.compute_loudness`, `tvl2018_jax.compute_loudness` | available | own tests only | — |

## How it was validated

As reported by the project; LISQM has not run the code. Two implementations that agree can still share the same error.

- [Time-varying loudness (Moore–Glasberg–Schlittenlacher)](https://zhenxianli.github.io/LISQM/metrics/loudness-moore-glasberg-time-varying.html), Moore et al. (2018): own tests only
  - Ported or adapted from [iso532-3 (tv2018.m)](https://zhenxianli.github.io/LISQM/projects/js2251-iso532-3.html).
  - Tests run in GitHub Actions compare overall loudness, the first five short-term and long-term values and selected intermediate stages for one input (1 kHz tone, 100 ms, 32 kHz) with hard-coded expected values.
  - The README calls this "a known accurate output", but neither it nor the tests say where the values come from.

## Notes

- The README credits Brian C. J. Moore, Brian R. Glasberg and Josef Schlittenlacher for the MATLAB model and links the original MATLAB code (the first download on https://www.psychol.cam.ac.uk/hearing#programs). That page now needs a University of Cambridge login; an [archived copy](https://web.archive.org/web/20251123130736/https://www.psychol.cam.ac.uk/hearing) from November 2025 still links the code, an earlier version of the code in [iso532-3](https://github.com/js2251/iso532-3).
- The Python function names largely mirror the MATLAB files of tv2018 (see [iso532-3](https://github.com/js2251/iso532-3)), e.g. `agc_next_frame` for `AGCNextFrame.m`. ISO 532-3 is not mentioned in the repository.
- Outer- and middle-ear transfer functions for free-field, diffuse-field and eardrum presentation are included for 32 kHz.
- There is no packaging metadata (no pyproject.toml or setup.py) and no PyPI package; the README installs from a clone with requirements.txt. A Colab notebook with demos is linked.

## Before you rely on it

- The README says the JAX version "does not compile as there are several portions of the implementation that are not pure".

## Sources

- https://github.com/MalcolmSlaney/LoudnessModel
- https://github.com/MalcolmSlaney/LoudnessModel/blob/main/README.md
- https://github.com/MalcolmSlaney/LoudnessModel/blob/main/tvl2018_test.py
- https://github.com/MalcolmSlaney/LoudnessModel/blob/main/LICENSE
