A study on longitudinal vibration of a pile with variable sectional acoustic impedance subjected to arbitrary form of external excitation is conducted. The analytical solution of transfer function is primarily solved by Laplace transform, and then its corresponding impulse response function is solved by residue method of inverse Laplace transformation. With impulse response function, the analytical solution of response at pile top can be obtained by convolution calculation, which overcomes the limit of previous analytical solutions subjected to prescribed time-harmonic load. The accuracy of presented solution is verified by compared with existing solutions subjected to semi-sine excitation and low-strain test of model piles. To take advantage of presented solution, this paper also proposes a case study of imposed excitation considering superimposed high-frequency interference component, and some conclusions derived from this case can provide practical guidance for engineering implementation.