The excitation of trapped diametral acoustic modes within a rectangular cavity attached to a cylindrical duct is investigated numerically and experimentally. Because the excited acoustic modes are highly three-dimensional, their interaction with the cavity shear layer results in complex patterns of flow oscillations. These are investigated for the special case of a square cavity, which exhibits three unique behaviors of the excited acoustic modes, including both stationary and spinning mode patterns. Phase-locked particle image velocimetry flow visualization accompanied with numerical simulation of the resonant sound fields indicate that the formation of disturbances is nonuniform and akin to the radial acoustic particle velocity distribution. In the instance of two acoustic modes being excited simultaneously, separate circumferential segments of the cylindrical shear layer do oscillate independently and at different frequencies, corresponding to the frequencies of the excited modes. Further, because of the symmetry inherent within the square geometry, two degenerate modes (i.e., orthogonal mode shapes with the same resonance frequency) generate a spinning mode when they are excited. The interaction of the spinning acoustic mode with the cavity shear layer leads to the formation of a three-dimensional helical vortex structure. These results underline the fact that a uniform excitation over the whole shear-layer circumference is not necessary for the generation of orderly vortical structures that maintain their coherence over the whole length of the cavity and sustain strong acoustic resonances.