[xiph-cvs] r6578 - trunk/postfish

xiphmont at xiph.org xiphmont at xiph.org
Tue May 4 21:25:48 PDT 2004



Author: xiphmont
Date: 2004-04-22 18:27:52 -0400 (Thu, 22 Apr 2004)
New Revision: 6578

Modified:
   trunk/postfish/compandpanel.c
   trunk/postfish/multicompand.c
   trunk/postfish/multicompand.h
   trunk/postfish/output.c
   trunk/postfish/version.h
Log:
First step of generalizing multicompand setup to allow multiple panels
and per-channel config

<p><p>Modified: trunk/postfish/compandpanel.c
===================================================================
--- trunk/postfish/compandpanel.c	2004-04-22 11:52:24 UTC (rev 6577)
+++ trunk/postfish/compandpanel.c	2004-04-22 22:27:52 UTC (rev 6578)
@@ -32,14 +32,11 @@
 #include "multicompand.h"
 #include "compandpanel.h"
 
-extern sig_atomic_t compand_active;
-extern sig_atomic_t compand_visible;
 extern int input_ch;
 extern int input_size;
 extern int input_rate;
 
-extern banked_compand_settings bc[multicomp_banks];
-extern other_compand_settings c;
+extern multicompand_settings multi_master_set;
 
 typedef struct {
   GtkWidget *label;
@@ -80,15 +77,15 @@
   *var=rint(val*1000.);
 }
 static void under_compand_change(GtkWidget *w,gpointer in){
-  compand_change(w,(Readout *)in,&c.under_ratio);
+  compand_change(w,(Readout *)in,&multi_master_set.under_ratio);
 }
 
 static void over_compand_change(GtkWidget *w,gpointer in){
-  compand_change(w,(Readout *)in,&c.over_ratio);
+  compand_change(w,(Readout *)in,&multi_master_set.over_ratio);
 }
 
 static void base_compand_change(GtkWidget *w,gpointer in){
-  compand_change(w,(Readout *)in,&c.base_ratio);
+  compand_change(w,(Readout *)in,&multi_master_set.base_ratio);
 }
 
 static void timing_display(GtkWidget *w,Readout *r,float v){
@@ -117,8 +114,8 @@
   timing_display(w,r->r0,attack);
   timing_display(w,r->r1,decay);
  
-  multicompand_under_attack_set(attack);
-  multicompand_under_decay_set(decay);  
+  multi_master_set.under_attack=rint(attack*10.);
+  multi_master_set.under_decay=rint(decay*10.);
 }
 
 static void over_timing_change(GtkWidget *w,gpointer in){
@@ -129,9 +126,8 @@
   timing_display(w,r->r0,attack);
   timing_display(w,r->r1,decay);
   
-  multicompand_over_attack_set(attack);
-  multicompand_over_decay_set(decay);
-  
+  multi_master_set.over_attack=rint(attack*10.);
+  multi_master_set.over_decay=rint(decay*10.);
 }
 
 static void base_timing_change(GtkWidget *w,gpointer in){
@@ -142,9 +138,8 @@
   timing_display(w,r->r0,attack);
   timing_display(w,r->r1,decay);
   
-  multicompand_base_attack_set(attack);
-  multicompand_base_decay_set(decay);
-  
+  multi_master_set.base_attack=rint(attack*10.);
+  multi_master_set.base_decay=rint(decay*10.);
 }
 
 static void under_lookahead_change(GtkWidget *w,gpointer in){
@@ -155,7 +150,7 @@
   sprintf(buffer,"%3.0f%%",val);
   readout_set(r,buffer);
   
-  c.under_lookahead=rint(val*10.);
+  multi_master_set.under_lookahead=rint(val*10.);
 }
 
 static void over_lookahead_change(GtkWidget *w,gpointer in){
@@ -166,7 +161,7 @@
   sprintf(buffer,"%3.0f%%",val);
   readout_set(r,buffer);
   
-  c.over_lookahead=rint(val*10.);
+  multi_master_set.over_lookahead=rint(val*10.);
 }
 
 static int updating_av_slider=0;
@@ -181,8 +176,8 @@
 
   /* compute the current average */
   for(i=0;i<multicomp_freqs[bank_active];i++){
-    oav+=rint(bc[bank_active].static_o[i]);
-    uav+=rint(bc[bank_active].static_u[i]);
+    oav+=rint(multi_master_set.bc[bank_active].static_o[i]);
+    uav+=rint(multi_master_set.bc[bank_active].static_u[i]);
   }
   oav=rint(oav/multicomp_freqs[bank_active]);
   uav=rint(uav/multicomp_freqs[bank_active]);
@@ -201,7 +196,7 @@
       /* update u average (might have pushed it) */
       uav=0;
       for(i=0;i<multicomp_freqs[bank_active];i++)
-	uav+=rint(bc[bank_active].static_u[i]);
+	uav+=rint(multi_master_set.bc[bank_active].static_u[i]);
       uav=rint(uav/multicomp_freqs[bank_active]);
       multibar_thumb_set(MULTIBAR(bars[multicomp_freqs_max].slider),uav,0);
     }else{
@@ -213,7 +208,7 @@
       /* update o average (might have pushed it) */
       oav=0;
       for(i=0;i<multicomp_freqs[bank_active];i++)
-	oav+=rint(bc[bank_active].static_o[i]);
+	oav+=rint(multi_master_set.bc[bank_active].static_o[i]);
       oav=rint(oav/multicomp_freqs[bank_active]);
       multibar_thumb_set(MULTIBAR(bars[multicomp_freqs_max].slider),oav,1);
     }
@@ -231,12 +226,12 @@
   u=multibar_get_value(MULTIBAR(b->slider),0);
   sprintf(buffer,"%+4ddB",u);
   readout_set(READOUT(b->readoutu),buffer);
-  bc[bank_active].static_u[b->number]=u;
+  multi_master_set.bc[bank_active].static_u[b->number]=u;
   
   o=multibar_get_value(MULTIBAR(b->slider),1);
   sprintf(buffer,"%+4ddB",o);
   readout_set(READOUT(b->readouto),buffer);
