[xiph-commits] r7967 - trunk/postfish

xiphmont at motherfish-iii.xiph.org xiphmont at motherfish-iii.xiph.org
Sun Oct 10 17:36:04 PDT 2004


Author: xiphmont
Date: 2004-10-10 17:36:04 -0700 (Sun, 10 Oct 2004)
New Revision: 7967

Modified:
   trunk/postfish/eqpanel.c
   trunk/postfish/mixpanel.c
   trunk/postfish/version.h
Log:
Add average attenuation slider to EQ panel 



Modified: trunk/postfish/eqpanel.c
===================================================================
--- trunk/postfish/eqpanel.c	2004-10-10 22:48:21 UTC (rev 7966)
+++ trunk/postfish/eqpanel.c	2004-10-11 00:36:04 UTC (rev 7967)
@@ -36,13 +36,15 @@
 typedef struct {
   GtkWidget *slider;
   GtkWidget *readout;
-  eq_settings *s;
+  struct eps *p;
   int number;
 } bar;
 
-typedef struct {
+typedef struct eps {
   subpanel_generic *panel;
   bar *bars;
+  eq_settings *s;
+  int av_callback_enter;
 } eq_panel_state;
 
 static eq_panel_state *master_panel;
@@ -80,6 +82,33 @@
     eqpanel_state_from_config_helper(bank,eq_channel_set+i,channel_panel[i],i+1);
 }
 
+static float determine_average(eq_panel_state *p){
+  bar *b=p->bars;
+  int i;
+  float acc=0;
+  for(i=0;i<eq_freqs;i++)
+    acc+=multibar_get_value(MULTIBAR(b[i].slider),0);
+  return acc/eq_freqs;
+}
+
+static void average_change(GtkWidget *w,gpointer in){
+  eq_panel_state *p=(eq_panel_state *)in;
+  if(!p->av_callback_enter){
+    
+    float av=multibar_get_value(MULTIBAR(p->bars[eq_freqs].slider),0);
+    float actual=determine_average(p);
+    int i;
+
+    p->av_callback_enter=1;
+    for(i=0;i<eq_freqs;i++){
+      float val=multibar_get_value(MULTIBAR(p->bars[i].slider),0) + av - actual;
+      multibar_thumb_set(MULTIBAR(p->bars[i].slider),val,0);
+    }
+    
+    p->av_callback_enter=0;
+  }
+}
+
 static void slider_change(GtkWidget *w,gpointer in){
   char buffer[80];
   bar *b=(bar *)in;
@@ -88,8 +117,14 @@
   sprintf(buffer,"%+3.0fdB",val);
   readout_set(READOUT(b->readout),buffer);
   
-  eq_set(b->s,b->number,val);
+  eq_set(b->p->s,b->number,val);
 
+  if(!b->p->av_callback_enter){
+    b->p->av_callback_enter=1;
+    float actual=determine_average(b->p);
+    multibar_thumb_set(MULTIBAR(b->p->bars[eq_freqs].slider),actual,0);
+    b->p->av_callback_enter=0;
+  }
 }
 
 static eq_panel_state *eqpanel_create_helper(postfish_mainpanel *mp,
@@ -99,15 +134,19 @@
   int i;
   char *labels[16]={"","110","100","90","80","70","60","50","40",
 		    "30","20","10","0","+10","+20","+30"};
+  char *labels2[16]={"","","","","","","60","50","40",
+		    "30","20","10","0","+10","+20","+30"};
   float levels[16]={-120,-110,-100,-90,-80,-70,-60,-50,-40,
 		     -30,-20,-10,0,10,20,30};
 
-  GtkWidget *slidertable=gtk_table_new(eq_freqs,3,0);
-  bar *bars=calloc(eq_freqs,sizeof(*bars));
+  GtkWidget *slidertable=gtk_table_new(eq_freqs+1,3,0);
+  bar *bars=calloc(eq_freqs+1,sizeof(*bars));
   eq_panel_state *p=calloc(1,sizeof(*p));
 
   p->bars=bars;
+  p->s=es;
   p->panel=panel;
+  p->av_callback_enter=1;
 
   for(i=0;i<eq_freqs;i++){
     const char *labeltext=eq_freq_labels[i];
@@ -119,7 +158,7 @@
     bars[i].slider=multibar_new(16,labels,levels,1,
 				LO_DECAY|HI_DECAY|LO_ATTACK|HI_ATTACK);
     bars[i].number=i;
-    bars[i].s=es;
+    bars[i].p=p;
 
     multibar_callback(MULTIBAR(bars[i].slider),slider_change,bars+i);
     multibar_thumb_set(MULTIBAR(bars[i].slider),0.,0);
@@ -136,8 +175,30 @@
 		     GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,0,0);
   }
 
+  {
+    GtkWidget *label=gtk_label_new("average");
+    gtk_widget_set_name(label,"smallmarker");
+
+    bars[i].slider=multibar_slider_new(16,labels2,levels,1);
+    bars[i].number=i;
+    bars[i].p=p;
+
+    multibar_callback(MULTIBAR(bars[i].slider),average_change,p);
+    multibar_thumb_bounds(MULTIBAR(bars[i].slider),-60,30);
+    multibar_thumb_increment(MULTIBAR(bars[i].slider),1,10);
+
+    gtk_misc_set_alignment(GTK_MISC(label),1,.5);
+
+    gtk_table_attach(GTK_TABLE(slidertable),label,0,1,i,i+1,
+		     GTK_FILL,0,0,0);
+    gtk_table_attach(GTK_TABLE(slidertable),bars[i].slider,1,2,i,i+1,
+		     GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,0,0);
+
+  }
+
   gtk_box_pack_start(GTK_BOX(panel->subpanel_box),slidertable,1,1,4);
   subpanel_show_all_but_toplevel(panel);
+  p->av_callback_enter=0;
 
   return p;
 }

Modified: trunk/postfish/mixpanel.c
===================================================================
--- trunk/postfish/mixpanel.c	2004-10-10 22:48:21 UTC (rev 7966)
+++ trunk/postfish/mixpanel.c	2004-10-11 00:36:04 UTC (rev 7967)
@@ -174,7 +174,6 @@
 
 static void av_slider_change(GtkWidget *w,gpointer in){
   if(!av_callback_enter){
-    char buffer[80];
     atten_panelsave *p=(atten_panelsave *)in;
     
     float av=multibar_get_value(MULTIBAR(p->average),0);

Modified: trunk/postfish/version.h
===================================================================
--- trunk/postfish/version.h	2004-10-10 22:48:21 UTC (rev 7966)
+++ trunk/postfish/version.h	2004-10-11 00:36:04 UTC (rev 7967)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Sun Oct 10 19:06:35 EDT 2004] */
+/* DO NOT EDIT: Automated versioning hack [Sun Oct 10 20:56:54 EDT 2004] */



More information about the commits mailing list