Refactor gain_schedule.

Simplify set_rate, prevent extra data copies in gain_schedule.cpp.