Knowledge of the in-situ sound velocity of drilling mud can be used in mud-pulse acoustic telemetry for evaluating the presence and amount of gas invasion in the drilling mud. We propose a model for calculating the in-situ density and sound velocity of water-based and oil-based drilling muds containing formation gas. Drilling muds are modeled as a suspension of clay particles and high-gravity solids in water or oil, with the acoustic properties of these fluids depending on pressure and temperature. Since mud at different depths experiences different pressures and temperatures, downhole mud weights can be significantly different from those measured at the surface. Taking this fact into consideration, we assume constant clay composition and obtained the fraction of high-gravity solids to balance the formation pressure corresponding to a given drilling plan. This gives the in-situ density of the drilling mud, which together with the bulk moduli of the single constituents allow us to compute the sound velocity using Reuss's model. In the case of oil-based muds, we take into account the gas solubility in oil. When gas goes into solution, the mud is composed of solid particles, live oil and, eventually, free gas. A phenomenological model based on a continuous spectrum of relaxation mechanisms is used to describe attenuation due to mud viscosity. The calculations for water-based and oil-based muds showed that the sound velocity is strongly dependent on gas saturation, fluid composition, and drilling depth.