Skip to main content

MetaSona

Psychoacoustic metrics in C, with a typed Python interface.

MetaSona packages compiled C implementations in a Python wheel to reduce computation time for repeated psychoacoustic analysis, while keeping a simple NumPy interface. The speed comes from the native implementation; the wheel makes that implementation easy to install.

Function Calculates Unit
stationary_loudness Zwicker loudness from audio sone
loudness_from_levels Zwicker loudness from 28 third-octave levels sone
time_varying_loudness Zwicker loudness over time sone
roughness_daniel_weber Daniel–Weber roughness asper
tonality_aures Aures tonality dimensionless
sharpness_din45692 Sharpness from specific loudness acum
loudness_ecma ECMA-418-2:2025 loudness, including tonal/noise separation sone_HMS
roughness_ecma ECMA-418-2:2025 roughness asper_HMS
tonality_ecma ECMA-418-2:2025 psychoacoustic tonality tu_HMS

The current version is experimental, particularly roughness and tonality. Standards conformance has not been established.

The metrics draw on SQAT revision e6228b789fc9. Aures tonality uses 250 ms windows and 125 ms hops. MetaSona returns every complete frame with centre timestamps; see implementation credits and differences.

Computation time

Measured September 2026 with the SQAT-aligned MetaSona wheel. Median of five warmed calls for 10 s of 48 kHz audio (1 kHz carrier, 70 Hz AM plus noise, 60 dB SPL), Ryzen 9 5950X, Windows. MetaSona: MSVC Release; MoSQITo: 1.2.1; imports and audio I/O are excluded.

Metric MetaSona MoSQITo Speedup vs MoSQITo
Stationary loudness 0.090 s 0.220 s 2.4×
Time-varying loudness 0.233 s 17.092 s 73.5×
Roughness 1.448 s 22.754 s 15.7×
Aures tonality 0.572 s Not available —

These are workload timings; models and outputs differ. Native filtering and channel processing contribute to speed alongside FFTs; compiler and framing differences also affect timings.

Python

MetaSona requires Python 3.9–3.14. Install the published package from PyPI with pip:

python -m pip install metasona

Or add it to a uv project:

uv add metasona

Prebuilt wheels are published for Windows x64, Linux x64/ARM64, and macOS Intel/Apple silicon, so these installations do not require a C compiler.

To install from a source checkout instead, use python -m pip install . or uv add /path/to/metasona. Building from source requires a C11 compiler.

Pass calibrated pressure in pascals, not uncalibrated audio samples. The ECMA functions accept mono (samples,) or stereo (samples, 2) arrays; the other functions accept mono arrays. Python accepts integer sample rates from 8 to 192 kHz and resamples to 48 kHz when needed. Results include their units and read-only NumPy arrays.

Applications that receive calibrated mono audio in chunks can use RollingAnalyzer to compute selected metrics over bounded rolling windows. The analyzer is synchronous and device-independent, so callers retain control of capture and concurrency. See the rolling analysis API and complete rolling example.

For ECMA loudness and tonality together, use result = ms.ecma_tonal_analysis(pressure_pa, fs) and read result.loudness and result.tonality. Loudness/tonality require at least 304 ms of audio; roughness requires 320 ms. Representative values exclude the initial filter transient. ECMA loudness implements Section 8, whereas MoSQITo's loudness_ecma implements the Section 5 basis calculation. ECMA roughness does not apply the optional entropy weighting. Function and result-class docstrings describe output shapes, units, timing and binaural combination.

import numpy as np
import metasona as ms

# One second of a 1 kHz tone at 60 dB SPL (0.02 Pa RMS).
fs = 48_000
t = np.arange(fs) / fs
pressure_pa = np.sqrt(2) * 0.02 * np.sin(2 * np.pi * 1_000 * t)

loudness = ms.stationary_loudness(pressure_pa, fs, sound_field="free")
sharpness = ms.sharpness_din45692(loudness.specific_loudness_sone_per_bark)

print(f"Loudness: {loudness.loudness_sone:.3f} sone")
print(f"Sharpness: {sharpness.sharpness_acum:.3f} acum")

See the Python API and complete example.

C library

Requires CMake 3.21 or newer and a C11 compiler:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cmake --install build --config Release --prefix install

Include <metasona/metasona.h> and link the installed CMake target MetaSona::metasona. Native signal functions require 48 kHz input. Use -DMS_BUILD_SHARED=OFF for a static library.

See the C API and C example.

License and credits

GPL-3.0 for the combined distribution, with retained Apache-2.0, BSD-3-Clause and MIT component notices. See third-party credits.

Acknowledgements

Developed by Jiahua Zhang with assistance from OpenAI Codex.

Developed during PhD research within the METAVISION MSCA Doctoral Network.

The European Commission is gratefully acknowledged for their support of the Horizon Europe DN METAVISION project (GA 101072415). Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union. The European Union cannot be held responsible for them.

Release files for metasona 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metasona 0.2.2
File Size Uploaded
metasona-0.2.2.tar.gz 100.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for metasona 0.2.2
File
metasona-0.2.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
metasona-0.2.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
metasona-0.2.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
metasona-0.2.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
metasona-0.2.2-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 953.1 kB

Release files / metasona-0.2.2.tar.gz

Download URL metasona-0.2.2.tar.gz
Size 100.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c50f2f9fe37a5496cc670055de9b0d625989d9142344eabe23ff3e9245feecbc
BLAKE2b-256 checksum
How to use checksums
e7328ba657f7b74b3c07ac12cf5f2f4d8bafca38fee077b116eb447bc38663ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / metasona-0.2.2-py3-none-win_amd64.whl

Download URL metasona-0.2.2-py3-none-win_amd64.whl
Size 169.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
7026181240768c67c98dd6e4df2155dfe6596dedd3cde0e5a8145c7360cfcdb3
BLAKE2b-256 checksum
How to use checksums
aa94ba2cd06b4592918279bbd99dfa2247e397abf79d5b7f0d6df4b32c2e4775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / metasona-0.2.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL metasona-0.2.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 160.2 kB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
02152b40336527ef17bd97c51a9af182ce16e9f1a5780c7b1e961216d9174ea0
BLAKE2b-256 checksum
How to use checksums
25729487e3e9145485eaf3385f37e40e1587a1b9efb0603789ea17d3735fffe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / metasona-0.2.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL metasona-0.2.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 165.2 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
5f4e7fa0eb39f6e955a75e6996cc073fc4f23379060e4d8c79691e1eca6295ca
BLAKE2b-256 checksum
How to use checksums
c79275a0b11617e982040818f2c581a1dde68befe030844d03531ea789ae3ac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / metasona-0.2.2-py3-none-macosx_11_0_arm64.whl

Download URL metasona-0.2.2-py3-none-macosx_11_0_arm64.whl
Size 170.1 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
506eee0819bd9c2a9b0d45ee6c12fd201d4a9676407c963412c8b308e2f607fa
BLAKE2b-256 checksum
How to use checksums
90bb9ed8ee057661a62d05f6d106def73cafab7fc7a962a4a7944528151b3939
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / metasona-0.2.2-py3-none-macosx_10_9_x86_64.whl

Download URL metasona-0.2.2-py3-none-macosx_10_9_x86_64.whl
Size 186.9 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
43c34e011fb9071b7b65d6755d7687f01a416c854175bc32b909bfc7ab45f9db
BLAKE2b-256 checksum
How to use checksums
b62e884a1cb369714064594a163324f69937c9b5f032fbe84627c6590cc6f5b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.2 This release

6 release files

0.2.1

6 release files

0.2.0

6 release files

0.1.1

6 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page