# tf.signal.inverse_mdct

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/signal/spectral_ops.py#L367-L449) |

Computes the inverse modified DCT of `mdcts`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.signal.inverse_mdct`](https://www.tensorflow.org/api_docs/python/tf/signal/inverse_mdct)

<br />

    tf.signal.inverse_mdct(
        mdcts,
        window_fn=https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/signal/vorbis_window,
        norm=None,
        name=None
    )

To reconstruct an original waveform, the same window function should
be used with `mdct` and `inverse_mdct`.

#### Example usage:

    @tf.function
    def compare_round_trip():
      samples = 1000
      frame_length = 400
      halflen = frame_length // 2
      waveform = tf.random.normal(dtype=tf.float32, shape=[samples])
      waveform_pad = tf.pad(waveform, [[halflen, 0],])
      mdct = tf.signal.mdct(waveform_pad, frame_length, pad_end=True,
                            window_fn=tf.signal.vorbis_window)
      inverse_mdct = tf.signal.inverse_mdct(mdct,
                                            window_fn=tf.signal.vorbis_window)
      inverse_mdct = inverse_mdct[halflen: halflen + samples]
      return waveform, inverse_mdct
    waveform, inverse_mdct = compare_round_trip()
    np.allclose(waveform.numpy(), inverse_mdct.numpy(), rtol=1e-3, atol=1e-4)
    True

Implemented with TPU/GPU-compatible ops and supports gradients.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `mdcts` | A `float32`/`float64` `[..., frames, frame_length // 2]` `Tensor` of MDCT bins representing a batch of `frame_length // 2`-point MDCTs. |
| `window_fn` | A callable that takes a frame_length and a `dtype` keyword argument and returns a `[frame_length]` `Tensor` of samples in the provided datatype. If set to `None`, a rectangular window with a scale of 1/sqrt(2) is used. For perfect reconstruction of a signal from `mdct` followed by `inverse_mdct`, please use [`tf.signal.vorbis_window`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/signal/vorbis_window), [`tf.signal.kaiser_bessel_derived_window`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/signal/kaiser_bessel_derived_window) or `None`. If using another window function, make sure that w\[n\]\^2 + w\[n + frame_length // 2\]\^2 = 1 and w\[n\] = w\[frame_length - n - 1\] for n = 0,...,frame_length // 2 - 1 to achieve perfect reconstruction. |
| `norm` | If "ortho", orthonormal inverse DCT4 is performed, if it is None, a regular dct4 followed by scaling of `1/frame_length` is performed. |
| `name` | An optional name for the operation. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `[..., samples]` `Tensor` of `float32`/`float64` signals representing the inverse MDCT for each input MDCT in `mdcts` where `samples` is `(frames - 1) * (frame_length // 2) + frame_length`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `mdcts` is not at least rank 2. |

<br />