Predicting accurate ground motion is critical for earthquake hazard analysis, particularly in situations where sedimentary basins trap and amplify seismic waves. We exploit the information carried by the ambient seismic field to extract surface-wave Green's functions between seismic stations and to predict long-period ground motion from earthquakes. To do so, we modify the surface impulse response to correct for the source depth and for the double-couple focal mechanism. These corrections are derived under the assumption that material properties in the immediate vicinity of the source depend only on depth. Using this local 1-D assumption, we solve the surface-wave eigenproblem and compute the fundamental-mode displacement eigenfunctions to express the surface-wave excitation at the source. We validate this technique, which we call the virtual earthquake approach, by comparing computed seismograms with earthquake waveforms from four moderate earthquakes that occur near broadband stations in southern California. The depth and mechanism corrections show clear improvements of the predicted ground motion relative to the surface impulse response.