4. Given the function $y=A \sin (\omega x+\varphi)+m$ has a maximum value of 4, a minimum value of 0, a smallest positive period of $\frac{\pi}{2}$, and is symmetric about the line $x=\frac{\pi}{3}$. If $A>0, \omega>0,0<\varphi<\frac{\pi}{2}$, then $f(x)=$ $\qquad$ 1 .
4. $2 \sin \left(4 x-\frac{\pi}{6}\right)+2$.

From the problem, we know the maximum value is $A+M=4$, the minimum value is $A-m=0, A=2, m=2$.
From the conditions, we know the period $T=\frac{2 \pi}{\omega}=\frac{\pi}{2}, \omega=4$, the axis of symmetry is $\omega x+\varphi=k \pi+\frac{\pi}{2}(k \in \mathbf{Z})$.
4. $\frac{\pi}{3}+\varphi=k \pi+\frac{\pi}{2}(k \in \mathbf{Z}), \varphi=k \pi-\frac{\pi}{6}(k \in \mathbf{Z}) \cdot \varphi=-\frac{\pi}{6}, f(x)=2 \sin \left(4 x-\frac{\pi}{6}\right)+2$