imdct#

diffsptk.IMDCT#

alias of InverseModifiedDiscreteCosineTransform

class diffsptk.InverseModifiedDiscreteCosineTransform(frame_length: int, window: str = 'sine', learnable: bool | list[str] = False, device: device | None = None, dtype: dtype | None = None)[source]#

This is the opposite module to ModifiedDiscreteCosineTransform().

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(y: Tensor, out_length: int | None = None) Tensor[source]#

Compute inverse modified discrete cosine transform.

Parameters:
yTensor [shape=(…, 2T/L, L/2)]

The spectrum.

out_lengthint or None

The length of the output waveform.

Returns:
outTensor [shape=(…, T)]

The reconstructed waveform.

Examples

>>> x = diffsptk.ramp(3)
>>> x
tensor([0., 1., 2., 3.])
>>> mdct_params = {"frame_length": 4, "window": "vorbis"}
>>> mdct = diffsptk.MDCT(**mdct_params)
>>> imdct = diffsptk.IMDCT(**mdct_params)
>>> y = imdct(mdct(x))
>>> y
tensor([1.0431e-07, 1.0000e+00, 2.0000e+00, 3.0000e+00])
diffsptk.functional.imdct(y: Tensor, out_length: int | None = None, frame_length: int = 400, window: str = 'sine') Tensor[source]#

Compute inverse modified discrete cosine transform.

Parameters:
yTensor [shape=(…, 2T/L, L/2)]

The spectrum.

out_lengthint or None

The length of the output waveform.

frame_lengthint >= 2

The frame length, \(L\).

window[‘sine’, ‘vorbis’, ‘kbd’, ‘rectangular’]

The window type.

Returns:
outTensor [shape=(…, T)]

The reconstructed waveform.

See also

unframe window mdct