seewave (version 2.2.3)

istft: Inverse of the short-term Fourier transform

Description

This function returns a wave object from a complex STFT matrix by computing the inverse of the short-term Fourier transform (STFT)

Usage

istft(stft, f, wl, ovlp=75, wn="hanning", output = "matrix")

Value

A new wave is returned. The class of the returned object is set with the argument output.

Arguments

stft

a complex matrix resulting of a short-term Fourier transform.

f

sampling frequency of the original wave object (in Hz)

wl

FFT window length for the analysis (even number of points).

ovlp

overlap between successive FFT windows (in %, by default 75%, see the Details section).

wn

character string specifying the FFT window name, see ftwindow (by default "hanning").

output

character string, the class of the object to return, either "matrix", "Wave", "audioSample" or "ts".

Author

Original Matlab code by Hristo Zhivomirov (Technical University of Varna, Bulgaria), translated and adapted to R by Jerome Sueur

Details

The function is based on the inverse of the FFT (see fft) and on the overlap add (OLA) method.
The overlap percentage must satisfy the Perfect Reconstruction OLA-constraint. For the most windows, this constraint is:
$$ovlp = 100 \times (1 - \frac{1}{4 \times n}),$$
with n being a positive integer.
A default value is set to 75%. We suggest not to change it.

See Also

spectro, ffilter, lfs

Examples

Run this code
if (FALSE) {
# STFT and iSTFT parameters
wl <- 1024
ovlp <- 75
# reconstruction of the tico sound from the stft complex data matrix
data(tico)
data <- spectro(tico, wl=wl, ovlp=ovlp, plot=FALSE, norm=FALSE, dB=NULL, complex=TRUE)$amp
res <- istft(data, ovlp=ovlp, wn="hanning", wl=wl, f=22050, out="Wave")
spectro(res)
# a strange frequency filter
n <- noisew(d=1, f=44100)
data <- spectro(n, f=44100, wl=wl, ovlp=ovlp, plot=FALSE, norm=FALSE, dB=NULL, complex=TRUE)$amp
data[64:192, 6:24] <- 0 
nfilt <- istft(data, f=8000, wl=wl, ovlp=ovlp, output="Wave")
spectro(nfilt, wl=wl, ovlp=ovlp)
}

Run the code above in your browser using DataLab