-  bc[bank_active].static_o[b->number]=o;
+  multi_master_set.bc[bank_active].static_o[b->number]=o;
 
   if(inactive_updatep){
     /* keep the inactive banks also tracking settings */
@@ -244,160 +239,160 @@
     switch(bank_active){
     case 0:
       if(b->number==0){
-	bc[2].static_o[0]+=o-bc[2].static_o[1];
-	bc[2].static_u[0]+=u-bc[2].static_u[1];
+	multi_master_set.bc[2].static_o[0]+=o-multi_master_set.bc[2].static_o[1];
+	multi_master_set.bc[2].static_u[0]+=u-multi_master_set.bc[2].static_u[1];
       }
       
       /* convolutions for roundoff behavior */
       if(b->number>0){
-	adj=(bc[1].static_o[b->number*2-1]*2 -
-	     bc[1].static_o[b->number*2-2]-bc[1].static_o[b->number*2])/2;
-	bc[1].static_o[b->number*2-1]=
-	    (bc[1].static_o[b->number*2-2]+o)/2+adj;
+	adj=(multi_master_set.bc[1].static_o[b->number*2-1]*2 -
+	     multi_master_set.bc[1].static_o[b->number*2-2]-multi_master_set.bc[1].static_o[b->number*2])/2;
+	multi_master_set.bc[1].static_o[b->number*2-1]=
+	    (multi_master_set.bc[1].static_o[b->number*2-2]+o)/2+adj;
         
-	adj=(bc[1].static_u[b->number*2-1]*2 -
-	     bc[1].static_u[b->number*2-2]-bc[1].static_u[b->number*2])/2;
-	bc[1].static_u[b->number*2-1]=
-	  (bc[1].static_u[b->number*2-2]+u)/2+adj;
+	adj=(multi_master_set.bc[1].static_u[b->number*2-1]*2 -
+	     multi_master_set.bc[1].static_u[b->number*2-2]-multi_master_set.bc[1].static_u[b->number*2])/2;
+	multi_master_set.bc[1].static_u[b->number*2-1]=
+	  (multi_master_set.bc[1].static_u[b->number*2-2]+u)/2+adj;
         
-	adj=(bc[2].static_o[b->number*3-1]*3 -
-	     bc[2].static_o[b->number*3-2] - 
-	     bc[2].static_o[b->number*3-2] - 
-	     bc[2].static_o[b->number*3+1])/3;
-	bc[2].static_o[b->number*3-1]=
-	  (bc[2].static_o[b->number*3-2]+
-	   bc[2].static_o[b->number*3-2]+
+	adj=(multi_master_set.bc[2].static_o[b->number*3-1]*3 -
+	     multi_master_set.bc[2].static_o[b->number*3-2] - 
+	     multi_master_set.bc[2].static_o[b->number*3-2] - 
+	     multi_master_set.bc[2].static_o[b->number*3+1])/3;
+	multi_master_set.bc[2].static_o[b->number*3-1]=
+	  (multi_master_set.bc[2].static_o[b->number*3-2]+
+	   multi_master_set.bc[2].static_o[b->number*3-2]+
            o)/3+adj;
         
-	adj=(bc[2].static_o[b->number*3]*3 -
-	     bc[2].static_o[b->number*3-2] - 
-	     bc[2].static_o[b->number*3+1] - 
-	     bc[2].static_o[b->number*3+1])/3;
-	bc[2].static_o[b->number*3]=
-	  (bc[2].static_o[b->number*3-2]+o+o)/3+adj;
+	adj=(multi_master_set.bc[2].static_o[b->number*3]*3 -
+	     multi_master_set.bc[2].static_o[b->number*3-2] - 
+	     multi_master_set.bc[2].static_o[b->number*3+1] - 
+	     multi_master_set.bc[2].static_o[b->number*3+1])/3;
+	multi_master_set.bc[2].static_o[b->number*3]=
+	  (multi_master_set.bc[2].static_o[b->number*3-2]+o+o)/3+adj;
         
-	adj=(bc[2].static_u[b->number*3-1]*3 -
-	     bc[2].static_u[b->number*3-2] - 
-	     bc[2].static_u[b->number*3-2] - 
-	     bc[2].static_u[b->number*3+1])/3;
-	bc[2].static_u[b->number*3-1]=
-	  (bc[2].static_u[b->number*3-2]+
-	   bc[2].static_u[b->number*3-2]+
+	adj=(multi_master_set.bc[2].static_u[b->number*3-1]*3 -
+	     multi_master_set.bc[2].static_u[b->number*3-2] - 
+	     multi_master_set.bc[2].static_u[b->number*3-2] - 
+	     multi_master_set.bc[2].static_u[b->number*3+1])/3;
+	multi_master_set.bc[2].static_u[b->number*3-1]=
+	  (multi_master_set.bc[2].static_u[b->number*3-2]+
+	   multi_master_set.bc[2].static_u[b->number*3-2]+
            u)/3+adj;
         
-	adj=(bc[2].static_u[b->number*3]*3 -
-	     bc[2].static_u[b->number*3-2] - 
-	     bc[2].static_u[b->number*3+1] - 
-	     bc[2].static_u[b->number*3+1])/3;
-	bc[2].static_u[b->number*3]=
-	  (bc[2].static_u[b->number*3-2]+u+u)/3+adj;
+	adj=(multi_master_set.bc[2].static_u[b->number*3]*3 -
+	     multi_master_set.bc[2].static_u[b->number*3-2] - 
+	     multi_master_set.bc[2].static_u[b->number*3+1] - 
+	     multi_master_set.bc[2].static_u[b->number*3+1])/3;
+	multi_master_set.bc[2].static_u[b->number*3]=
+	  (multi_master_set.bc[2].static_u[b->number*3-2]+u+u)/3+adj;
         
       }
       
       if(b->number<9){
-	adj=(bc[1].static_o[b->number*2+1]*2-
-	     bc[1].static_o[b->number*2+2]-bc[1].static_o[b->number*2])/2;
-	bc[1].static_o[b->number*2+1]=
-	  (bc[1].static_o[b->number*2+2]+o)/2+adj;
+	adj=(multi_master_set.bc[1].static_o[b->number*2+1]*2-
+	     multi_master_set.bc[1].static_o[b->number*2+2]-multi_master_set.bc[1].static_o[b->number*2])/2;
+	multi_master_set.bc[1].static_o[b->number*2+1]=
+	  (multi_master_set.bc[1].static_o[b->number*2+2]+o)/2+adj;
         
-	adj=(bc[1].static_u[b->number*2+1]*2-
-	     bc[1].static_u[b->number*2+2]-bc[1].static_u[b->number*2])/2;
-	bc[1].static_u[b->number*2+1]=
-	  (bc[1].static_u[b->number*2+2]+u)/2+adj;
+	adj=(multi_master_set.bc[1].static_u[b->number*2+1]*2-
+	     multi_master_set.bc[1].static_u[b->number*2+2]-multi_master_set.bc[1].static_u[b->number*2])/2;
+	multi_master_set.bc[1].static_u[b->number*2+1]=
+	  (multi_master_set.bc[1].static_u[b->number*2+2]+u)/2+adj;
         
-	adj=(bc[2].static_o[b->number*3+3]*3 -
-	     bc[2].static_o[b->number*3+4] - 
-	     bc[2].static_o[b->number*3+4] - 
-	     bc[2].static_o[b->number*3+1])/3;
-	bc[2].static_o[b->number*3+3]=
-	  (bc[2].static_o[b->number*3+4]+
-	   bc[2].static_o[b->number*3+4]+
+	adj=(multi_master_set.bc[2].static_o[b->number*3+3]*3 -
+	     multi_master_set.bc[2].static_o[b->number*3+4] - 
+	     multi_master_set.bc[2].static_o[b->number*3+4] - 
+	     multi_master_set.bc[2].static_o[b->number*3+1])/3;
+	multi_master_set.bc[2].static_o[b->number*3+3]=
+	  (multi_master_set.bc[2].static_o[b->number*3+4]+
+	   multi_master_set.bc[2].static_o[b->number*3+4]+
            o)/3+adj;
         
-	adj=(bc[2].static_o[b->number*3+2]*3 -
-	     bc[2].static_o[b->number*3+4] - 
-	     bc[2].static_o[b->number*3+1] - 
-	     bc[2].static_o[b->number*3+1])/3;
-	bc[2].static_o[b->number*3+2]=
-	  (bc[2].static_o[b->number*3+4]+o+o)/3+adj;
+	adj=(multi_master_set.bc[2].static_o[b->number*3+2]*3 -
+	     multi_master_set.bc[2].static_o[b->number*3+4] - 
+	     multi_master_set.bc[2].static_o[b->number*3+1] - 
+	     multi_master_set.bc[2].static_o[b->number*3+1])/3;
+	multi_master_set.bc[2].static_o[b->number*3+2]=
+	  (multi_master_set.bc[2].static_o[b->number*3+4]+o+o)/3+adj;
         
-	adj=(bc[2].static_u[b->number*3+3]*3 -
-	     bc[2].static_u[b->number*3+4] - 
-	     bc[2].static_u[b->number*3+4] - 
-	     bc[2].static_u[b->number*3+1])/3;
-	bc[2].static_u[b->number*3+3]=
-	  (bc[2].static_u[b->number*3+4]+
-	   bc[2].static_u[b->number*3+4]+
+	adj=(multi_master_set.bc[2].static_u[b->number*3+3]*3 -
+	     multi_master_set.bc[2].static_u[b->number*3+4] - 
+	     multi_master_set.bc[2].static_u[b->number*3+4] - 
+	     multi_master_set.bc[2].static_u[b->number*3+1])/3;
+	multi_master_set.bc[2].static_u[b->number*3+3]=
+	  (multi_master_set.bc[2].static_u[b->number*3+4]+
+	   multi_master_set.bc[2].static_u[b->number*3+4]+
            u)/3+adj;
         
-	adj=(bc[2].static_u[b->number*3+2]*3 -
-	     bc[2].static_u[b->number*3+4] - 
-	     bc[2].static_u[b->number*3+1] - 
-	     bc[2].static_u[b->number*3+1])/3;
-	bc[2].static_u[b->number*3+2]=
-	  (bc[2].static_u[b->number*3+4]+u+u)/3+adj;
+	adj=(multi_master_set.bc[2].static_u[b->number*3+2]*3 -
+	     multi_master_set.bc[2].static_u[b->number*3+4] - 
+	     multi_master_set.bc[2].static_u[b->number*3+1] - 
+	     multi_master_set.bc[2].static_u[b->number*3+1])/3;
+	multi_master_set.bc[2].static_u[b->number*3+2]=
+	  (multi_master_set.bc[2].static_u[b->number*3+4]+u+u)/3+adj;
         
       }
       
       if(b->number==9){
-	bc[1].static_o[19]+=o-bc[1].static_o[18];
-	bc[1].static_u[19]+=u-bc[1].static_u[18];
-	bc[2].static_o[29]+=o-bc[2].static_o[28];
-	bc[2].static_u[29]+=u-bc[2].static_u[28];
+	multi_master_set.bc[1].static_o[19]+=o-multi_master_set.bc[1].static_o[18];
+	multi_master_set.bc[1].static_u[19]+=u-multi_master_set.bc[1].static_u[18];
+	multi_master_set.bc[2].static_o[29]+=o-multi_master_set.bc[2].static_o[28];
+	multi_master_set.bc[2].static_u[29]+=u-multi_master_set.bc[2].static_u[28];
       }
 
-      bc[1].static_o[b->number*2]=o;
-      bc[1].static_u[b->number*2]=u;
-      bc[2].static_o[b->number*3+1]=o;
-      bc[2].static_u[b->number*3+1]=u;
+      multi_master_set.bc[1].static_o[b->number*2]=o;
+      multi_master_set.bc[1].static_u[b->number*2]=u;
+      multi_master_set.bc[2].static_o[b->number*3+1]=o;
+      multi_master_set.bc[2].static_u[b->number*3+1]=u;
 
       break;
     case 1:
       if((b->number&1)==0){
-	bc[0].static_o[b->number>>1]=o;
-	bc[0].static_u[b->number>>1]=u;
-	bc[2].static_o[b->number/2*3+1]=o;
-	bc[2].static_u[b->number/2*3+1]=u;
+	multi_master_set.bc[0].static_o[b->number>>1]=o;
+	multi_master_set.bc[0].static_u[b->number>>1]=u;
+	multi_master_set.bc[2].static_o[b->number/2*3+1]=o;
+	multi_master_set.bc[2].static_u[b->number/2*3+1]=u;
       }else{
         if(b->number<19){
-	  int val=(bc[2].static_o[b->number/2*3+2]+
-		     bc[2].static_o[b->number/2*3+3])/2;
-	  bc[2].static_o[b->number/2*3+2]+=(o-val);
-	  bc[2].static_o[b->number/2*3+3]+=(o-val);
+	  int val=(multi_master_set.bc[2].static_o[b->number/2*3+2]+
+		     multi_master_set.bc[2].static_o[b->number/2*3+3])/2;
+	  multi_master_set.bc[2].static_o[b->number/2*3+2]+=(o-val);
+	  multi_master_set.bc[2].static_o[b->number/2*3+3]+=(o-val);
           
-	  val=(bc[2].static_u[b->number/2*3+2]+
-	       bc[2].static_u[b->number/2*3+3])/2;
-	  bc[2].static_u[b->number/2*3+2]+=(u-val);
-	  bc[2].static_u[b->number/2*3+3]+=(u-val);
+	  val=(multi_master_set.bc[2].static_u[b->number/2*3+2]+
+	       multi_master_set.bc[2].static_u[b->number/2*3+3])/2;
+	  multi_master_set.bc[2].static_u[b->number/2*3+2]+=(u-val);
+	  multi_master_set.bc[2].static_u[b->number/2*3+3]+=(u-val);
           
         }else{
-	  bc[2].static_o[b->number/2*3+2]=o;
-	  bc[2].static_u[b->number/2*3+2]=u;
+	  multi_master_set.bc[2].static_o[b->number/2*3+2]=o;
+	  multi_master_set.bc[2].static_u[b->number/2*3+2]=u;
         }
       }
       if(b->number==0){
-	bc[2].static_o[0]+=o-bc[2].static_o[1];
-	bc[2].static_u[0]+=u-bc[2].static_u[1];
+	multi_master_set.bc[2].static_o[0]+=o-multi_master_set.bc[2].static_o[1];
+	multi_master_set.bc[2].static_u[0]+=u-multi_master_set.bc[2].static_u[1];
       }
 
       break;
     case 2:
       if((b->number%3)==1){
-	bc[0].static_o[b->number/3]=o;
-	bc[0].static_u[b->number/3]=u;
-	bc[1].static_o[b->number/3*2]=o;
-	bc[1].static_u[b->number/3*2]=u;
+	multi_master_set.bc[0].static_o[b->number/3]=o;
+	multi_master_set.bc[0].static_u[b->number/3]=u;
+	multi_master_set.bc[1].static_o[b->number/3*2]=o;
+	multi_master_set.bc[1].static_u[b->number/3*2]=u;
       }else if(b->number>1){
         if(b->number<29){
-	  bc[1].static_o[(b->number-1)/3*2+1]=
-	    (bc[2].static_o[(b->number-1)/3*3+2]+
-	     bc[2].static_o[(b->number-1)/3*3+3])/2;
-	  bc[1].static_u[(b->number-1)/3*2+1]=
-	    (bc[2].static_u[(b->number-1)/3*3+2]+
-	     bc[2].static_u[(b->number-1)/3*3+3])/2;
+	  multi_master_set.bc[1].static_o[(b->number-1)/3*2+1]=
+	    (multi_master_set.bc[2].static_o[(b->number-1)/3*3+2]+
+	     multi_master_set.bc[2].static_o[(b->number-1)/3*3+3])/2;
+	  multi_master_set.bc[1].static_u[(b->number-1)/3*2+1]=
+	    (multi_master_set.bc[2].static_u[(b->number-1)/3*3+2]+
+	     multi_master_set.bc[2].static_u[(b->number-1)/3*3+3])/2;
         }else{
-	  bc[1].static_o[(b->number-1)/3*2+1]=o;
-	  bc[1].static_u[(b->number-1)/3*2+1]=u;
+	  multi_master_set.bc[1].static_o[(b->number-1)/3*2+1]=o;
+	  multi_master_set.bc[1].static_u[(b->number-1)/3*2+1]=u;
         }
       }
       break;
@@ -411,8 +406,8 @@
     
     /* compute the current average */
     for(i=0;i<multicomp_freqs[bank_active];i++){
-      oav+=rint(bc[bank_active].static_o[i]);
-      uav+=rint(bc[bank_active].static_u[i]);
+      oav+=rint(multi_master_set.bc[bank_active].static_o[i]);
+      uav+=rint(multi_master_set.bc[bank_active].static_u[i]);
     }
     oav=rint(oav/multicomp_freqs[bank_active]);
     uav=rint(uav/multicomp_freqs[bank_active]);
@@ -443,8 +438,8 @@
           inactive_updatep=0;
           
           {
-	    float o=bc[bank_active].static_o[i];
-	    float u=bc[bank_active].static_u[i];
+	    float o=multi_master_set.bc[bank_active].static_o[i];
+	    float u=multi_master_set.bc[bank_active].static_u[i];
 
             multibar_thumb_set(MULTIBAR(bars[i].slider),u,0);
             multibar_thumb_set(MULTIBAR(bars[i].slider),o,1);
@@ -460,7 +455,7 @@
         }
       }
 
-      c.active_bank=bank_active;
+      multi_master_set.active_bank=bank_active;
       
     }
   }
@@ -468,27 +463,27 @@
 
 static void over_mode(GtkButton *b,gpointer in){
   int mode=(int)in;
-  c.over_mode=mode;
+  multi_master_set.over_mode=mode;
 }
 
 static void under_mode(GtkButton *b,gpointer in){
   int mode=(int)in;
-  c.under_mode=mode;
+  multi_master_set.under_mode=mode;
 }
 
 static void base_mode(GtkButton *b,gpointer in){
   int mode=(int)in;
-  c.base_mode=mode;
+  multi_master_set.base_mode=mode;
 }
 
 static void under_knee(GtkToggleButton *b,gpointer in){
   int mode=gtk_toggle_button_get_active(b);
-  c.under_softknee=mode;
+  multi_master_set.under_softknee=mode;
 }
 
 static void over_knee(GtkToggleButton *b,gpointer in){
   int mode=gtk_toggle_button_get_active(b);
-  c.over_softknee=mode;
+  multi_master_set.over_softknee=mode;
 }
 
 void compandpanel_create(postfish_mainpanel *mp,
@@ -512,8 +507,8 @@
   char *shortcut[]={" m "};
 
   subpanel_generic *panel=subpanel_create(mp,windowbutton,&activebutton,
-					  &compand_active,
-					  &compand_visible,
+					  &multi_master_set.panel_active,
+					  &multi_master_set.panel_visible,
                                           "_Multiband Compand",shortcut,
                                           0,1);
   
@@ -925,10 +920,10 @@
     }
   }
 
-  if(pull_multicompand_feedback(peakfeed,rmsfeed,&bands)==1)
+  if(pull_multicompand_feedback_master(peakfeed,rmsfeed,&bands)==1)
     for(i=0;i<bands;i++)
       multibar_set(MULTIBAR(bars[i].slider),rmsfeed[i],peakfeed[i],
-		   input_ch,(displayit && compand_visible));
+		   input_ch,(displayit && multi_master_set.panel_visible));
 }
 
 void compandpanel_reset(void){

Modified: trunk/postfish/multicompand.c
===================================================================
--- trunk/postfish/multicompand.c	2004-04-22 11:52:24 UTC (rev 6577)
+++ trunk/postfish/multicompand.c	2004-04-22 22:27:52 UTC (rev 6578)
@@ -51,14 +51,14 @@
   subband_state ss;
   subband_window sw[multicomp_banks];
   
-  iir_filter over_attack;
-  iir_filter over_decay;
+  iir_filter *over_attack;
+  iir_filter *over_decay;
 
-  iir_filter under_attack;
-  iir_filter under_decay;
+  iir_filter *under_attack;
+  iir_filter *under_decay;
 
-  iir_filter base_attack;
-  iir_filter base_decay;
+  iir_filter *base_attack;
+  iir_filter *base_decay;
 
   iir_state *over_iir[multicomp_freqs_max];
   iir_state *under_iir[multicomp_freqs_max];
@@ -70,14 +70,10 @@
   
   float **peak;
   float **rms;
+
 } multicompand_state;
 
