librosa.frequency_weighting

librosa.frequency_weighting(frequencies, kind='A', **kw)[source]

Compute the weighting of a set of frequencies.

Parameters
frequenciesscalar or np.ndarray [shape=(n,)]

One or more frequencies (in Hz)

kindstr in

The weighting kind. e.g. ‘A’, ‘B’, ‘C’, ‘D’, ‘Z’

min_dbfloat [scalar] or None

Clip weights below this threshold. If None, no clipping is performed.

Returns
weightingscalar or np.ndarray [shape=(n,)]

weighting[i] is the weighting of frequencies[i]

Examples

Get the A-weighting for CQT frequencies

>>> import matplotlib.pyplot as plt
>>> freqs = librosa.cqt_frequencies(108, librosa.note_to_hz('C1'))
>>> weights = librosa.frequency_weighting(freqs, 'A')
>>> fig, ax = plt.subplots()
>>> ax.plot(freqs, weights)
>>> ax.set(xlabel='Frequency (Hz)', ylabel='Weighting (log10)',
...        title='A-Weighting of CQT frequencies')
../_images/librosa-frequency_weighting-1.png