Given the square-wave function (later used to illustrate Gibbs phenomenon) $$f(x) = \left\{\begin{array}{c} \frac{h}{2} & 0 < x < \pi \\ -\frac{h}{2} & -\pi < x < 0 \end{array}\right.$$ I'm asked to show that the first $r$ terms of its Fourier series $$S_r (x) = \frac{a_0}{2} + \sum_{n=1}^{r} \left (a_n \cos nx + b_n \sin nx \right)$$ can be written as
$$S_r (x) = \frac{1}{2 \pi}\displaystyle\int_{-\pi}^{\pi} f(t) \frac{\sin \left( (r+1/2)(t-x)\right)}{\sin \left( (t-x)/2\right)} dt$$
Now I realize that since $f$ is odd we expect to have only $b_n$ terms in our sum, whence the sines. However I do not quite get the same result when using the standard definition of $b_n$. Is there some kind of change of variable I should perform to get it to the above form? And why is there a $(t-x)$ term in the arguments of the sines?
Any help would be appreciated.
Hint: $$b_n = 2\frac{h \sin ^2\left(\frac{n\pi}{2}\right)}{n\pi}=\frac{h(1-(-1)^n)}{n\pi}$$ So: $$S_{2r-1}=\sum_{n=1}^r \frac{2h}{(2n-1)\pi}\sin((2n-1)x)$$
Now, write out the Riemann sum for the function $\sin(x)/x$ on the interval $[0,\pi]$