Context. Over recent decades, asteroseismology has proven to be a powerful method for probing stellar interiors. Analytical descriptions of the global oscillation modes, in combination with pulsation codes, have provided valuable help in processing and interpreting the large amount of seismic data collected, for instance, by space-borne missions CoRoT, Kepler, and TESS. These prior results have paved the way to more in-depth analyses of the oscillation spectra of stars in order to delve into subtle properties of their interiors. This purpose conversely requires innovative theoretical descriptions of stellar oscillations. Aims. In this paper, we aim to analytically express the resonance condition of the adiabatic oscillation modes of spherical stars in a very general way that is applicable at different evolutionary stages. Methods. In the present formulation, a star is represented as an acoustic interferometer composed of a multitude of resonant cavities where waves can propagate and the short-wavelength JWKB approximation is met. Each cavity is separated from the adjacent ones by barriers, which corresponds to regions either where waves are evanescent or where the JWKB approximation fails. Each barrier is associated with a reflection and transmission coefficient. The stationary modes are then computed using two different physical representations: 1) studying the infinite-time reflections and transmissions of a wave energy ray through the ensemble of cavities or 2) solving the linear boundary value problem using the progressive matching of the wave function from one barrier to the adjacent one between the core and surface. Results. Both physical pictures provide the same resonance condition, which ultimately turns out to depend on a number of parameters: the reflection and transmission phase lags introduced by each barrier, the coupling factor associated with each barrier, and the wave number integral over each resonant cavity. Using such a formulation, we can retrieve, in a practical way, the usual forms derived in previous works in the case of mixed modes with two or three cavities coupled though evanescent barriers, low-and large-amplitude glitches, and the simultaneous presence of evanescent regions and glitches. Conclusions. The resonance condition obtained in this work provides a new tool that is useful in predicting the oscillation spectra of stars and interpret seismic observations at different evolutionary stages in a simple way. Practical applications require more detailed analyses to make the link between the reflection-transmission parameters and the internal structure. These aspects will be the subject of a future paper.