The denser the medium, the faster the sound wave travels. This is because the particles in a denser medium are more closely packed together and can therefore transfer the energy of the sound wave more quickly. The temperature of the medium also affects the speed of sound. Sound waves travel faster in warmer media because the particles in the medium have more energy and can therefore move more quickly.
Sound waves can travel through solids, liquids, and gases. However, the speed of sound is different in each type of medium. Sound waves travel fastest in solids, slower in liquids, and slowest in gases.