Calculating the magnitude spectrum and phase spectrum

From a window function $$x(t)=u(t+2)-u(t-2)$$, we can get the Fourier Transform $$X(j\omega)=\frac{2\sin(2\omega)}{\omega}$$.

Then, I want to calculate its magnitude spectrum and phase spectrum.

The magnitude spectrum is the magnitude distribution at every $$\omega$$, so it's simply absolute value of $$X(j\omega)$$, is this correct?

And how to calculate the phase spectrum?

Magnitude $$M(\omega)\ge 0$$ and phase $$\phi(\omega)$$ are defined by
$$X(\omega)=M(\omega)e^{j\phi(\omega)}\tag{1}$$
Note that $$(1)$$ is generally complex-valued. In your example, the Fourier transform $$X(\omega)$$ is clearly real-valued. This restricts the possible values of the phase $$\phi(\omega)$$. What are those two values of $$\phi(\omega)$$ for which $$X(\omega)$$ in $$(1)$$ is real-valued? How do they relate to the sign of $$X(\omega)$$? I'm sure you can take it from here.
• Thanks for you help. Since it's real-valued, the phase should be 0 for positive and $+\pi$ or $-\pi$ for negative. But, $X(j\omega)$ is smooth, should the phase be $\pi$ at only the peak of each negative loop, like shifted $\delta$ function? Or should it last for the whole negative loop? Apr 2 '20 at 12:18
• I tried to express $X(j\omega)$ in the complex form, I got $\frac{j}{\omega}(e^{-j2\omega}-e^{j2\omega})$ Apr 2 '20 at 12:20
• @keanehui: The phase must equal $\pi$ for all frequencies for which $X(\omega)$ is negative, otherwise the phase equals zero. Apr 2 '20 at 12:26