mdct module

mdct.mdct(x, odd=True, transforms=None, **kwargs)

Calculate lapped MDCT of input signal

Parameters:
  • x (array_like) – The signal to be transformed. May be a 1D vector for single channel or a 2D matrix for multi channel data. In case of a mono signal, the data is must be a 1D vector of length samples. In case of a multi channel signal, the data must be in the shape of samples x channels.
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • framelength (int) – The signal frame length. Defaults to 2048.
  • hopsize (int) – The signal frame hopsize. Defaults to None. Setting this value will override overlap.
  • overlap (int) – The signal frame overlap coefficient. Value x means 1/x overlap. Defaults to 2. Note that anything but 2 will result in a filterbank without perfect reconstruction.
  • centered (boolean) – Pad input signal so that the first and last window are centered around the beginning of the signal. Defaults to True. Disabling this will result in aliasing in the first and last half-frame.
  • window (callable, array_like) – Window to be used for deringing. Can be False to disable windowing. Defaults to scipy.signal.cosine.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast
  • padding (int) – Zero-pad signal with x times the number of samples. Defaults to 0.
  • save_settings (boolean) – Save settings used here in attribute out.stft_settings so that ispectrogram() can infer these settings without the developer having to pass them again.
Returns:

out – The signal (or matrix of signals). In case of a mono output signal, the data is formatted as a 1D vector of length samples. In case of a multi channel output signal, the data is formatted as samples x channels.

Return type:

array_like

mdct.imdct(X, odd=True, transforms=None, **kwargs)

Calculate lapped inverse MDCT of input signal

Parameters:
  • x (array_like) – The spectrogram to be inverted. May be a 2D matrix for single channel or a 3D tensor for multi channel data. In case of a mono signal, the data must be in the shape of bins x frames. In case of a multi channel signal, the data must be in the shape of bins x frames x channels.
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • framelength (int) – The signal frame length. Defaults to infer from data.
  • hopsize (int) – The signal frame hopsize. Defaults to infer from data. Setting this value will override overlap.
  • overlap (int) – The signal frame overlap coefficient. Value x means 1/x overlap. Defaults to infer from data. Note that anything but 2 will result in a filterbank without perfect reconstruction.
  • centered (boolean) – Pad input signal so that the first and last window are centered around the beginning of the signal. Defaults to to infer from data. The first and last half-frame will have aliasing, so using centering during forward MDCT is recommended.
  • window (callable, array_like) – Window to be used for deringing. Can be False to disable windowing. Defaults to to infer from data.
  • halved (boolean) – Switch to reconstruct the other halve of the spectrum if the forward transform has been truncated. Defaults to to infer from data.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast
  • padding (int) – Zero-pad signal with x times the number of samples. Defaults to infer from data.
  • outlength (int) – Crop output signal to length. Useful when input length of spectrogram did not fit into framelength and input data had to be padded. Not setting this value will disable cropping, the output data may be longer than expected.
Returns:

out – The output signal

Return type:

array_like

See also

mdct.fast.transforms.imdct()
inverse MDCT
mdct.mdst(x, odd=True, transforms=None, **kwargs)

Calculate lapped MDST of input signal

Parameters:
  • x (array_like) – The input signal
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast Additional keyword arguments passed to stft.spectrogram
Returns:

out – The output signal

Return type:

array_like

mdct.imdst(X, odd=True, transforms=None, **kwargs)

Calculate lapped inverse MDST of input signal

Parameters:
  • x (array_like) – The input signal
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast Additional keyword arguments passed to stft.spectrogram
Returns:

out – The output signal

Return type:

array_like

See also

mdct.fast.transforms.imdst()
inverse MDST
mdct.cmdct(x, odd=True, transforms=None, **kwargs)

Calculate lapped complex MDCT/MCLT of input signal

Parameters:
  • x (array_like) – The input signal
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast
  • optional (**kwargs,) –

    Additional keyword arguments passed to stft.spectrogram

Returns:

out – The output signal

Return type:

array_like

See also

mdct.fast.transforms.cmdct()
complex MDCT
mdct.icmdct(X, odd=True, transforms=None, **kwargs)

Calculate lapped inverse complex MDCT/MCLT of input signal

Parameters:
  • x (array_like) – The input signal
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast Additional keyword arguments passed to stft.spectrogram
Returns:

out – The output signal

Return type:

array_like

See also

mdct.fast.transforms.icmdct()
inverse complex MDCT
mdct.mclt(x, odd=True, transforms=None, **kwargs)

Calculate lapped complex MDCT/MCLT of input signal

Parameters:
  • x (array_like) – The input signal
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast
  • optional (**kwargs,) –

    Additional keyword arguments passed to stft.spectrogram

Returns:

out – The output signal

Return type:

array_like

See also

mdct.fast.transforms.cmdct()
complex MDCT
mdct.imclt(X, odd=True, transforms=None, **kwargs)

Calculate lapped inverse complex MDCT/MCLT of input signal

Parameters:
  • x (array_like) – The input signal
  • odd (boolean, optional) – Switch to oddly stacked transform. Defaults to True.
  • transforms (module, optional) – Module reference to core transforms. Mostly used to replace fast with slow core transforms, for testing. Defaults to mdct.fast Additional keyword arguments passed to stft.spectrogram
Returns:

out – The output signal

Return type:

array_like

See also

mdct.fast.transforms.icmdct()
inverse complex MDCT