Adenv crashes with segment times = 0

Just a heads-up: If someone sets a segment time on an envelope to zero (for example to have a zero attack), it will crash on the next Process() call.

Reason is that
time_samps = (uint32_t)(segment_time_[current_segment_] * sample_rate_);
ends up being zero and
[…]
c_inc_ = (end - beg) / time_samps;

will divide by zero.

@horstmaista @shensley yes not only that but the ADenv also behaves weirdly when you set MIN to 0.0f. If you use multiple envelopes (say 12) in a sketch, you start to get crackles and pops once the envelope reaches the 0 amplitude value. The crackles disappear when you set min to 0.001f (like is default), but you also let some volume through.

We haven’t looked deeper into why exactly that is because just finding the fact took a good few hours of head scratching last weekend :sweat_smile:

Our plan would have been to implement a simpler version without curve now and see if the problem persists.

@MakingSoundMachines - thanks for the headsup. Was wondering were that noise came from.

I just made an issue for this on the DaisySP GitHub repo.

1 Like

We’ll look into fixing this ASAP. I think I may have something that can fix the minimum issue (as that was similar, but only applied for signals with curves, linear should have transitioned to 0 fine). That patch also includes the ability to set curve for each segment separately.

I suppose the general consensus on segment time “0” would be to instantaneously jump to the next stage on the next sample?

2 Likes

Yeah, zero would just jump forward. Thanks @shensley!