The speed of any wave/the speed of sound depends upon the properties of the medium through which the wave is traveling. But first if there is no medium for the wave or sound to go through, then there will be no sound. For example, there is no medium in space so there is no waves/sounds travelling in space. There are two factors that effect speed of sound. One of them is the elastic properties of the medium/material. Elastic properties of an object is how easily the object is able to bend or deform when a force is acted upon it. So the phase of matter effects the elastic properties of the medium. For example, longitudinal sound waves travel faster in solids than liquids and gases due to their elasticity properties. Another factor that affect the speed of light is the density of a medium.The greater the density of individual particles of the medium the slower that the wave will be. A sound wave will travel faster in a less dense material than a more dense material.