Roughly working but unoptimized envelope generator.
Still needs unit tests and support for curves.