chroma#
- class diffsptk.ChromaFilterBankAnalysis(*, fft_length: int, n_channel: int, sample_rate: int, norm: float = inf, use_power: bool = True)[source]#
Chroma filter bank analysis module.
- Parameters:
- fft_lengthint >= 2
The number of FFT bins, \(L\).
- n_channelint >= 1
The number of chroma filter banks, \(C\).
- sample_rateint >= 1
The sample rate in Hz.
- normfloat
The normalization factor.
- use_powerbool
If True, use the power spectrum instead of the amplitude spectrum.
- forward(x: Tensor) Tensor [source]#
Apply chroma filter banks to the STFT.
- Parameters:
- xTensor [shape=(…, L/2+1)]
The power spectrum.
- Returns:
- outTensor [shape=(…, C)]
The chroma filter bank output.
Examples
>>> sr = 16000 >>> x = diffsptk.sin(500, period=sr/440) >>> stft = diffsptk.STFT(frame_length=512, frame_period=512, fft_length=512) >>> chroma = diffsptk.ChromaFilterBankAnalysis(12, 512, sr) >>> y = chroma(stft(x)) >>> y tensor([[0.1146, 0.0574, 0.0457, 0.0468, 0.0519, 0.0789, 0.1736, 0.4285, 0.7416, 1.0000, 0.7806, 0.3505]])
- diffsptk.functional.chroma(x: Tensor, n_channel: int, sample_rate: int, norm: float = inf, use_power: bool = True) Tensor [source]#
Apply chroma-filter banks to the STFT.
- Parameters:
- xTensor [shape=(…, L/2+1)]
The power spectrum.
- n_channelint >= 1
The number of chroma filter banks, \(C\).
- sample_rateint >= 1
The sample rate in Hz.
- normfloat
The normalization factor.
- use_powerbool
If True, use the power spectrum instead of the amplitude spectrum.
- Returns:
- outTensor [shape=(…, C)]
The chroma filter bank output.