But the density of water does not vary much by depth (like 1% per 2 kilometers depth). Similar deal for temperature, density lowers by 1% per 20 degrees Celsius (and given that the temp of ocean water stays very much between like >0 and <<35, basically no difference in density.
In fact some of these properties of density of water are what make it such a weird substance, and enable the use of submarines, etc.
Something similar happens with sound but the range is way off.
https://en.m.wikipedia.org/wiki/SOFAR_channel