# How to Calculate the number of DFTs taken in a STFT

Given variables of window size (W), overlap (O), and length of the Signal (S) (in my case, length of a song) and I am trying to determine an equation that gives me the number of DFTs that would be taken in an STFT as the window slides given those variables above. I'm not sure if those variables is enough to give me the equation or not, and if it is, I'm not sure how to derive that equation.

I will first produce a lower number based on the covering of all the non-zero sample set.

With a window of size $W$, counting samples from $0$ to $S-1$, the first window containing at least one sample covers $[-W+1,0]$. If the discrete overlap range is a number of samples $O<W$, the next window will be $$[1-O,W-O]=[-W+1,0]+(W-O)$$ and the others $k$th hops are $$[-W+1,0]+k(W-O)$$ Those intervals exceed the last sample $S-1$ when $0+k(W-O)\ge S-1$ or

$$k\ge \left\lceil\frac{S-1}{W-O}\right\rceil$$

so the covering takes $\left\lceil\frac{S-1}{W-O}\right\rceil+1$ windows, hence DFTs.

Does this suffice in general, as we did not use any window property? For instance, if the window is non-null at one point only (or vanishes), the $O$ cannot be chosen arbitrarily.

The question in general seems open to me. For randomly chosen complex filterbanks, the smallest oversampling seems to suffice for recovery. For other tasks, who knows?

• i guess this is correct. i think we might wanna know what a minimum hop rate (the reciprocal of the hop size $W-O$) is as a function of some property (like the degree of its stationarity, like how fast is the spectrum changing) of the signal. – robert bristow-johnson Jul 16 '18 at 1:43