librosa.effects.deemphasis

librosa.effects.deemphasis(y, *, coef=0.97, zi=None, return_zf=False)[source]

De-emphasize an audio signal with the inverse operation of preemphasis():

If y = preemphasis(x, coef=coef, zi=zi), the deemphasis is:

>>> x[i] = y[i] + coef * x[i-1]
>>> x = deemphasis(y, coef=coef, zi=zi)
Parameters:
ynp.ndarray [shape=(…, n)]

Audio signal. Multi-channel is supported.

coefpositive number

Pre-emphasis coefficient. Typical values of coef are between 0 and 1.

At the limit coef=0, the signal is unchanged.

At coef=1, the result is the first-order difference of the signal.

The default (0.97) matches the pre-emphasis filter used in the HTK implementation of MFCCs [1].

zinumber

Initial filter state. If inverting a previous preemphasis(), the same value should be used.

By default zi is initialized as ((2 - coef) * y[0] - y[1]) / (3 - coef). This value corresponds to the transformation of the default initialization of zi in preemphasis(), 2*x[0] - x[1].

return_zfboolean

If True, return the final filter state. If False, only return the pre-emphasized signal.

Returns:
y_outnp.ndarray

de-emphasized signal

zfnumber

if return_zf=True, the final filter state is also returned

See also

preemphasis

Examples

Apply a standard pre-emphasis filter and invert it with de-emphasis

>>> y, sr = librosa.load(librosa.ex('trumpet'))
>>> y_filt = librosa.effects.preemphasis(y)
>>> y_deemph = librosa.effects.deemphasis(y_filt)
>>> np.allclose(y, y_deemph)
True