# Stft of sinusoids

I have a sinusoidal signal of 10 minutes. For the first 5 minutes, the signal has a frequency of 100 Hz and for the next 5 minutes, the signal has a frequency of 200 Hz.

1 - If I look at the spectrogram of the signal calculated using stft windows of the length of 5 min and no overlap, what will I see in the spectrogram?

2 - If I look at the spectrogram of the signal calculated using the same stft window but with 50% overlap, what will I see in the spectrogram?

To answer your question in the context you have asked, you can look at it as follows:

You input signal is made up of two discrete-time sinusoids of equal length(5mins) $$x_1[n]$$ and $$x_2[n]$$. Supposing sampling rate such that 5mins correspond to $$N$$ samples and it is well above $$400Hz$$. So, your input signal will be of length $$2N$$.

Now, N-Point DFT of $$x_1[n]$$ will give you a vector of DFT coefficients $$X[k]$$ with peak at $$k$$ corresponding to $$100Hz$$ and similarly, N-Point DFT of $$x_2[n]$$ will give you a vector of DFT coefficients $$X[k]$$ with peak at $$k$$ corresponding to $$200Hz$$.

And, when the window is such that it contains $$\frac{N}{2}$$ samples from $$x_1[n]$$ and $$\frac{N}{2}$$ samples from $$x_2[n]$$, then the N-Point DFT will have 2 peaks at $$k$$'s corresponding to both frequencies $$100Hz$$ and $$200Hz$$.

Spectrogram will show the same effect:

1. It will show a jump in frequency, because each window contains only one frequency element.

2. It will show both frequency in the window where $$\frac{N}{2}$$ samples are taken from both frequencies. Also, notice that when there is a window where two frequencies overlap, then DFT will be sum of two sinc functions peaking at $$k$$'s corresponding to two frequencies. This is because then the content of the window becomes : $$[x_1[\frac{N}{2}+1:N] \ 0 \ 0 \ 0 \dots] + [0 \dots \ 0 \ 0 x_2[1:\frac{N}{2}]]$$ This effect can be seen in the below spectrogram in the middle window where we can see increased power in the entire frequency range $$[0, 2\pi]$$ and peaks at 2 frequencies.

What you exactly you are going to see will depend a lot on the details and not only the overlap. What's your FFT size, what's your hop size, what's your window function, how do the sinusoids line up with the FFT frequency grid, how do changes in the signal line up with the individual frames and how the changes in frequency are actually implemented (i.e. what's continuous and what isn't).