Optical determination of the velocity of sound in liquids