librosa.filters.dct

librosa.filters.dct(n_filters, n_input)[source]

Discrete cosine transform (DCT type-III) basis.

[1]http://en.wikipedia.org/wiki/Discrete_cosine_transform
Parameters:
n_filters : int > 0 [scalar]

number of output components (DCT filters)

n_input : int > 0 [scalar]

number of input components (frequency bins)

Returns:
dct_basis: np.ndarray [shape=(n_filters, n_input)]

DCT (type-III) basis vectors [1]

Notes

This function caches at level 10.

Examples

>>> n_fft = 2048
>>> dct_filters = librosa.filters.dct(13, 1 + n_fft // 2)
>>> dct_filters
array([[ 0.031,  0.031, ...,  0.031,  0.031],
       [ 0.044,  0.044, ..., -0.044, -0.044],
       ...,
       [ 0.044,  0.044, ..., -0.044, -0.044],
       [ 0.044,  0.044, ...,  0.044,  0.044]])
>>> import matplotlib.pyplot as plt
>>> plt.figure()
>>> librosa.display.specshow(dct_filters, x_axis='linear')
>>> plt.ylabel('DCT function')
>>> plt.title('DCT filter bank')
>>> plt.colorbar()
>>> plt.tight_layout()

(Source code)

../_images/librosa-filters-dct-1.png