Elasticity in Solids
The speed of a wave that travels through solid materials is partially determined by the elasticity of the solid. The elasticity of a solid is determined by how much its shape changes when it is placed under stress. Solids with high elasticity, such as rubber, change greatly under pressure and the speed of sound waves through these kinds of materials is much slower. Solids with low elasticity, such as steel, retain their shape and waves are able to travel at higher speeds.
Density in Solids
The speed of a wave through a solid is also determined by the density of the solid. Density is simply the overall mass of the material per volume. Therefore, solids that are made of large molecules tend to have greater density, or mass per volume. Dense solids are much harder for waves to travel through and so will slow down the speed of the wave.
Gases
Gases with high density, such as xenon, slow waves down while lighter gases, such as helium and hydrogen, allow waves to travel at greater speeds. Gases are highly elastic, so density is the more important factor in determining wave speed. However, the density of the gas does not affect the sound wave as long as the gas exists at a constant temperature. In this case, the temperature of the gas determines the speed of the wave. Wave energy is transmitted by causing molecules to move and transfer that movement to adjacent molecules. Temperature determines how fast molecules are moving prior to the wave arriving. At a higher temperature, the molecules will already be moving a great deal, so less energy will be required to transfer wave energy and the wave will travel faster. At lower temperatures, the opposite is true. If the temperature is constantly fluctuating, then density comes into play as the temperature is not consistent enough to determine the speed of the wave.
Humidity
Water molecules are less elastic than gas molecules. This is because the atoms in water molecules are more powerfully attracted to each other than the atoms in gas molecules. When a force acts upon water, the molecules are displaced but return to their previous position more quickly than gas molecules. As wave energy is transmitted through moving molecules, the sooner molecules return to their positions, the sooner they can be moved again and the wave can travel faster. When the air is humid, it is full of water molecules and waves travel more quickly.
Atmosphere
At higher temperatures, waves travel faster because less energy is required to cause molecules to move. At high altitudes, the air is much colder so waves subsequently travel slower, a phenomenon called the sound-speed gradient. In the stratosphere, the speed of waves increases again as the warm ozone layer, which lies adjacent to the stratosophere, warms up the air. In this case, neither elasticity nor density is the the defining factor in determining the speed of the wave.