Answer:
because of the doppler effect
Step-by-step explanation:
Remember, the doppler effect refers to the changes in sound (frequency of sound) observed by a person who is in a position relative to the wave source.
In this example, we notice as the train comes closer to the boy, the sound becomes louder also increasing the pitch slightly, the doppler effect sets in when the train passes the boy because the boy notices a decrease in the pitch of the moving train.
We learn from the change in the observed sound of the train that the frequency of the sound is determined by the distance of the observer from the wave source.
In other words, the closer the source of the sound to the observer; the faster it travels to the observer, however, the farther it is; the lesser it is; the greater the sound heard.