This paper deals with strategies for computing efficiently the propagation of sound waves in ducts with acoustic lining at its walls. Although efficient, these treatments seem to have reached their limit and there is still a need for considering other passive techniques to reduce further the sound radiation at the duct exit. In most cases of practical interest, these added acoustics components can be modeled as acoustic cavities, which are connected to the duct and can be either purely reactive or dissipative. The assessment of the efficiency of such a system requires a precise knowledge of the acoustic field in the duct. Although standard Finite Element (FE) software could, in principle, be used for this purpose, a full FE model would be extremely demanding, particularly in the mid-frequency range and this can have a negative impact when, for instance, some efficient optimizations are needed. In the present work, we present a new numerical procedure that judiciously exploits the benefit of the FEM and the BEM approach. Firstly, a set of FE eigenmodes are computed in the cavity to produce a numerical impedance matrix connecting the pressure and the acoustic velocity on the duct wall interface. Then an integral representation for the acoustic pressure in the main duct is used. The presence of acoustic liners on the walls of the duct is taken into account via an appropriate modal decomposition of the Green's function. Typical applications involving Helmholtz resonators and Herschel-Quincke tubes are presented. We show that our algorithm allows a very fast and accurate computation of the scattering matrix of such a system with a numerical complexity that grows very mildly with the frequency.