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 original implementation was developed by Georg Götz. Both estimators in this package, and the bundled network weights, come from his DecayFitNet toolbox, written with Sebastian J. Schlecht and Ville Pulkki and released under the MIT license. The network architecture, the training procedure that produced the weights, and the Bayesian analysis are all his work.
What this package adds is packaging, not method: the Python toolbox is ported from PyTorch to NumPy/SciPy, published to PyPI with the weights bundled, and given a common API that further estimators can plug into. The numerics are unchanged, and regression tests against the reference implementation are what verify that.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multislope-0.1.1.tar.gz.
File metadata
- Download URL: multislope-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0d549052e479714f8b14f842727483599dc3b027d313a413054788f31e2c288
|
|
| MD5 |
f9921b09711cbc89bedde916805d2c6b
|
|
| BLAKE2b-256 |
0ebe9f67a405c7686d9403d590c60c3f1119dbd6f3b40599a1ae1b79edabfcf0
|
Provenance
The following attestation bundles were made for multislope-0.1.1.tar.gz:
Publisher:
publish.yml on artificial-audio/multislope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
multislope-0.1.1.tar.gz -
Subject digest:
b0d549052e479714f8b14f842727483599dc3b027d313a413054788f31e2c288 - Sigstore transparency entry: 2334885161
- Sigstore integration time:
-
Permalink:
artificial-audio/multislope@aaf8f00df4819b8e5f71468568a885a55e141137 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/artificial-audio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aaf8f00df4819b8e5f71468568a885a55e141137 -
Trigger Event:
push
-
Statement type:
File details
Details for the file multislope-0.1.1-py3-none-any.whl.
File metadata
- Download URL: multislope-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdeab48063a6e25e305740f0a8f130b83454ff87c2f4e8beec5875f6c2ab0d43
|
|
| MD5 |
cdf338e63ff225df21bf9e403b26d6e7
|
|
| BLAKE2b-256 |
28372202d098c9450e8517d6d51880a80b4c78e0d08ffeaddfb6f4d6cf012aa3
|
Provenance
The following attestation bundles were made for multislope-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on artificial-audio/multislope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
multislope-0.1.1-py3-none-any.whl -
Subject digest:
bdeab48063a6e25e305740f0a8f130b83454ff87c2f4e8beec5875f6c2ab0d43 - Sigstore transparency entry: 2334885170
- Sigstore integration time:
-
Permalink:
artificial-audio/multislope@aaf8f00df4819b8e5f71468568a885a55e141137 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/artificial-audio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aaf8f00df4819b8e5f71468568a885a55e141137 -
Trigger Event:
push
-
Statement type: