[xiph-commits] r7683 - trunk/postfish

xiphmont at motherfish-iii.xiph.org xiphmont at motherfish-iii.xiph.org
Thu Sep 2 05:30:24 PDT 2004


Author: xiphmont
Date: 2004-09-02 05:30:23 -0700 (Thu, 02 Sep 2004)
New Revision: 7683

Modified:
   trunk/postfish/bessel.c
   trunk/postfish/bessel.h
   trunk/postfish/suppress.c
Log:
Minor improvements to deverber; not quite finished
 


Modified: trunk/postfish/bessel.c
===================================================================
--- trunk/postfish/bessel.c	2004-09-02 04:55:51 UTC (rev 7682)
+++ trunk/postfish/bessel.c	2004-09-02 12:30:23 UTC (rev 7683)
@@ -209,7 +209,7 @@
       while(i<n){
 	double ya= (x[i]+x0*2.+x1)/a_g + y0*a_c0+y1*a_c1;
     
-	if(ya<y0){
+	if(x[i]<y0 && ya<y0){
 	  state=1; 
 	  break;
 	}
@@ -248,6 +248,70 @@
   
 }
 
+/* this one is designed for fast decay, slow attack */
+void compute_iir_fast_decay2(float *x, int n, iir_state *is, 
+			     iir_filter *attack, iir_filter *decay){
+  double a_c0=attack->c[0],d_c0=decay->c[0];
+  double a_c1=attack->c[1],d_c1=decay->c[1];
+  double a_g=attack->g, d_g=decay->g;
+  
+  double x0=is->x[0],x1=is->x[1];
+  double y0=is->y[0],y1=is->y[1];
+  int state=is->state;
+  int i=0;
+
+  if(zerome(y0) && zerome(y1)){
+    y0=y1=0.;
+  }
+
+  if(x[0]<y0)state=1; 
+      
+  while(i<n){
+    
+    if(state==1){
+      /* decay case */
+      while(i<n){
+	double yd= (x[i]+x0*2.+x1)/d_g + y0*d_c0+y1*d_c1;
+    
+	if(x[i]>y0 && yd>y0){
+	  state=0; 
+	  break;
+	}
+	x1=x0;x0=x[i];
+	y1=y0;x[i]=y0=yd;
+	i++;
+      }
+    }
+
+    if(state==0){
+      /* attack case */
+      if(y1>y0){
+	/* attack fixup needed because we're in discontinuous time */
+	  y1=y0;
+      }
+
+      while(1){
+	double ya = (x[i]+x0*2.+x1)/a_g + y0*a_c0+y1*a_c1;
+
+	x1=x0;x0=x[i];
+	y1=y0;x[i]=y0=ya;
+	i++;
+
+	if(i>=n)break;
+	if(x[i]<y0){
+	  state=1;
+	  break;
+	}
+      }
+    }
+  }
+  
+  is->x[0]=x0;is->x[1]=x1;
+  is->y[0]=y0;is->y[1]=y1;
+  is->state=state;
+  
+}
+
 /* allow decay to proceed in freefall */
 void compute_iir_freefall1(float *x, int n, iir_state *is, 
 			   iir_filter *decay){
@@ -264,12 +328,17 @@
   while(i<n){
     double yd;
 
-     yd = y0*d_c0;
+    yd = y0*d_c0;
+    x0=x[i];
+    
+    /* if we're not in freefall, be sure x[i]_out == x[i]_in  */
+    if(x[i]>yd){
+      yd=x[i];
+    }else{
+      x[i]=yd;
+    }
 
-    if(x[i]>yd)yd=x[i];
-
-    x0=x[i];
-    x[i]=y0=yd;
+    y0=yd;
     i++;
   }
   

Modified: trunk/postfish/bessel.h
===================================================================
--- trunk/postfish/bessel.h	2004-09-02 04:55:51 UTC (rev 7682)
+++ trunk/postfish/bessel.h	2004-09-02 12:30:23 UTC (rev 7683)
@@ -73,6 +73,8 @@
 extern double mkbessel(double raw_alpha,int order,double *ycoeff);
 extern void compute_iir_fast_attack2(float *x, int n, iir_state *is, 
 				     iir_filter *attack, iir_filter *decay);
+extern void compute_iir_fast_decay2(float *x, int n, iir_state *is, 
+				     iir_filter *attack, iir_filter *decay);
 extern void compute_iir_symmetric2(float *x, int n, iir_state *is, 
 				  iir_filter *filter);
 extern void compute_iir_symmetric3(float *x, int n, iir_state *is, 

Modified: trunk/postfish/suppress.c
===================================================================
--- trunk/postfish/suppress.c	2004-09-02 04:55:51 UTC (rev 7682)
+++ trunk/postfish/suppress.c	2004-09-02 12:30:23 UTC (rev 7683)
@@ -88,9 +88,9 @@
   
   /* make sure the chosen frequency doesn't require a lookahead
      greater than what's available */
-  if(impulse_freq4(input_size*2-ss->qblocksize*3)*1.01>corner_freq && 
+  if(impulse_freq2(input_size*2-ss->qblocksize*3)*1.01>corner_freq && 
      attackp)
-    corner_freq=impulse_freq4(input_size*2-ss->qblocksize*3);
+    corner_freq=impulse_freq2(input_size*2-ss->qblocksize*3);
   
   alpha=corner_freq/input_rate;
   filter->g=mkbessel(alpha,order,filter->c);
@@ -129,11 +129,11 @@
   iir_filter *release=&sss->release;
   int ahead;
 
-  if(smoothms!=smooth->ms)filter_set(ss,smoothms,smooth,1,4);
-  if(triggerms!=trigger->ms)filter_set(ss,triggerms,trigger,0,1);
-  if(releasems!=release->ms)filter_set(ss,releasems,release,0,1);
+  if(smoothms!=smooth->ms)filter_set(ss,smoothms,smooth,1,2);
+  if(triggerms!=trigger->ms)filter_set(ss,triggerms,trigger,0,2);
+  if(releasems!=release->ms)filter_set(ss,releasems,release,0,2);
 
-  ahead=impulse_ahead4(smooth->alpha);
+  ahead=impulse_ahead2(smooth->alpha);
   
   for(i=0;i<suppress_freqs;i++){
     int firstlink=0;
@@ -171,17 +171,14 @@
 	
 	if(sset->linkp==0 || firstlink==1){
 	  
-	  compute_iir_symmetric4(fast, input_size, &sss->iirS[i][j],
-				 smooth);
-	  
-	  //_analysis("smooth",i,fast,input_size,1,offset);
-	  
-	  compute_iir_freefall1(fast, input_size, &sss->iirT[i][j],
-				trigger);
 	  memcpy(slow,fast,sizeof(slow));
-	  compute_iir_freefall1(slow, input_size, &sss->iirR[i][j],
-				release);
+
 	  
+	  compute_iir_fast_attack2(fast, input_size, &sss->iirT[i][j],
+				smooth,trigger);
+	  compute_iir_fast_attack2(slow, input_size, &sss->iirR[i][j],
+				smooth,release);
+	  
 	  //_analysis("fast",i,fast,input_size,1,offset);
 	  //_analysis("slow",i,slow,input_size,1,offset);
 



More information about the commits mailing list