Flexible audio loudness meter in Python with implementation of ITU-R BS.1770-4 loudness algorithm
No Data
Flexible audio loudness meter in Python.
Implementation of ITU-R BS.1770-4.
Allows control over gating block size and frequency weighting filters for additional control.
You can install with pip as follows
pip install pyloudnorm
For the latest releases always install from the GitHub repo
pip install git+https://github.com/csteinmetz1/pyloudnorm
It's easy to measure the loudness of a wav file. Here we use PySoundFile to read a .wav file as an ndarray. ```python import soundfile as sf import pyloudnorm as pyln
data, rate = sf.read("test.wav") # load audio (with shape (samples, channels)) meter = pyln.Meter(rate) # create BS.1770 meter loudness = meter.integrated_loudness(data) # measure loudness ```
Methods are included to normalize audio files to desired peak values or desired loudness. ```python import soundfile as sf import pyloudnorm as pyln
data, rate = sf.read("test.wav") # load audio
peaknormalizedaudio = pyln.normalize.peak(data, -1.0)
meter = pyln.Meter(rate) # create BS.1770 meter loudness = meter.integrated_loudness(data)
loudnessnormalizedaudio = pyln.normalize.loudness(data, loudness, -12.0) ```
A number of alternate weighting filters are available, as well as the ability to adjust the analysis block size. Examples are shown below. ```python import soundfile as sf import pyloudnorm as pyln from pyloudnorm import IIRfilter
data, rate = sf.read("test.wav") # load audio
meter1 = pyln.Meter(rate) # 400ms block size meter2 = pyln.Meter(rate, block_size=0.200) # 200ms block size
meter3 = pyln.Meter(rate) # BS.1770 meter
meter4 = pyln.Meter(rate, filterclass="DeMan") # fully compliant filters
meter5 = pyln.Meter(rate, filterclass="Fenton/Lee 1") # low complexity improvement by Fenton and Lee
meter6 = pyln.Meter(rate, filterclass="Fenton/Lee 2") # higher complexity improvement by Fenton and Lee
meter7 = pyln.Meter(rate, filterclass="Dash et al.") # early modification option
myhighpass = IIRfilter(0.0, 0.5, 20.0, rate, 'highpass') myhighshelf = IIRfilter(2.0, 0.7, 1525.0, rate, 'highshelf')
meter8 = pyln.Meter(rate, filter_class="custom")
meter8.filters = {'myhighpass' : myhighpass, 'myhighshelf' : myhigh_shelf}
## Dependancies - **SciPy** ([https://www.scipy.org/](https://www.scipy.org/)) - **NumPy** ([http://www.numpy.org/](http://www.numpy.org/))Cite as
> Christian Steinmetz, csteinmetz1/pyloudnorm: 0.1.0 (Version v0.1.0), Zenodo, November 2019
References
> Ian Dash, Luis Miranda, and Densil Cabrera, "Multichannel Loudness Listening Test," > 124th International Convention of the Audio Engineering Society, May 2008
> Pedro D. Pestana and Álvaro Barbosa, "Accuracy of ITU-R BS.1770 Algorithm in Evaluating Multitrack Material," > 133rd International Convention of the Audio Engineering Society, October 2012
> Pedro D. Pestana, Josh D. Reiss, and Álvaro Barbosa, "Loudness Measurement of Multitrack Audio Content Using Modifications of ITU-R BS.1770," > 134th International Convention of the Audio Engineering Society, May 2013
> Steven Fenton and Hyunkook Lee, "Alternative Weighting Filters for Multi-Track Program Loudness Measurement," > 143rd International Convention of the Audio Engineering Society, October 2017
> Brecht De Man, "Evaluation of Implementations of the EBU R128 Loudness Measurement," > 145th International Convention of the Audio Engineering Society, October 2018.