As a sound source approaches you, successive wavefronts arrive closer together. The observed frequency is higher, and the sound is heard at a higher pitch. As it recedes, wavefronts arrive farther apart and the observed pitch falls.
This is the Doppler effect. The source can be producing the same frequency throughout; the change comes from relative motion between source and observer. Loudness may change as well, but loudness and pitch describe different aspects of the sound.