From 4e8508b8a3b3c41ea5d6f4dfe2dffe4fad868b4b Mon Sep 17 00:00:00 2001 From: Garrett Date: Sun, 9 Nov 2014 22:41:46 -0800 Subject: [PATCH] Exponential decay for release instead of linear It now sounds much more like the release in Linux Sampler. --- plugins/GigPlayer/GigPlayer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index f678bf7bc..0e6a97a99 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -1204,7 +1204,15 @@ double ADSR::value() { if( releasePosition < releaseLength ) { - amplitude = sustain * ( 1.0 - 1.0 / releaseLength * releasePosition ); + // Maybe not the best way of doing this, but it appears to be about right + amplitude = sustain * exp( -5.0 / releaseLength * releasePosition ) - 1e-5; + + // Don't have an infinite exponential decay + if( amplitude < 0 ) + { + amplitude = 0; + isDone = true; + } } else {