From d5a4d1ee88330cd29bb91c3c9b689959c10026de Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sat, 26 Dec 2020 19:14:18 +0100 Subject: [PATCH] =?UTF-8?q?Implemented=20b3e5c500e3546c0467629ccd08da3901a?= =?UTF-8?q?21b8848=20from=20asb2m10:=20Implement=20accurate=20DX7=20envelo?= =?UTF-8?q?pes=20for=20the=20case=20that=20the=20attack=20phase=20h?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/msfa/env.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/msfa/env.cc b/src/msfa/env.cc index 58478a3..b61e9d3 100644 --- a/src/msfa/env.cc +++ b/src/msfa/env.cc @@ -71,7 +71,10 @@ int32_t Env::getsample() { #endif if (ix_ < 3 || ((ix_ < 4) && !down_)) { - if (rising_) { + if (staticcount_) { + ; + } + else if (rising_) { const int jumptarget = 1716; if (level_ < (jumptarget << 16)) { level_ = jumptarget << 16; @@ -83,9 +86,6 @@ int32_t Env::getsample() { advance(ix_ + 1); } } - else if (staticcount_) { - ; - } else { // !rising level_ -= inc_; if (level_ <= targetlevel_) { @@ -126,7 +126,7 @@ void Env::advance(int newix) { qrate = min(qrate, 63); #ifdef ACCURATE_ENVELOPE - if (targetlevel_ == level_) { + if (targetlevel_ == level_ || (ix_ == 0 && newlevel == 0)) { // approximate number of samples at 44.100 kHz to achieve the time // empirically gathered using 2 TF1s, could probably use some double-checking // and cleanup, but it's pretty close for now. @@ -134,6 +134,9 @@ void Env::advance(int newix) { staticrate += rate_scaling_; // needs to be checked, as well, but seems correct staticrate = min(staticrate, 99); staticcount_ = staticrate < 77 ? statics[staticrate] : 20 * (99 - staticrate); + if (staticrate < 77 && (ix_ == 0 && newlevel == 0)) { + staticcount_ /= 20; // attack is scaled faster + } staticcount_ = (int)(((int64_t)staticcount_ * (int64_t)sr_multiplier) >> 24); } else {