In situ observations of magnetosonic waves modulated by background plasma density