We perform a theoretical investigation into the classical and quantum dynamics of an optical field in a cavity containing a moving membrane ("membrane-in-the-middle" set-up). Our approach is based on the Maxwell wave equation, and complements previous studies based on an effective Hamiltonian. The analysis shows that for slowly moving and weakly reflective membranes the dynamics can be approximated by unitary, first-order-in-time evolution given by an effective Schrödinger-like equation with a Hamiltonian that does not depend on the membrane speed. This approximate theory is the one typically adopted in cavity optomechanics and we develop a criterion for its validity. However, in more general situations the full second-order wave equation predicts light dynamics which do not conserve energy, giving rise to parametric amplification (or reduction) that is forbidden under first order dynamics and can be considered to be the classical counterpart of the dynamical Casimir effect. The case of a membrane moving at constant velocity can be mapped onto the Landau-Zener problem but with additional terms responsible for field amplification. Furthermore, the nature of the adiabatic regime is rather different from the ordinary Schrödinger case, since mode amplitudes need not be constant even when there are no transitions between them. The LandauZener problem for a field is therefore richer than in the standard single-particle case. We use the work-energy theorem applied to the radiation pressure on the membrane as a self-consistency check for our solutions of the wave equation and as a tool to gain an intuitive understanding of energy pumped into/out of the light field by the motion of the membrane.