audioflux.chroma_linear

audioflux.chroma_linear(X, chroma_num=12, radix2_exp=12, samplate=32000, low_fre=0.0, high_fre=16000.0, window_type=WindowType.HANN, slide_length=1024, data_type=SpectralDataType.POWER, style_type=SpectralFilterBankStyleType.SLANEY, normal_type=SpectralFilterBankNormalType.NONE)

Linear(STFT) chromagram

Parameters
X: np.ndarray [shape=(…, n)]

audio time series.

chroma_num: int

Number of chroma bins to generate.

radix2_exp: int

fft_length=2**radix2_exp

samplate: int:

Sampling rate of the incoming audio.

low_fre: float

Lowest frequency.

high_fre: float or None

Highest frequency. Default is 16000(samplate/2).

window_type: WindowType

Window type for each frame.

See: type.WindowType

slide_length: int

Window sliding length.

data_type: SpectralDataType

Spectrogram data type.

See: type.SpectralDataType

style_type: SpectralFilterBankStyleType

Spectral filter bank style type. It determines the bank type of window.

see: type.SpectralFilterBankStyleType

normal_type: SpectralFilterBankNormalType

Spectral filter normal type. It determines the type of normalization.

See: type.SpectralFilterBankNormalType

Returns
out: np.ndarray [shape=(…, chroma_num, time)]

The matrix of chroma_linear

Examples

Read 220Hz audio data

>>> import audioflux as af
>>> audio_path = af.utils.sample_path('220')
>>> audio_arr, sr = af.read(audio_path)

Extract chroma_linear data

>>> chroma_arr = af.chroma_linear(audio_arr, samplate=sr)

Show spectrogram plot

>>> import matplotlib.pyplot as plt
>>> from audioflux.display import fill_spec
>>> import numpy as np
>>>
>>> # calculate x-coords
>>> audio_len = audio_arr.shape[-1]
>>> x_coords = np.linspace(0, audio_len/sr, chroma_arr.shape[-1] + 1)
>>>
>>> fig, ax = plt.subplots()
>>> img = fill_spec(chroma_arr, axes=ax,
>>>                 x_coords=x_coords,
>>>                 x_axis='time', y_axis='chroma',
>>>                 title='Chroma_linear')
>>> fig.colorbar(img, ax=ax)
../_images/audioflux-chroma_linear-1.png