Variable-gain control for respiratory systems