Music Perception Toolbox (Python)
Perceptually and cognitively motivated measures of pitch similarity, consonance, and the structure of scales and rhythms.
The toolbox is available in parallel MATLAB and Python implementations with identical semantics. This package is the Python one; the full repository, including the MATLAB implementation, the User Guide, and the demos, is at https://github.com/andymilne/Music-Perception-Toolbox.
Install
pip install music-perception-toolbox
What it provides
Expectation tensors and their cosine similarity. A weighted multiset of pitches or time points is smoothed into a continuous density over its r-tuples, with a single parameter σ modelling perceptual uncertainty. The density and the cosine similarity of two densities are computed analytically, without discretization, in all four modes (absolute or relative, non-periodic or periodic). The (S)P(C)S family of similarity measures are instances of this.
Consonance and harmonicity. Spectral entropy, template harmonicity, tensor harmonicity, virtual pitch profiles, and Sethares roughness.
Scale and rhythm structure. Circular DFT, balance, evenness, coherence, sameness, n-tuple entropy, edge detection, projected centroid, mean offset, the circular autocorrelation phase matrix, and Markov prediction.
Audio input. Spectral peaks extracted from a recording can be used wherever symbolic pitches can.
Quick example
import numpy as np
import mpt
major = np.array([0.0, 400.0, 700.0]) # cents
minor = np.array([0.0, 300.0, 700.0])
# Spectral pitch class similarity: harmonic partials added, octave-periodic.
spectrum = ["harmonic", 16, "powerlaw", 1.0]
p_a, w_a = mpt.add_spectra(major, None, *spectrum)
p_b, w_b = mpt.add_spectra(minor, None, *spectrum)
d_a = mpt.build_exp_tens(p_a, w_a, 10.0, 1, False, True, 1200)
d_b = mpt.build_exp_tens(p_b, w_b, 10.0, 1, False, True, 1200)
print(mpt.cos_sim_exp_tens(d_a, d_b))
Documentation
The User Guide
covers the conceptual foundations and gives a complete function reference for
both languages. Nine demo scripts, also provided as Jupyter notebooks, are in
python/demos/.
Citation
See CITATION.cff in the repository.
Licence
MIT.
Metadata
Release files for music-perception-toolbox 2.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| music_perception_toolbox-2.0.4.tar.gz | 33.0 kB | Without provenance | Details for music_perception_toolbox-2.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| music_perception_toolbox-2.0.4-py3-none-any.whl | Python 3 | none | any | Details for music_perception_toolbox-2.0.4-py3-none-any.whl |
Total release size: 64.6 kB
Release files / music_perception_toolbox-2.0.4.tar.gz
| Download URL | music_perception_toolbox-2.0.4.tar.gz |
|---|---|
| Size | 33.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a45a0c862b2632532fc5ad6d850f293fc3ca69224b555e99dd1299f81727eb66
|
|
BLAKE2b-256 checksum How to use checksums |
819638dfc4c093bbb867348fa83966aff7f01b5da276a2afa245e9cc2923cf25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Release files / music_perception_toolbox-2.0.4-py3-none-any.whl
| Download URL | music_perception_toolbox-2.0.4-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f30e596f52af38d64d6c145dcf0f514df5b0cded27ee27fbf43eeef483ccf294
|
|
BLAKE2b-256 checksum How to use checksums |
2fdc5c16e1be2185af62d46f07eb55c443cfcfbb68b5cca241703506b3bd7be8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Security for music-perception-toolbox 2.0.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.