Forum Rule: Always post complete source code & details to reproduce any issue!

# Thread: Nonlinear Decay with Effect_Envelope?

1. ## Nonlinear Decay with Effect_Envelope?

Hey all, I've been experimenting with the synth library for the past few months, specifically working on synthesizing percussive sounds, and I've come to the conclusion that part of the reason I can't get the snappy sounds I am after is because the envelope effect decay is too linear. I started trying to decipher the source code for somewhere I might be able to pop in a function to adjust the slope of the decay but having trouble figuring out where in here the linear decay is being implemented. If anyone has ideas and can point me in a direction of what I should be looking at it would be a huge help!

Links to the relevant code for reference:
https://github.com/PaulStoffregen/Au...t_envelope.cpp
https://github.com/PaulStoffregen/Au...ect_envelope.h

2. hi cyclpsrock

3. Originally Posted by houtson
hi cyclpsrock

Thank you! Very interesting, somehow missed this in my search.

4. Originally Posted by cyclpsrock
Hey all, I've been experimenting with the synth library for the past few months, specifically working on synthesizing percussive sounds, and I've come to the conclusion that part of the reason I can't get the snappy sounds I am after is because the envelope effect decay is too linear. I started trying to decipher the source code for somewhere I might be able to pop in a function to adjust the slope of the decay but having trouble figuring out where in here the linear decay is being implemented. If anyone has ideas and can point me in a direction of what I should be looking at it would be a huge help!

The update method's loop uses inc to adjust the envelope value (mult) for each sample. The code is highly optimized
for linear slopes only, its effectively this in pseudo-code:

Code:
```  output <- input * mult
mult <- mult + inc
counter <- counter - 1```
When the counter reaches zero its the end of the current phase, and the state machine advances.

The actual code is complicated by using both high and low resolution variables, and by loop-unrolling,
all to save a few CPU cycles.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•