Package: pyloudnorm
pyloudnormFlexible audio loudness meter in Python.Implementation ofITU-R BS.1770-4.Allows control over gating block size and frequency weighting filters for additional control.For full details on the implementation see ourpaperwith a summary in ourAES presentation video.InstallationYou can install with pip as followspip install pyloudnormFor the latest releases always install from the GitHub repopip install git+https://github.com/csteinmetz1/pyloudnormUsageFind the loudness of an audio fileIt's easy to measure the loudness of a wav file.
Here we use PySoundFile to read a .wav file as an ndarray.importsoundfileassfimportpyloudnormaspylndata,rate=sf.read("test.wav")# load audio (with shape (samples, channels))meter=pyln.Meter(rate)# create BS.1770 meterloudness=meter.integrated_loudness(data)# measure loudnessLoudness normalize and peak normalize audio filesMethods are included to normalize audio files to desired peak values or desired loudness.importsoundfileassfimportpyloudnormaspylndata,rate=sf.read("test.wav")# load audio# peak normalize audio to -1 dBpeak_normalized_audio=pyln.normalize.peak(data,-1.0)# measure the loudness firstmeter=pyln.Meter(rate)# create BS.1770 meterloudness=meter.integrated_loudness(data)# loudness normalize audio to -12 dB LUFSloudness_normalized_audio=pyln.normalize.loudness(data,loudness,-12.0)Advanced operationA number of alternate weighting filters are available, as well as the ability to adjust the analysis block size.
Examples are shown below.importsoundfileassfimportpyloudnormaspylnfrompyloudnormimportIIRfilterdata,rate=sf.read("test.wav")# load audio# block sizemeter1=pyln.Meter(rate)# 400ms block sizemeter2=pyln.Meter(rate,block_size=0.200)# 200ms block size# filter classesmeter3=pyln.Meter(rate)# BS.1770 metermeter4=pyln.Meter(rate,filter_class="DeMan")# fully compliant filtersmeter5=pyln.Meter(rate,filter_class="Fenton/Lee 1")# low complexity improvement by Fenton and Leemeter6=pyln.Meter(rate,filter_class="Fenton/Lee 2")# higher complexity improvement by Fenton and Leemeter7=pyln.Meter(rate,filter_class="Dash et al.")# early modification option# create your own IIR filtersmy_high_pass=IIRfilter(0.0,0.5,20.0,rate,'high_pass')my_high_shelf=IIRfilter(2.0,0.7,1525.0,rate,'high_shelf')# create a meter initialized without filtersmeter8=pyln.Meter(rate,filter_class="custom")# load your filters into the metermeter8._filters={'my_high_pass':my_high_pass,'my_high_shelf':my_high_shelf}DependanciesSciPy(https://www.scipy.org/)NumPy(http://www.numpy.org/)CitationIf you use pyloudnorm in your work please consider citing us.@inproceedings{steinmetz2021pyloudnorm,
        title={pyloudnorm: {A} simple yet flexible loudness meter in Python},
        author={Steinmetz, Christian J. and Reiss, Joshua D.},
        booktitle={150th AES Convention},
        year={2021}}ReferencesIan Dash, Luis Miranda, and Densil Cabrera, "Multichannel Loudness Listening Test,"
124th International Convention of the Audio Engineering Society, May 2008Pedro 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 2012Pedro 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 2013Steven Fenton and Hyunkook Lee, "Alternative Weighting Filters for Multi-Track Program Loudness Measurement,"
143rd International Convention of the Audio Engineering Society, October 2017Brecht De Man, "Evaluation of Implementations of the EBU R128 Loudness Measurement,"
145th International Convention of the Audio Engineering Society, October 2018.