The change in the pitch of the sound you just observed was made possible by a scientific phenomenon known as the Doppler Effect. The Doppler Effect stems from the motion of the source of a sound (in this case). The speed of audible sound is approximately 334 m/s (1140 ft/s). Now, when the source of that sound is moving towards the observer, the speed carries a velocity of the sound and also that of the moving source. The truck could be approaching you at 36.6 m/s (60 mph), which means that the speed of the sound and that of the truck combine to produce a velocity of 370.6 m/s. This increase in velocity results in a subsequent increase in frequency (velocity = frequency x wavelength), and as a result, an increase in pitch is detected. This increased pitch is then compounded by the truck actually moving closer to you, thus, a higher sound intensity, thus a higher volume. The sound then reaches a climax when the truck actually passes you as you stand there.
Just the opposite is true as the truck moves away from you. The sound's velocity is now the speed of sound MINUS the speed of the truck. The sound moving at 334 m/s emitted from a truck moving 36.6 m/s is now only 297.4 m/s. Again, a change in velocity results in a change in frequency results in a change in pitch, and a deeper, fading sound is noticeable.