Difficult math (filter envelopes)

Cleaning up the filter envelopes. They're now simpler, and will be
easier to break down into smaller functions later. More DRY
improvements.