9. (16 points) Given that $x$ is a real number. Find the range of the function
$$
f(x)=4 \sin ^{3} x+\sin ^{2} x-4 \sin x+8
$$
9. Let $t=\sin x(-1 \leqslant t \leqslant 1)$.
Then $f(x)=g(t)=4 t^{3}+t^{2}-4 t+8$.
Let $4 t^{3}+t^{2}-4 t+8$
$$
=(2 t+a)^{2}(t+b)+c \text {. }
$$

Thus, $4 t^{3}+t^{2}-4 t+8$
$$
=4 t^{3}+4(a+b) t^{2}+\left(a^{2}+4 a b\right) t+a^{2} b+c \text {. }
$$

By comparing coefficients, we get
$$
\begin{array}{l}
\left\{\begin{array}{l}
4(a+b)=1, \\
a^{2}+4 a b=-4, \\
a^{2} b+c=8
\end{array}\right. \\
\Rightarrow(a, b, c) \\
\quad=\left(-1, \frac{5}{4}, 6 \frac{3}{4}\right) \text { or }\left(\frac{4}{3},-\frac{13}{12}, 9 \frac{25}{27}\right) .
\end{array}
$$

Substituting these into equation (1), we get
$$
g(t)=(2 t-1)^{2}\left(t+\frac{5}{4}\right)+6 \frac{3}{4} \geqslant 6 \frac{3}{4},
$$

and when $t=\frac{1}{2}$, $g(t)$ has a minimum value, which is $6 \frac{3}{4}$;
$$
g(t)=\left(2 t+\frac{4}{3}\right)^{2}\left(t-\frac{13}{12}\right)+9 \frac{25}{27} \leqslant 9 \frac{25}{27},
$$

and when $t=-\frac{2}{3}$, $g(t)$ has a maximum value, which is $9 \frac{25}{27}$.
Since $g(t)$ is a continuous function, the range of $g(t)$ is $\left[6 \frac{3}{4}, 9 \frac{25}{27}\right]$, which means the range of $f(x)$ is $\left[6 \frac{3}{4}, 9 \frac{25}{27}\right]$.