Skip to content

Envelope resets the amplitude of an oscillator to one on play #3

@defrost256

Description

@defrost256

In the Env.play() method the value for the envelope data for the SegmentedEnvelope assumes the value of the attack is 1f instead of the expected input.amp, taking control away from the developer.
Easy fix:

SegmentedEnvelope env = new SegmentedEnvelope(new double[] {
				attackTime, input.amp, // attack
				// gradual decay towards sustain level across entire sustain period
				sustainTime, sustainLevel, // sustain
				releaseTime, 0.0 });

instead of

SegmentedEnvelope env = new SegmentedEnvelope(new double[] {
				attackTime, 1.0, // attack
				// gradual decay towards sustain level across entire sustain period
				sustainTime, sustainLevel, // sustain
				releaseTime, 0.0 });

On another note I think sustain level might be more intuitive represented as a fraction of amplitude as well

SegmentedEnvelope env = new SegmentedEnvelope(new double[] {
				attackTime, input.amp, // attack
				// gradual decay towards sustain level across entire sustain period
				sustainTime, sustainLevel * input.amp, // sustain
				releaseTime, 0.0 });

I'm going to make a PR for the first one shortly, since that's an actual problem, but I'll wait with the second one in case there is discussion to be had about it.
Keep up the good work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions