This is due to Doppler effect. Doppler effect states that if the source approaches the observer, the frequency of the sound increases and if the source of sound recedes from the observer, the frequency of sound decreases.