# Loop bug in applying envelope function

**URL:** https://discourse.processing.org/t/loop-bug-in-applying-envelope-function/10077
**Category:** Libraries
**Created:** [April 8, 2019, 10:39am UTC](https://discourse.processing.org/t/loop-bug-in-applying-envelope-function/10077 "2019-04-08T10:39:09Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [April 8, 2019, 12:27pm UTC](https://discourse.processing.org/t/loop-bug-in-applying-envelope-function/10077/2 "2019-04-08T12:27:39Z")

</div>

-a- from the reference it is clear that they all add up.  
[https://p5js.org/reference/#/p5.Envelope/setInput](https://p5js.org/reference/#/p5.Envelope/setInput)

-b- i try like

```auto
//...
      reset();
      env.setInput(song[i]);
      env.play();
    }
  }
}

function reset() {
  env = new p5.Envelope();
  env.setADSR(attackTime, decayTime, susPercent, releaseTime);
  env.setRange(attackLevel, releaseLevel);
}

```

first it looks like it is working,  
but then my browser still hangs ( check on memory );

---

_[View the full topic](https://discourse.processing.org/t/loop-bug-in-applying-envelope-function/10077)._
