a-Reverb: Interpolate parameters, stable version
authorDamien Zammit <damien@zamaudio.com>
Wed, 13 Jul 2016 13:58:07 +0000 (23:58 +1000)
committerDamien Zammit <damien@zamaudio.com>
Wed, 13 Jul 2016 13:58:07 +0000 (23:58 +1000)
libs/plugins/a-reverb.lv2/a-reverb.c
libs/plugins/a-reverb.lv2/a-reverb.ttl.in

index ef7ace0ae60e8120bafac5b7f5d2a2a559b2387b..4c5251d217576c77fa9f886a13f84c4bc4c9e7ae 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // needed for M_PI
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -28,7 +32,6 @@
 #define RV_NZ 7
 #define DENORMAL_PROTECT (1e-14)
 
-
 typedef struct {
        float* delays[2][RV_NZ]; /**< delay line buffer */
 
@@ -249,6 +252,7 @@ typedef struct {
 
        float v_mix;
        float v_roomsz;
+       float srate;
 
        b_reverb r;
 } AReverb;
@@ -270,6 +274,7 @@ instantiate (const LV2_Descriptor*     descriptor,
        // these are set in initReverb()
        self->v_roomsz = 0.75;
        self->v_mix = 0.1;
+       self->srate = rate;
 
        return (LV2_Handle)self;
 }
@@ -313,15 +318,16 @@ run (LV2_Handle instance, uint32_t n_samples)
        float* const      output0 = self->output0;
        float* const      output1 = self->output1;
 
-       // TODO interpolate
+       // 25Hz update
+       const float tau = (1.0 - exp(-2.0 * M_PI * n_samples * 25 / self->srate));
+
        if (*self->mix != self->v_mix) {
-               self->v_mix = *self->mix;
-               const float u = self->r.wet + self->r.dry;
-               self->r.wet = self->v_mix * u;
-               self->r.dry = u - (self->v_mix * u);
+               self->v_mix += tau * ( *self->mix - self->v_mix);
+               self->r.wet = self->v_mix;
+               self->r.dry = 1.0 - self->v_mix;
        }
        if (*self->roomsz != self->v_roomsz) {
-               self->v_roomsz = *self->roomsz;
+               self->v_roomsz += tau * ( *self->roomsz - self->v_roomsz);
                self->r.gain[0] = 0.773 * self->v_roomsz;
                self->r.gain[1] = 0.802 * self->v_roomsz;
                self->r.gain[2] = 0.753 * self->v_roomsz;
index c8f7252cd0a37060396f64ae9270201d3ed88026..476c463c5578192a2e475c23ad425e41088834af 100644 (file)
@@ -20,7 +20,7 @@
        doap:maintainer <http://ardour.org/credits.html>
        doap:license <http://usefulinc.com/doap/licenses/gpl> ;
 
-       lv2:microVersion 0 ; lv2:minorVersion 1 ;
+       lv2:microVersion 0 ; lv2:minorVersion 2 ;
        lv2:optionalFeature lv2:hardRTCapable ;
 
        lv2:port
@@ -56,8 +56,8 @@
                a lv2:InputPort ,
                        lv2:ControlPort ;
                lv2:index 4 ;
-               lv2:symbol "mix" ;
-               lv2:name "Dry/Wet";
+               lv2:symbol "blend" ;
+               lv2:name "Blend";
                lv2:default 0.3;
                lv2:minimum 0.0 ;
                lv2:maximum 1.0 ;