A GainNode could be optimized where if the gain value is exactly 1 it just passes audio through to save CPU, rather than iterating over the entire buffer needlessly.
Probably best to check if the starting, middle, and ending gain values are 1. Otherwise a rapid change could be missed.