| istft {seewave} | R Documentation |
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")
Arguments
stft |
a complex matrix resulting of a short-term Fourier transform. |
f |
sampling frequency of the original |
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 |
output |
character string, the class of the object to return, either
|
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.
Value
A new wave is returned. The class of the returned object is set with the argument output.
Note
The stft input data must be complex.
This function is used by ffilter, lfs to
respectively filter in frequency and shift in frequency a sound.
The function can be used to reconstruct or modify a sound. See examples.
Author(s)
Original Matlab code by Hristo Zhivomirov (Technical University of Varna, Bulgaria), translated and adapted to R by Jerome Sueur
See Also
Examples
## Not run:
# 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)
## End(Not run)