We study the time-dependent response of a randomly magnetized medium (such as the solar atmosphere) to the propagation of acoustic waves, including energy transfer to the medium due to different physical processes. It is shown that the details of the interaction of a sound wave with an ensemble of magnetic flux tubes, and, in particular, the maximum energy input, crucially depends on the magnetic filling factor of the medium as well as on the distribution of the random tubes in space. The interaction of acoustic waves and unsteady wave packets with an ensemble of magnetic flux tubes reveals some simple and important features, which, in principle, are observable. A most important role in these effects is played by resonant interaction both absorption and scattering of the sound wave by flux tubes. We focus on the case when the incident wavelength (λ) is much larger than the separation (d) between tubes, which is in turn much larger than the tube radii (R).In the case of resonant absorption (an effect similar to Landau damping in the collisionless plasma) the energy of the incident acoustic wave is accumulated in the system of magnetic flux tubes and causes the acoustic wave (of frequency ω) to damp at a rate νL ∼ (R2/d2)ω. The energy remains for a long time in the form of flux-tube oscillations. Then, in a time ν-1rad which is much longer than the damping time of the sound wave, the resonant flux tubes radiate their energy as secondary acoustic (or MHD) waves, where νrad ∼ ωk2R2. The incident acoustic wave can also be resonantly scattered with the main contribution coming from the kink mode; it leads to a linear frequency shift and to the appearance of incoherent noise without a preliminary build up of wave energy in flux-tube oscillations. When the distribution of flux-tube natural frequencies is broader than νL the Landau-like resonant absorption process is more important than resonant scattering, but when the distribution is narrow the tubes are essentially identical and resonant absorption is generally absent so that resonant scattering dominates. A nonlinear analysis allows us to find the maximum energy input and the frequency shift and their dependence on the parameters of medium. Also, a detailed treatment is given of Landau-like damping due to excitation of sausage modes.