• Stars
    star
    581
  • Rank 74,362 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Flexible audio loudness meter in Python with implementation of ITU-R BS.1770-4 loudness algorithm

pyloudnorm Build Status Zenodo

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.

For full details on the implementation see our paper with a summary in our AES presentation video.

Installation

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

Usage

Find the loudness of an audio file

It's easy to measure the loudness of a wav file. Here we use PySoundFile to read a .wav file as an ndarray.

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

Loudness normalize and peak normalize audio files

Methods are included to normalize audio files to desired peak values or desired loudness.

import soundfile as sf
import pyloudnorm as pyln

data, rate = sf.read("test.wav") # load audio

# peak normalize audio to -1 dB
peak_normalized_audio = pyln.normalize.peak(data, -1.0)

# measure the loudness first 
meter = pyln.Meter(rate) # create BS.1770 meter
loudness = meter.integrated_loudness(data)

# loudness normalize audio to -12 dB LUFS
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)

Advanced operation

A number of alternate weighting filters are available, as well as the ability to adjust the analysis block size. Examples are shown below.

import soundfile as sf
import pyloudnorm as pyln
from pyloudnorm import IIRfilter

data, rate = sf.read("test.wav") # load audio

# block size
meter1 = pyln.Meter(rate)                               # 400ms block size
meter2 = pyln.Meter(rate, block_size=0.200)             # 200ms block size

# filter classes
meter3 = pyln.Meter(rate)                               # BS.1770 meter
meter4 = pyln.Meter(rate, filter_class="DeMan")         # fully compliant filters  
meter5 = pyln.Meter(rate, filter_class="Fenton/Lee 1")  # low complexity improvement by Fenton and Lee
meter6 = pyln.Meter(rate, filter_class="Fenton/Lee 2")  # higher complexity improvement by Fenton and Lee
meter7 = pyln.Meter(rate, filter_class="Dash et al.")   # early modification option

# create your own IIR filters
my_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 filters
meter8 = pyln.Meter(rate, filter_class="custom")

# load your filters into the meter
meter8._filters = {'my_high_pass' : my_high_pass, 'my_high_shelf' : my_high_shelf}

Dependancies

Citation

If 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}}

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.

More Repositories

1

ai-audio-startups

Community list of startups working with AI in audio and music technology
1,449
star
2

auraloss

Collection of audio-focused loss functions in PyTorch
Python
662
star
3

dasp-pytorch

Differentiable audio signal processors in PyTorch
Python
201
star
4

steerable-nafx

Steerable discovery of neural audio effects
Jupyter Notebook
200
star
5

micro-tcn

Efficient neural networks for analog audio effect modeling
Python
139
star
6

ronn

Randomized overdrive neural networks
Jupyter Notebook
132
star
7

pymixconsole

Headless multitrack mixing console in Python
Python
110
star
8

wavebeat

End-to-end beat and downbeat tracking in the time domain.
Python
109
star
9

AutomaticMixingPapers

Important papers and associated code on automatic mixing research
HTML
91
star
10

automix-toolkit

Models and datasets for training deep learning automatic mixing models
Python
80
star
11

NeuralReverberator

Reverb synthesis via a spectral autoencoder
Python
79
star
12

IIRNet

Direct design of biquad filter cascades with deep learning by sampling random polynomials.
Python
73
star
13

flowEQ

ฮฒ-VAE for intelligent control of a five band parametric EQ
MATLAB
67
star
14

bela-zlc

Zero-latency convolution on Bela platform
C++
25
star
15

MixCNN

Convolutional Neural Network for multitrack mix leveling
Python
18
star
16

neural-2a

Neural network model of the analog LA-2A dynamic range compressor
CMake
16
star
17

findio

The Spotify search you don't need and never wanted
HTML
13
star
18

computational-music-creativity

Materials for the Computational Music Creativity course at UPF-MTG (Spring 2020)
TeX
12
star
19

PhaseAnalyzer

C++ plugin built with the JUCE Framework to provide insight about the relative phase relationship of audio signals
C++
10
star
20

pyloudnorm-eval

Evaluation of a number of loudness meter implementations
Python
10
star
21

Cinuosity

Novel playlist generation and music discovery in Spotify
JavaScript
9
star
22

mids

Implementation of content-based audio search algorithm.
Python
8
star
23

auxCord

Sync Spotify accounts to build tailored playlists
JavaScript
7
star
24

amida

audio mixing interface for data acquisition
Python
5
star
25

youtube-audio-dl

Utility to automate download and normalization of YouTube audio streams
Python
5
star
26

pyreqs

Easily build requirements.txt files automatically
Python
4
star
27

consynthance

Studying consonance as a result of vocal similarity
Jupyter Notebook
4
star
28

machine-learning

Materials for the Machine Learning course at UPF-MTG (Winter 2019)
Jupyter Notebook
3
star
29

arte

generative artwork created with canvas-sketch
JavaScript
3
star
30

ML4AP

Slides for my talk Applications of machine learning for assistive and creative audio plugins
JavaScript
3
star
31

cavae

Covert art variational autoencoder for generating new cover art
Python
3
star
32

aes-presenters-145th

Analysis of papers and presenters at the 145th AES Convention in NYC
Python
2
star
33

AudioTechTalks-S19

Materials and associated code for audio technology talks at Clemson University - Spring 2019
JavaScript
2
star
34

LDA-Music

LDA topic modeling of raw audio data for music suggestions
Python
2
star
35

aes-stats-147th

Analysis of papers from the 147th AES Convention in NYC
Python
2
star
36

macOS-laptop

Setup script for config and installation on a fresh macOS machine
Shell
2
star
37

tempnetic

Tempo estimation
Python
2
star
38

sBucket

Build large Spotify playlists using user top tracks and seed track recommendations
Python
1
star
39

ev-sound-analysis

Analyzing audio from electric vehicles to determine FMVSS 141 compliance
Python
1
star
40

personal-website

Personal website built with Angular 7 and Bootstrap 4
HTML
1
star
41

LoudnessHistory

An analysis of the perceived loudness of music over time.
Python
1
star