Acoustic resonances leading to high unsteady pressure levels may occur in flow past cavities. The resonance involves a coupling between the downstream-propagating instability wave on the shear layer spanning the open face of the cavity, and acoustic waves propagating within the cavity. These elements of the disturbance field are coupled by the scattering processes that occur at the upstream and downstream ends of the cavity. We develop a theoretical prediction method that combines propagation models in the central region of the cavity with scattering models for the end regions. In our analyses of the scattering processes at the cavity ends, the square-corner geometry is treated exactly, by a method employing the Wiener-Hopf technique. The shear layer is approximated as a vortex sheet in the edge scattering analyses, but finite shear-layer thickness is accounted for in analyzing the propagation of the waves along the length of the cavity. The global analysis leads to a prediction for the resonant frequencies which has much in common with the Rossiter formula, but contains no empirical constants. The analysis also determines the temporal growth (or decay) rate of each mode, thereby providing the stability boundaries in parameter space. Comparisons are made with existing experimental data.