Speed of sound and distance calculation