mdct#
- diffsptk.MDCT#
alias of
ModifiedDiscreteCosineTransform
- class diffsptk.ModifiedDiscreteCosineTransform(frame_length: int, window: str = 'sine', learnable: bool | list[str] = False, device: device | None = None, dtype: dtype | None = None)[source]#
This module is a simple cascade of framing, windowing, and modified DCT.
- Parameters:
- frame_lengthint >= 2
The frame length, \(L\).
- window[‘sine’, ‘vorbis’, ‘kbd’, ‘rectangular’]
The window type.
- learnablebool or list[str]
Indicates whether the parameters are learnable. If a boolean, it specifies whether all parameters are learnable. If a list, it contains the keys of the learnable parameters, which can only be “basis” and “window”.
- devicetorch.device or None
The device of this module.
- dtypetorch.dtype or None
The data type of this module.
- forward(x: Tensor) Tensor [source]#
Compute modified discrete cosine transform.
- Parameters:
- xTensor [shape=(…, T)]
The input waveform.
- Returns:
- outTensor [shape=(…, 2T/L, L/2)]
The spectrum.
Examples
>>> import diffsptk >>> mdct = diffsptk.MDCT(frame_length=4) >>> x = diffsptk.ramp(3) >>> y = mdct(x) >>> y tensor([[-0.5000, -0.2071], [-4.4142, -0.4142], [-1.0858, 2.6213]])
- diffsptk.functional.mdct(x: Tensor, frame_length: int = 400, window: str = 'sine') Tensor [source]#
Compute modified discrete cosine transform.
- Parameters:
- xTensor [shape=(…, T)]
The input waveform.
- frame_lengthint >= 2
The frame length, \(L\).
- window[‘sine’, ‘vorbis’, ‘kbd’, ‘rectangular’]
The window type.
- Returns:
- outTensor [shape=(…, 2T/L, L/2)]
The spectrum.