Question about finite analog of $\int_0^\infty \frac{\sin x\sinh x}{\cos (2 x)+\cosh \left(2x \right)}\frac{dx}{x}=\frac{\pi}{8}$ The integral
$$
\int_0^\infty \frac{\sin x\sinh x}{\cos (2 x)+\cosh \left(2x \right)}\frac{dx}{x}=\frac{\pi}{8},
$$
is given as equation $(17)$ in  M.L. Glasser, Some integrals of the Dedekind $\eta$-function.
More general integral
$$
\int_0^\infty \frac{\sin x\sinh (x/a)}{\cos (2 x)+\cosh \left(2x/a\right)}\frac{dx}{x}=\frac{\tan^{-1} a}{2},\tag{1}
$$
can be deduced as a limiting case of formula $4.123.6$ in Gradsteyn and Ryzhik.
I have been looking for finite elementary analogs of integral $(1)$ and have proved that
\begin{align}\label{}
\int_0^{1}\frac{\sin \bigl(n \sin^{-1}t\bigr)\sinh \bigl(n \sinh^{-1}(t/a)\bigr)}{\cos \bigl( 2 n \sin^{-1}t\bigr)+\cosh \bigl(2 n \sinh^{-1}(t/a)\bigr)}\frac{dt}{t \sqrt{1-t^2} \sqrt{1+{t^2}/{a^2}}}=\frac{\tan^{-1} a}{2},\tag{1a}
\end{align}
for an odd integer $n$.
When $n\to\infty$ equation $(1a)$ will give equation $(1)$. This is easy to see because when $n$ is large then the main contribution to $(1a)$ comes from a small neighborhood around $0$. 

Q: Can you explain why this integral has such a simple closed form and in particular why it has the same value for all odd $n$?

I want to stress that I have a proof which is based on partial fractions expansion for odd $n$
\begin{align}
&\frac{\sin \bigl(n \sin^{-1}t\bigr)\sinh \bigl(n \sinh^{-1}(t/a)\bigr)}{\cos \bigl( 2 n \sin^{-1}t\bigr)+\cosh \bigl(2 n \sinh^{-1}(t/a)\bigr)}\frac{2n}{t^2}\\&=\sum _{j=1}^n\frac{i(-1)^{j-1} }{\sin\frac{\pi  (2 j-1)}{2 n}}\cdot \frac{\left(a\cos\frac{\pi  (2 j-1)}{2 n}+i\right) \left(a+i \cos\frac{\pi  (2 j-1)}{2 n}\right)}{t^2 \left(a^2-1+2 ia \cos\frac{\pi  (2 j-1)}{2 n}\right)-a^2 \sin ^2\frac{\pi  (2 j-1)}{2 n}},
\end{align}
the elementary integral
\begin{align}
\int_0^1 \frac{t}{t^2 \left(a^2-1+2 ia \cos\frac{\pi  (2 j-1)}{2 n}\right)-a^2 \sin ^2\frac{\pi  (2 j-1)}{2 n}}\frac{dt}{\sqrt{1-t^2} \sqrt{1+{t^2}/{a^2}}}\\=\frac{\tan^{-1}a+i\tanh^{-1}\cos\frac{\pi  (2 j-1)}{2 n}}{i\left(a\cos\frac{\pi  (2 j-1)}{2 n}+i\right) \left(a+i \cos\frac{\pi  (2 j-1)}{2 n}\right)},
\end{align}
and summation formula which can be deduced from the partial fractions above
$$
\sum _{j=1}^n \frac{(-1)^{j-1}}{\sin \frac{\pi  (2 j-1)}{2 n}}=n.
$$
But despite this prove I don't understand why all these cancellations occur to give such a simple result at the end. I suspect there is a very short and transparent proof which explains why the integral is $\frac{\tan^{-1} a}{2}$ for all odd $n$. Maybe Glasser's master theorem or some contour integration can explain this formula? Motivation for this question is desire to understand this integration formula.
Any alternative proof is welcome if it is not just a detailed version of the proof above. Any ideas and comments are welcome. Thanks.