-sig_atomic_t compand_visible;
-sig_atomic_t compand_active;
-
-banked_compand_settings bc[multicomp_banks];
-other_compand_settings c;
-
+multicompand_settings multi_master_set;
 static multicompand_state ms;
 
 static feedback_generic *new_multicompand_feedback(void){
@@ -97,7 +93,7 @@
 
 /* total, peak, rms are pulled in array[freqs][input_ch] order */
 
-int pull_multicompand_feedback(float **peak,float **rms,int *b){
+int pull_multicompand_feedback_master(float **peak,float **rms,int *b){
   multicompand_feedback *f=(multicompand_feedback *)feedback_pull(&ms.feedpool);
   int i;
   
@@ -135,7 +131,7 @@
 void multicompand_reset(){
   
   subband_reset(&ms.ss);
-  while(pull_multicompand_feedback(NULL,NULL,NULL));
+  while(pull_multicompand_feedback_master(NULL,NULL,NULL));
   reset_filters(&ms);
 
 }
@@ -151,6 +147,15 @@
     subband_load_freqs(&ms.ss,&ms.sw[h],multicomp_freq_list[h],
                        multicomp_freqs[h]);
     
+  ms.over_attack=calloc(input_ch,sizeof(*ms.over_attack));
+  ms.over_decay=calloc(input_ch,sizeof(*ms.over_decay));
+
+  ms.under_attack=calloc(input_ch,sizeof(*ms.under_attack));
+  ms.under_decay=calloc(input_ch,sizeof(*ms.under_decay));
+
+  ms.base_attack=calloc(input_ch,sizeof(*ms.base_attack));
+  ms.base_decay=calloc(input_ch,sizeof(*ms.base_decay));
+
   for(i=0;i<multicomp_freqs_max;i++){
     ms.over_peak[i]=calloc(input_ch,sizeof(peak_state));
     ms.under_peak[i]=calloc(input_ch,sizeof(peak_state));
@@ -168,9 +173,9 @@
   return 0;
 }
 
-static int multicompand_filter_set(float msec,
-				    iir_filter *filter,
-				    int attackp){
+static void filter_set(float msec,
+		      iir_filter *filter,
+		      int attackp){
   float alpha;
   float corner_freq= 500./msec;
 
@@ -184,33 +189,17 @@
   filter->alpha=alpha;
   filter->Hz=alpha*input_rate;
 
-  return 0;
 }
 
-int multicompand_over_attack_set(float msec){
-  return multicompand_filter_set(msec,&ms.over_attack,1);
-}
+static void filterbank_set(float msec,
+			  iir_filter *filter,
+			  int attackp){
+  int i;
+  for(i=0;i<input_ch;i++)
+    filter_set(msec,filter+i,attackp);
 
-int multicompand_over_decay_set(float msec){
-  return multicompand_filter_set(msec,&ms.over_decay,0);  
 }
 
-int multicompand_under_attack_set(float msec){
-  return multicompand_filter_set(msec,&ms.under_attack,1);
-}
-
-int multicompand_under_decay_set(float msec){
-  return multicompand_filter_set(msec,&ms.under_decay,0);
-}
-
-int multicompand_base_attack_set(float msec){
-  return multicompand_filter_set(msec,&ms.base_attack,1);
-}
-
-int multicompand_base_decay_set(float msec){
-  return multicompand_filter_set(msec,&ms.base_decay,0);
-}
-
 static void prepare_rms(float *rms, float *xx, int n, int ahead){
   int i;
   float *x=xx+ahead;
@@ -293,17 +282,17 @@
 static void over_compand(float *lx,float zerocorner,
                          iir_filter *attack, iir_filter *decay,
                          iir_state *iir, peak_state *ps,
+			 float lookahead,int mode,int knee,
+			 int ratio,
                          float *adj){
   int k;
   float overdB[input_size];
-  float lookahead=c.over_lookahead/1000.;
-  int mode=c.over_mode;
 
   run_filter(overdB,lx,input_size,lookahead,mode,iir,attack,decay,ps);
   
   if(adj){
-    float corner_multiplier=(1.-1./(c.over_ratio/1000.));
-    if(c.over_softknee){
+    float corner_multiplier= 1.- 1000./ratio;
+    if(knee){
       for(k=0;k<input_size;k++)
         adj[k]+=soft_knee(overdB[k]-zerocorner)*corner_multiplier;
     }else{
@@ -316,16 +305,17 @@
 static void base_compand(float *x,
                          iir_filter *attack, iir_filter *decay,
                          iir_state *iir, peak_state *ps,
+			 int mode,
+			 int ratio,
                          float *adj){
   int k;
   float basedB[input_size];
-  int mode=c.base_mode;
 
   run_filter(basedB,x,input_size,1.,mode,
              iir,attack,decay,ps);
   
   if(adj){
-    float base_multiplier=(1.-1./(c.base_ratio/1000.));
+    float base_multiplier=1.-1000./ratio;
     for(k=0;k<input_size;k++)
       adj[k]-=(basedB[k]+adj[k])*base_multiplier;
   }
@@ -334,18 +324,18 @@
 static void under_compand(float *x,float zerocorner,
                          iir_filter *attack, iir_filter *decay,
                          iir_state *iir, peak_state *ps,
+			 float lookahead,int mode,int knee,
+			 int ratio,
                          float *adj){
   int k;
   float underdB[input_size];
-  float lookahead=c.under_lookahead/1000.;
-  int mode=c.under_mode;
 
   run_filter(underdB,x,input_size,lookahead,mode,
              iir,attack,decay,ps);
   
   if(adj){
-    float corner_multiplier=(1./(c.under_ratio/1000.)-1.);
-    if(c.under_softknee){
+    float corner_multiplier=1000./ratio -1.;
+    if(knee){
       for(k=0;k<input_size;k++)
         adj[k]=soft_knee(zerocorner-underdB[k])*corner_multiplier;
     }else{
@@ -355,129 +345,158 @@
   }
 }
 
-static void multicompand_work(void *vs){
-  multicompand_state *ms=(multicompand_state *)vs;
+static int find_maxbands(subband_state *ss,int channel){
+  int maxbands=ss->wC[channel]->freq_bands;
+  if(maxbands<ss->w0[channel]->freq_bands)maxbands=ss->w0[channel]->freq_bands;
+  if(maxbands<ss->w1[channel]->freq_bands)maxbands=ss->w1[channel]->freq_bands;
+  return maxbands;
+}
+
+static int multicompand_work_channel(multicompand_state *ms, 
+				     float **peakfeed,
+				     float **rmsfeed,
+				     int maxbands,
+				     int channel,
+				     multicompand_settings *c){
   subband_state *ss=&ms->ss;
-  int i,j,k,bypass_visible=1;
+  int active=(ss->effect_active1[channel] || 
+	      ss->effect_active0[channel] || 
+	      ss->effect_activeC[channel]);
+    
+  int feedback_p=0;
+  int i,k,bank;
+  subband_window *w=ss->w1[channel];
+  subband_window *wP=ss->wP[channel];
   float adj[input_size];
-  int maxmaxbands=0;
-
-  float **peakfeed=ms->peak;
-  float **rmsfeed=ms->rms;
   
-  for(j=0;j<input_ch;j++){
-    int active=(ss->effect_active1[j] || 
-		ss->effect_active0[j] || 
-		ss->effect_activeC[j]);
+  if(w==&ms->sw[0]){
+    bank=0;
+  }else if(w==&ms->sw[1]){
+    bank=1;
+  }else bank=2;
+  
+  for(i=0;i<maxbands;i++){
     
-    int bank;
-    subband_window *w=ss->w1[j];
-    subband_window *wP=ss->wP[j];
-    int maxbands=ss->wC[j]->freq_bands;
-    if(maxbands<ss->w0[j]->freq_bands)maxbands=ss->w0[j]->freq_bands;
-    if(maxbands<ss->w1[j]->freq_bands)maxbands=ss->w1[j]->freq_bands;
-    if(maxbands>maxmaxbands)maxmaxbands=maxbands;
+    float *x=ss->lap[i][channel];
     
-    if(w==&ms->sw[0]){
-      bank=0;
-    }else if(w==&ms->sw[1]){
-      bank=1;
-    }else bank=2;
-    
-    for(i=0;i<maxbands;i++){
+    if(active){
+      /* one thing is worth a note here; 'maxbands' can be
+	 'overrange' for the current bank.  This is intentional; we
+	 may need to run the additional (allocated and valid)
+	 filters before or after their bands are active.  The only
+	 garbage data here is the xxxx_u, xxxx_o and xxxx_b
+	 settings.  There are allocated, but unset; if overrange,
+	 they're ignored in the compand worker */
+      under_compand(x,  
+		    c->bc[bank].static_u[i], 
+		    &ms->under_attack[channel],
+		    &ms->under_decay[channel],
+		    &ms->under_iir[i][channel],
+		    &ms->under_peak[i][channel],
+		    c->under_lookahead/1000.,
+		    c->under_mode,
+		    c->under_softknee,
+		    c->under_ratio,
+		    (i>=w->freq_bands?0:adj));
       
-      float *x=ss->lap[i][j];
+      over_compand(x,  
+		   c->bc[bank].static_o[i],
+		   &ms->over_attack[channel],
+		   &ms->over_decay[channel],
+		   &ms->over_iir[i][channel],
+		   &ms->over_peak[i][channel],
+		   c->over_lookahead/1000.,
+		   c->over_mode,
+		   c->over_softknee,
+		   c->over_ratio,
+		   (i>=w->freq_bands?0:adj));
       
-      if(active){
-	/* one thing is worth a note here; 'maxbands' can be
-	   'overrange' for the current bank.  This is intentional; we
-	   may need to run the additional (allocated and valid)
-	   filters before or after their bands are active.  The only
-	   garbage data here is the xxxx_u, xxxx_o and xxxx_b
-	   settings.  There are allocated, but unset; if overrange,
-	   they're ignored in the compand worker */
-	under_compand(x,  
-		      bc[bank].static_u[i], 
-		      &ms->under_attack,
-		      &ms->under_decay,
-		      &ms->under_iir[i][j],
-		      &ms->under_peak[i][j],
-		      (i>=w->freq_bands?0:adj));
-	
-	over_compand(x,  
-	     bc[bank].static_o[i],
-	     &ms->over_attack,
-	     &ms->over_decay,
-	     &ms->over_iir[i][j],
-	     &ms->over_peak[i][j],
-	     (i>=w->freq_bands?0:adj));
+    }
+    
+    if(ss->visible1[channel] && !mute_channel_muted(ss->mutemask1,channel)){
+      /* determine rms and peak for feedback */
+      float max=-1.;
+      int maxpos=-1;
+      float rms=0.;
 
-      }
-
-      if(ss->visible1[j] && !mute_channel_muted(ss->mutemask1,j)){
-	/* determine rms and peak for feedback */
-	float max=-1.;
-	int maxpos=-1;
-	float rms=0.;
-	if(bypass_visible){
-	  int ii;
-	  for(ii=0;ii<w->freq_bands;ii++){
-	    memset(peakfeed[ii],0,input_ch*sizeof(**peakfeed));
-	    memset(rmsfeed[ii],0,input_ch*sizeof(**rmsfeed));
-	  }
+      feedback_p=1;
+      
+      for(k=0;k<input_size;k++){
+	float val=x[k]*x[k];
+	if(val>max){
+	  max=val;
+	  maxpos=k;
         }
-	bypass_visible=0;
-
-	for(k=0;k<input_size;k++){
-	  float val=x[k]*x[k];
-	  if(val>max){
-	    max=val;
-	    maxpos=k;
-	  }
-	  rms+=val;
-	}
-	if(active){
-	  peakfeed[i][j]=todB(max)*.5+adj[maxpos];
-	  rmsfeed[i][j]=todB(rms/input_size)*.5+adj[maxpos];
-	}else{
-	  peakfeed[i][j]=todB(max)*.5;
-	  rmsfeed[i][j]=todB(rms/input_size)*.5;
-	}
+	rms+=val;
       }
-      
       if(active){
-	base_compand(x,  
-	     &ms->base_attack,
-	     &ms->base_decay,
-	     &ms->base_iir[i][j],
-	     &ms->base_peak[i][j],
-	     (i>=w->freq_bands?0:adj));
-	
-	if(ss->effect_activeC[j]){
-	  for(k=0;k<input_size;k++)
-	    x[k]*=fromdB_a(adj[k]);
-	}
-      } else if (ss->effect_activeP[j]){ 
-	/* this lapping channel just became inactive */
-	memset(&ms->over_peak[i][j],0,sizeof(peak_state));
-	memset(&ms->under_peak[i][j],0,sizeof(peak_state));
-	memset(&ms->base_peak[i][j],0,sizeof(peak_state));
-	memset(&ms->over_iir[i][j],0,sizeof(iir_state));
-	memset(&ms->under_iir[i][j],0,sizeof(iir_state));
-	memset(&ms->base_iir[i][j],0,sizeof(iir_state));
-      }   
+	peakfeed[i][channel]=todB(max)*.5+adj[maxpos];
+	rmsfeed[i][channel]=todB(rms/input_size)*.5+adj[maxpos];
+      }else{
+	peakfeed[i][channel]=todB(max)*.5;
+	rmsfeed[i][channel]=todB(rms/input_size)*.5;
+      }
     }
     
-    for(;i<wP->freq_bands;i++){
-      memset(&ms->over_peak[i][j],0,sizeof(peak_state));
-      memset(&ms->under_peak[i][j],0,sizeof(peak_state));
-      memset(&ms->base_peak[i][j],0,sizeof(peak_state));
-      memset(&ms->over_iir[i][j],0,sizeof(iir_state));
-      memset(&ms->under_iir[i][j],0,sizeof(iir_state));
-      memset(&ms->base_iir[i][j],0,sizeof(iir_state));
-    }
+    if(active){
+      base_compand(x,  
+		   &ms->base_attack[channel],
+		   &ms->base_decay[channel],
+		   &ms->base_iir[i][channel],
+		   &ms->base_peak[i][channel],
+		   c->base_mode,
+		   c->base_ratio,
+		   (i>=w->freq_bands?0:adj));
+      
+      if(ss->effect_activeC[channel]){
+	for(k=0;k<input_size;k++)
+	  x[k]*=fromdB_a(adj[k]);
+      }
+    } else if (ss->effect_activeP[channel]){ 
+      /* this lapping channel just became inactive */
+      memset(&ms->over_peak[i][channel],0,sizeof(peak_state));
+      memset(&ms->under_peak[i][channel],0,sizeof(peak_state));
+      memset(&ms->base_peak[i][channel],0,sizeof(peak_state));
+      memset(&ms->over_iir[i][channel],0,sizeof(iir_state));
+      memset(&ms->under_iir[i][channel],0,sizeof(iir_state));
+      memset(&ms->base_iir[i][channel],0,sizeof(iir_state));
+    }   
   }
+  
+  for(;i<wP->freq_bands;i++){
+    memset(&ms->over_peak[i][channel],0,sizeof(peak_state));
+    memset(&ms->under_peak[i][channel],0,sizeof(peak_state));
+    memset(&ms->base_peak[i][channel],0,sizeof(peak_state));
+    memset(&ms->over_iir[i][channel],0,sizeof(iir_state));
+    memset(&ms->under_iir[i][channel],0,sizeof(iir_state));
+    memset(&ms->base_iir[i][channel],0,sizeof(iir_state));
+  }
+  return(feedback_p);
+}
 
+static void multicompand_work(void *vs){
+  multicompand_state *ms=(multicompand_state *)vs;
+  subband_state *ss=&ms->ss;
+  int i,j,bypass_visible=1;
+  int maxmaxbands=0;
+ 
+  float **peakfeed=ms->peak;
+  float **rmsfeed=ms->rms;
+
+  for(i=0;i<multicomp_freqs_max;i++){
+    memset(peakfeed[i],0,input_ch*sizeof(**peakfeed));
+    memset(rmsfeed[i],0,input_ch*sizeof(**rmsfeed));
+  }
+ 
+  for(j=0;j<input_ch;j++){
+    int maxbands=find_maxbands(ss,j);
+    if(maxbands>maxmaxbands)maxmaxbands=maxbands;
+
+    if(multicompand_work_channel(ms, peakfeed, rmsfeed, maxbands, j, &multi_master_set))
+      bypass_visible=0;
+  }
+
+
   /* finish up the state feedabck */
   if(bypass_visible){
     multicompand_feedback *ff=
@@ -500,17 +519,35 @@
   }
 }
 
-time_linkage *multicompand_read(time_linkage *in){
+time_linkage *multicompand_read_master(time_linkage *in){
   int visible[input_ch];
   int active[input_ch];
   subband_window *w[input_ch];
-  int i,ab=c.active_bank;
+  int i,ab=multi_master_set.active_bank;
 
   for(i=0;i<input_ch;i++){
-    visible[i]=compand_visible;
-    active[i]=compand_active;
+    visible[i]=multi_master_set.panel_visible;
+    active[i]=multi_master_set.panel_active;
     w[i]=&ms.sw[ab];
   }
+
+  /* do any filters need updated from UI changes? */
+  {
+    float o_attackms=multi_master_set.over_attack*.1;
+    float o_decayms=multi_master_set.over_decay*.1;
+    float u_attackms=multi_master_set.under_attack*.1;
+    float u_decayms=multi_master_set.under_decay*.1;
+    float b_attackms=multi_master_set.base_attack*.1;
+    float b_decayms=multi_master_set.base_decay*.1;
+
+    if(o_attackms!=ms.over_attack[0].ms) filterbank_set(o_attackms,ms.over_attack,1);
+    if(o_decayms !=ms.over_decay[0].ms)  filterbank_set(o_decayms,ms.over_decay,0);
+    if(u_attackms!=ms.under_attack[0].ms)filterbank_set(u_attackms,ms.under_attack,1);
+    if(u_decayms !=ms.under_decay[0].ms) filterbank_set(u_decayms,ms.under_decay,0);
+    if(b_attackms!=ms.base_attack[0].ms) filterbank_set(b_attackms,ms.base_attack,1);
+    if(b_decayms !=ms.base_decay[0].ms)  filterbank_set(b_decayms,ms.base_decay,0);
+  }
+
   return subband_read(in, &ms.ss, w,
                       visible,active,multicompand_work,&ms);
 

Modified: trunk/postfish/multicompand.h
===================================================================
--- trunk/postfish/multicompand.h	2004-04-22 11:52:24 UTC (rev 6577)
+++ trunk/postfish/multicompand.h	2004-04-22 22:27:52 UTC (rev 6578)
@@ -48,10 +48,12 @@
 typedef struct {
   sig_atomic_t static_o[multicomp_freqs_max];
   sig_atomic_t static_u[multicomp_freqs_max];
-} banked_compand_settings;
+} banked_multicompand_settings;
 
 typedef struct {
 
+  banked_multicompand_settings bc[multicomp_banks];
+
   sig_atomic_t over_mode;
   sig_atomic_t over_softknee;
   sig_atomic_t over_ratio;
@@ -74,16 +76,17 @@
   sig_atomic_t under_trim;
 
   sig_atomic_t active_bank;
-} other_compand_settings;
 
+  sig_atomic_t panel_active;
+  sig_atomic_t panel_visible;
+} multicompand_settings;
+
 extern void multicompand_reset();
 extern int multicompand_load(void);
-extern time_linkage *multicompand_read(time_linkage *in);
-extern int pull_multicompand_feedback(float **peak,float **rms,int *bands);
 
-extern int multicompand_over_attack_set(float msec);
-extern int multicompand_over_decay_set(float msec);
-extern int multicompand_under_attack_set(float msec);
-extern int multicompand_under_decay_set(float msec);
-extern int multicompand_base_attack_set(float msec);
-extern int multicompand_base_decay_set(float msec);
+extern time_linkage *multicompand_read_channels(time_linkage *in);
+extern time_linkage *multicompand_read_master(time_linkage *in);
+
+extern int pull_multicompand_feedback_channels(float **peak,float **rms,int *bands);
+extern int pull_multicompand_feedback_master(float **peak,float **rms,int *bands);
+

Modified: trunk/postfish/output.c
===================================================================
--- trunk/postfish/output.c	2004-04-22 11:52:24 UTC (rev 6577)
+++ trunk/postfish/output.c	2004-04-22 22:27:52 UTC (rev 6578)
@@ -238,7 +238,12 @@
 
     link=declip_read(link);
     result|=link->samples;
-    link=multicompand_read(link);
+
+
+
+
+
+    link=multicompand_read_master(link);
     result|=link->samples;
     link=singlecomp_read(link);
     result|=link->samples;

Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h	2004-04-22 11:52:24 UTC (rev 6577)
+++ trunk/postfish/version.h	2004-04-22 22:27:52 UTC (rev 6578)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Thu Apr 22 07:48:59 EDT 2004] */
+/* DO NOT EDIT: Automated versioning hack [Thu Apr 22 18:25:14 EDT 2004] */

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list