In fact, assuming an ideal gas, the speed of sound c depends on temperature and composition only, not on the pressure or density (since these change in lockstep for a given temperature and cancel out). Air is almost an ideal gas. The temperature of the air varies with altitude, giving the following variations in the speed of sound using the standard atmosphere— actual conditions may vary.