$$I_n\left(a\right)=\int_{0}^{1}{\frac{\sin{\left(n\sin^{-1}\left(t\right)\right)}\sinh{\left(n\sinh^{-1}{\left(\frac{t}{a}\right)}\right)}}{\cos{\left(2n\sin^{-1}\left(t\right)\right)}+\cosh{\left(2n\sinh^{-1}{\left(\frac{t}{a}\right)}\right)}}\frac{dt}{t\sqrt{1-t^2}\sqrt{1+\left(\frac{t}{a}\right)^2}}\ } $$
$$t\rightarrow\sqrt{\frac{a^2\left(\coth^2{\left(z\right)}-1\right)}{a^2\coth^2{\left(z\right)}+1}}\ $$
$$I_n\left(a\right)=\int_{0}^{\infty}{\frac{\sin{\left(n\sin^{-1}{\left(\frac{a}{\sqrt{a^2+\left(a^2+1\right)\sinh^2{(z)}}}\right)}\right)}\sinh{\left(n\sinh^{-1}{\left(\frac{1}{\sqrt{a^2+\left(a^2+1\right)\sinh^2{(z)}}}\right)}\right)}}{\cos{\left(2n\sin^{-1}{\left(\frac{a}{\sqrt{a^2+\left(a^2+1\right)\sinh^2{(z)}}}\right)}\right)}+\cosh{\left(2n\sinh^{-1}{\left(\frac{1}{\sqrt{a^2+\left(a^2+1\right)\sinh^2{(z)}}}\right)}\right)}}dz\ }$$
Using the following identities:
$$\color{red}{\frac{sin(\alpha)sinh(\beta)}{cos(2\alpha)+cosh(2\beta)}=\frac{sec(\alpha+i\beta)-sec(\alpha-i\beta)}{4i}}$$
$$\color{red}{\sin^{-1}(x)=-i\log\left(ix+\sqrt{1-x^2}\right)}$$
$$\color{red}{\sinh^{-1}(x)=\log\left(x+\sqrt{1+x^2}\right)}$$
$$\color{red}{x+yi=\sqrt{x^2+y^2}e^{i\tan^{-1}(y/x)}}$$
$$I_n(a)=\frac{1}{4i}\int_0^\infty\left[\sec{\left(-in\ log\left(\frac{e^z-e^{-i\tan^{-1}(a)}}{e^z+e^{-i\tan^{-1}(a)}}\right)\right)}-\sec{\left(-in\ log\left(\frac{e^z+e^{i\tan^{-1}(a)}}{e^z-e^{\tan^{-1}(a)}}\right)\right)}\right]dz$$
$$=\frac{1}{2i}\int_{0}^{\infty}{\left[\underbrace{\frac{\left[e^{2z}-e^{-2i\tan^{-1}(a)}\right]^n}{\left(e^z+e^{-i\tan^{-1}(a)}\right)^{2n}+\left(e^z-e^{-i\tan^{-1}(a)}\right)^{2n}}}_{z\rightarrow -z}-\frac{\left[e^{2z}-e^{2i\tan^{-1}(a)}\right]^n}{\left(e^z+e^{i\tan^{-1}(a)}\right)^{2n}+\left(e^z-e^{i\tan^{-1}(a)}\right)^{2n}}\right]dz\ }$$
$$=\frac{1}{2i}\int_{-\infty}^{0}\frac{(-1)^n\left[e^{2z}-e^{2i\tan^{-1}(a)}\right]^n}{\left(e^z+e^{i\tan^{-1}(a)}\right)^{2n}+\left(e^z-e^{i\tan^{-1}(a)}\right)^{2n}}dz-\frac{1}{2i}\int_{0}^{\infty}\frac{\left[e^{2z}-e^{2i\tan^{-1}(a)}\right]^n}{\left(e^z+e^{i\tan^{-1}(a)}\right)^{2n}+\left(e^z-e^{i\tan^{-1}(a)}\right)^{2n}}dz$$
Assuming that $n$ is odd:
$$I_n(a)=-\frac{1}{2i}\int_{-\infty}^{\infty}\frac{\left[e^{2z}-e^{2i\tan^{-1}(a)}\right]^n}{\left(e^z+e^{i\tan^{-1}(a)}\right)^{2n}+\left(e^z-e^{i\tan^{-1}(a)}\right)^{2n}}dz$$
$$=-\frac{1}{2i}\int_{-\infty}^{\infty}{\frac{{tanh}^n\left(\frac{z-i\ tan^{-1}(a)}{2}\right)}{{tanh}^{2n}\left(\frac{z-i\ tan^{-1}(a)}{2}\right)+1}\ dz}$$
Now, let's apply Complex Analysis.First, let's define $g(w)$ and then integrate over a rectangular contour.
$$g(w)=\frac{{tanh}^n\left(\frac{w}{2}\right)}{{tanh}^{2n}\left(\frac{w}{2}\right)+1}$$
$$\oint{g(w)dw}=\left[\color{red}{\int_{R}^{-R}}+{\color{blue}{\int_{-R}^{-R-i\ tan^{-1}(a)}}+\int_{-R-i\tan^{-1}(a)}^{R-i\tan^{-1}(a)}}+\color{blue}{\int_{R-i\tan^{-1}(a)}^{R}}\right]{g\left(w\right)dw\ }$$
Notice that the red integral will be zero due to the parity of the function, provided that $n$ is an odd number.
The blue integrals can be rewritten as:
$$\lim_{R\rightarrow\infty}{\int_{-R}^{-R-i\ tan^{-1}(a)}{g\left(w\right)dw\ }}+\lim_{R\rightarrow\infty}{\int_{R-i\tan^{-1}(a)}^{R}{g\left(w\right)dw\ }}$$
$$=i\int_{0}^{-\ tan^{-1}(a)}{\lim_{R\rightarrow\infty}\frac{{tanh}^n\left(\frac{iz-R}{2}\right)}{{tanh}^{2n}\left(\frac{iz-R}{2}\right)+1}dz\ }{+}i\int_{-\ tan^{-1}(a)}^{0}{\lim_{R\rightarrow\infty}\frac{{tanh}^n\left(\frac{iz+R}{2}\right)}{{tanh}^{2n}\left(\frac{iz+R}{2}\right)+1}dz\ }$$
$$=-\frac{i}{2}\int_{0}^{-\ tan^{-1}\left(a\right)}{dz\ }{+}\frac{i}{2}\ \int_{-\ tan^{-1}\left(a\right)}^{0}{dz\ }=i\tan^{-1}{(a)}$$
The last integral from the RHS:
$$\lim_{R\rightarrow\infty}{\int_{-R-i\tan^{-1}{(a)}}^{R-i\tan^{-1}{(a)}}{g(w)dw\ }}=\lim_{R\rightarrow\infty}\int_{-R}^{R}{g(z-i\tan^{-1}{(a)})dz\ }=\int_{-\infty}^{\infty}{\frac{{tanh}^n\left(\frac{z-i\ tan^{-1}(a)}{2}\right)}{{tanh}^{2n}\left(\frac{z-i\ tan^{-1}(a)}{2}\right)+1}\ dz}$$
Computing the residues (I'm not sure about this part, please, if you have any insight about it feel free to edit or comment):
$$\oint g(w)dw=2\pi i\lim_{w\rightarrow w_k=2\tanh^{-1}(\pm e^{\frac{\pi i(2k-1)}{2n}})}\sum_{k=1}^n g(w)(w-w_k)$$
$$\left[\frac{2\pi i}{n}-\frac{2\pi i}{n}\right]\sum_{k=1}^{n}\frac{1}{e^{\frac{\pi i\left(2k-1\right)}{2n}(n-1)}+e^{-\frac{\pi i\left(2k-1\right)}{2n}(n-1)}}=0$$
Gathering the results:
$$\int_{-\infty}^{\infty}{\frac{{tanh}^n\left(\frac{z-i\ tan^{-1}(a)}{2}\right)}{{tanh}^{2n}\left(\frac{z-i\ tan^{-1}(a)}{2}\right)+1}\ dz}=-i\tan^{-1}(a)$$
Thus
$$I_n(a)=\int_{0}^{1}{\frac{\sin{\left(n\sin^{-1}\left(t\right)\right)}\sinh{\left(n\sinh^{-1}{\left(\frac{t}{a}\right)}\right)}}{\cos{\left(2n\sin^{-1}\left(t\right)\right)}+\cosh{\left(2n\sinh^{-1}{\left(\frac{t}{a}\right)}\right)}}\frac{dt}{t\sqrt{1-t^2}\sqrt{1+\left(\frac{t}{a}\right)^2}}\ }=\frac{tan^{-1}(a)}{2}$$
