tf.signal.inverse_mdct
Stay organized with collections
Save and categorize content based on your preferences.
Computes the inverse modified DCT of mdcts
.
tf.signal.inverse_mdct(
mdcts,
window_fn=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.
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 ,
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.
|
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 .
|
Raises |
ValueError
|
If mdcts is not at least rank 2.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2022-11-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-11-04 UTC."],[],[]]