The product of (frequency) times (wavelength) is always the same number ...
the speed of the wave.
So if one of them changes, then the other one must change by the same
factor in the opposite direction, in order for the product to not change.
This works for sound and all electromagnetic waves.