pyaudioaliasingmetrics
A Python implementation of SNR and SINAD metrics, using Numpy and Numba
These implementations expects three types of inputs :
- spectral magnitudes of the required signals
- the fundamental frequency of the signal
- a description of which harmonics are part of the signal
Installation
You can install this library using pip
pip install pyaudioaliasingmetrics
Usage
Matlab suggest using a Kaiser window with a beta factor of 38
SNR
Computing the SNR of a saw wave at 440Hz, sampled at 44100Hz
import numpy as np
import audioaliasingmetrics as aam
noisy_signal : np.ndarray[np.float32] = ... # audio time serie of the noisy signal
length = noisy_signal.shape[0]
window = window = np.kaiser(length, 38)
magnitude = np.abs(np.fft.rfft(noisy_signal * window))
snr = aam.snr(magnitude, 44100, 440.0, aam.Harmonics.ALL)
SINAD
Computing the SINAD of a saw wave at 440Hz, sampled at 44100Hz
import numpy as np
import audioaliasingmetrics as aam
noisy_signal : np.ndarray[np.float32] = ... # audio time serie of the noisy signal
clean_signal : np.ndarray[np.float32] = ... # audio time serie of the clean signal
length = noisy_signal.shape[0]
window = window = np.kaiser(length, 38)
noisy_magnitude = np.abs(np.fft.rfft(noisy_signal * window))
clean_magnitude = np.abs(np.fft.rfft(clean_signal * window))
sinad = aam.sinad(noisy_magnitude, clean_magnitude, 44100, 440.0, aam.Harmonics.ALL)
Harmonics selection
You can select which harmonics are part of your signal with the harmonics parameter of both methods. It supports two modes:
- A
Harmonicsenum value (ODD/EVEN/ALL) to respectively select all possible odd, even or both harmonics. - A list/numpy array of integers values >2 of harmonics factors by which to multiply the fundamental with, to precisely select harmonics.
Metadata
Release files for pyaudioaliasingmetrics 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyaudioaliasingmetrics-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyaudioaliasingmetrics-0.1.0-py3-none-any.whl |
Release files / pyaudioaliasingmetrics-0.1.0-py3-none-any.whl
| Download URL | pyaudioaliasingmetrics-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96f1f3e8d9214123bb0bb1d31fca0454702bb0224ba7185727da747b08a8edf8
|
|
BLAKE2b-256 checksum How to use checksums |
70cf6c564d81834a3aa7f724446c511c15c559f4f63b5a502600f21364f6f6e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for pyaudioaliasingmetrics 0.1.0
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.