From 1c71eb6f0f38b8703b26b35d32c315332998f1a2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 1 Aug 2023 14:25:28 +0200 Subject: [PATCH] option for retriggering the envelope --- synth/tx_envelope.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/synth/tx_envelope.h b/synth/tx_envelope.h index 6cf2fe6..7198670 100644 --- a/synth/tx_envelope.h +++ b/synth/tx_envelope.h @@ -30,7 +30,7 @@ public: float release1_level; float release2_rate; - tx_envelope() + tx_envelope(bool _retrigger = false) : samplerate { 44100. } , attack1_rate { 0 } , attack1_level { 0 } @@ -50,6 +50,7 @@ public: , h1 { 0. } , h2 { 0. } , h3 { 0. } + , retrigger { _retrigger } { } @@ -65,7 +66,10 @@ public: // if note on is triggered, transition to attack phase if (trigger) { - start_level = level; + if (retrigger) + start_level = 0.f; + else + start_level = level; phase = 0; state = attack1; } @@ -264,6 +268,7 @@ private: float h1; float h2; float h3; + bool retrigger; float lerp(float x1, float y1, float x2, float y2, float x) { return y1 + (((x - x1) * (y2 - y1)) / (x2 - x1)); }