mdct#

diffsptk.MDCT#

alias of ModifiedDiscreteCosineTransform

class diffsptk.ModifiedDiscreteCosineTransform(frame_length, window='sine', **kwargs)[source]#

This module is a simple cascade of framing, windowing, and modified DCT.

Parameters:
frame_lengthint >= 2

Frame length, \(L\).

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

Window type.

forward(x)[source]#

Compute modified discrete cosine transform.

Parameters:
xTensor [shape=(…, T)]

Waveform.

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

Spectrum.

Examples

>>> x = diffsptk.ramp(3)
>>> x
tensor([0., 1., 2., 3.])
>>> mdct = diffsptk.MDCT(frame_length=4)
>>> y = mdct(x)
>>> y
tensor([[-0.3536, -0.1464],
        [-3.1213, -0.2929],
        [-0.7678,  1.8536]])
diffsptk.functional.mdct(x, frame_length=400, window='sine')[source]#

Compute modified discrete cosine transform.

Parameters:
xTensor [shape=(…, T)]

Waveform.

frame_lengthint >= 2

Frame length, \(L\).

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

Window type.

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

Spectrum.

See also

frame window imdct