Skip to main content

multislope

Multi-slope sound energy decay estimation for room impulse responses.

Rooms rarely decay with a single reverberation time. Coupled volumes, non-diffuse fields, and strongly absorbing surfaces produce energy decay curves that need two or three exponentials to be described well. multislope estimates those decay times, their amplitudes, and the noise floor, per octave band, from a measured RIR.

pip install multislope

The core install is NumPy, SciPy, and ONNX Runtime — no PyTorch required.

Quickstart

import multislope
import soundfile as sf

rir, fs = sf.read("my_rir.wav")

net = multislope.DecayFitNet(sample_rate=fs)
fit = net.estimate(rir)

print(fit)
# DecayFit(method='DecayFitNet', sample_rate=48000)
#      125 Hz  T = [0.690] s  A = [0.963]  N = 1.9e-08
#      250 Hz  T = [0.530, 2.303] s  A = [0.787, 0.0634]  N = 1.15e-09
#   ...

fit.t          # (n_bands, n_slopes) decay times in seconds; 0 marks an inactive slope
fit.a          # (n_bands, n_slopes) amplitudes, linear scale
fit.n          # (n_bands, 1) noise floor, linear scale
fit.n_slopes   # (n_bands,) number of active slopes per band

Reconstruct the fitted EDC to compare it against the measured one:

import numpy as np

pre = multislope.PreprocessRIR(sample_rate=fs)
measured_edc, _ = pre.schroeder(rir)              # (n_channels, n_bands, n_samples)
time_axis = np.arange(measured_edc.shape[-1]) / fs

fitted_edc = fit.edc(time_axis)                   # (n_bands, n_samples)

Methods

DecayFitNet BayesianDecayAnalysis
Approach trained neural network (bundled, ~10 MB of ONNX weights) slice sampling over a discrete parameter grid
Speed milliseconds per RIR seconds to minutes per RIR
Slopes 1–3, either fixed or estimated by the network 1–3, either fixed or selected by BIC
Needs training data already trained no
Determinism deterministic stochastic; pass seed= to reproduce

Both take the same arguments and return the same DecayFit:

net = multislope.DecayFitNet(n_slopes=0, sample_rate=fs)          # 0 = estimate the count
bda = multislope.BayesianDecayAnalysis(n_slopes=0, sample_rate=fs, n_iterations=100, seed=0)

fit_net = net.estimate(rir)
fit_bayes = bda.estimate(rir)

Options

Fixing the number of slopes. n_slopes=2 fits exactly two slopes and skips model-order selection. n_slopes=0 lets the estimator decide, and inactive slopes come back with T = A = 0.

Frequency bands. The default bands are 125 Hz to 4 kHz. Pass your own centre frequencies; a 0 adds a lowpass band below the lowest octave, and sample_rate / 2 adds a highpass band above the highest one.

net = multislope.DecayFitNet(sample_rate=fs, filter_frequencies=[0, 125, 250, 500, 1000, 2000, 4000, fs / 2])

Direct sound. By default the whole RIR is analysed. Pass analyse_full_rir=False to detect the direct-sound onset and discard everything before it.

Analysing an EDC directly. If you already have an energy decay curve, pass input_is_edc=True to skip filtering and backwards integration.

Example data

The example RIRs from the DecayFitNet repository are downloaded on first use and cached locally, so they are not part of the wheel:

from multislope import data

rir, fs = data.example_rir("doubleslope")
print(data.available_examples())

Optional extras

pip install multislope[plot]    # matplotlib helpers in multislope.plotting
pip install multislope[train]   # PyTorch training code in multislope.training

multislope.training re-exports the original DecayFitNet training pipeline (dataset, model definition, and EDC loss) for anyone who wants to retrain or fine-tune the network. It is not needed for inference.

Attribution

The DecayFitNet and Bayesian estimators, and the bundled network weights, are derived from the DecayFitNet toolbox by Georg Götz, Sebastian J. Schlecht, and Ville Pulkki, used under the MIT license. This package ports the Python toolbox to NumPy/SciPy, packages it for PyPI, and keeps its numerics unchanged (verified by regression tests against the reference implementation).

If you use this software, please cite:

@article{goetz2022decayfitnet,
  title   = {Neural network for multi-exponential sound energy decay analysis},
  author  = {G{\"o}tz, Georg and Schlecht, Sebastian J. and Pulkki, Ville},
  journal = {The Journal of the Acoustical Society of America},
  volume  = {152},
  number  = {2},
  pages   = {942--953},
  year    = {2022},
  doi     = {10.1121/10.0013416}
}

The Bayesian analysis follows Xiang et al., "Bayesian characterization of multiple-slope sound energy decays in coupled-volume systems", JASA 129(2), 741–752, 2011, and Jasa & Xiang, "Efficient estimation of decay parameters in acoustically coupled-spaces using slice sampling", JASA 126(3), 1269–1279, 2009.

Development

git clone https://github.com/artificial-audio/multislope
cd multislope
pip install -e ".[dev]"

python -m multislope.data download   # the regression tests analyse the example RIRs
pytest                               # full suite, including torch parity and slow Bayesian tests
pytest -m "not slow"                 # fast subset
ruff check .

The regression tests compare every estimate against tests/data/golden_upstream.npz, captured by running the reference PyTorch implementation. scripts/make_golden_fixtures.py regenerates it; see its docstring for how.

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multislope-0.1.0.tar.gz (9.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multislope-0.1.0-py3-none-any.whl (8.8 MB view details)

Uploaded Python 3

File details

Details for the file multislope-0.1.0.tar.gz.

File metadata

  • Download URL: multislope-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for multislope-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0847b194db46625ec5418efdfd1ffc9f862e5e22a8072202932ea4d92a8b0023
MD5 6507f456a374cf98d129bee3ab8f5b77
BLAKE2b-256 5b39c300ca92a3288fa827ac2d811b0d1c32616ee6e226f9e5ecd8108ecdd4ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for multislope-0.1.0.tar.gz:

Publisher: publish.yml on artificial-audio/multislope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file multislope-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: multislope-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for multislope-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 356da9df924a8c5bab4e832a8ffe9d296b126a43b0e4c704123c3747c4b3662a
MD5 4d6249ffaddf75b56b4e559d284afb2c
BLAKE2b-256 8f68b773db31f782e3ffbcf62d3e3adf173a88b9af79166c13301e654274ca63

See more details on using hashes here.

Provenance

The following attestation bundles were made for multislope-0.1.0-py3-none-any.whl:

Publisher: publish.yml on artificial-audio/multislope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 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