istft

Computes the inverse short time Fourier transform

  1. auto istft(Xs xs, size_t noverlap)
  2. auto istft(Xs xs)
    istft
    (
    alias windowFun = hann
    Xs
    )
    (
    Xs xs
    )
    if (
    isSlice!Xs &&
    DimensionCount!Xs == 2
    )

Parameters

xs Xs

input 2d complex slice with the shape (ntimes, nfreq)

Examples

test stft-istft health

import std.complex;
import std.stdio;
import mir.ndslice : map, sliced;
import numir.testing : approxEqual;
// first 16 samples from https://raw.githubusercontent.com/ShigekiKarita/torch-nmf-ss-toy/master/test10k.wav
auto xs = [-10, 15, 106, -1, -655, -1553, -1501, -522,
           -106, 831, 1250, 381, 1096, 2302, 2686, 2427].sliced;
// need larger overlaps to revert well
auto ys = stft(xs, 8, 7);
auto ixs = istft(ys, 7).map!(c => c.re);
assert(approxEqual(ixs, xs));

See Also

Meta