I apologize for any confusion in my previous response. It seems there may have been a misunderstanding. When a sound source is approaching an observer, the frequency of the sound waves does not actually change. The frequency of the sound wave is determined by the source and remains constant.
However, what does change is the perceived frequency of the sound by the observer due to the Doppler effect. The Doppler effect is the apparent change in frequency or pitch of a sound wave caused by relative motion between the source of the sound and the observer.
When a sound source approaches an observer, the sound waves get compressed or "squeezed" together, leading to an increase in the perceived frequency or pitch. This increase in frequency results in a higher-pitched sound. Conversely, when a sound source moves away from the observer, the sound waves get stretched out, causing a decrease in the perceived frequency or pitch.
So, to clarify, the frequency of the sound waves itself does not change, but the perceived frequency or pitch is affected by the relative motion between the source and the observer.