[xiph-cvs] cvs commit: postfish clippanel.c declip.c declip.h mainpanel.c multibar.c multibar.h postfish-gtkrc version.h

Monty xiphmont at xiph.org
Sun Feb 15 21:00:56 PST 2004



xiphmont    04/02/16 00:00:56

  Modified:    .        clippanel.c declip.c declip.h mainpanel.c
                        multibar.c multibar.h postfish-gtkrc version.h
  Log:
  link the trigger slider into live peak data

Revision  Changes    Path
1.10      +15 -4     postfish/clippanel.c

Index: clippanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/clippanel.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- clippanel.c	15 Feb 2004 15:14:14 -0000	1.9
+++ clippanel.c	16 Feb 2004 05:00:54 -0000	1.10
@@ -37,6 +37,7 @@
 extern sig_atomic_t declip_converge;
 
 GtkWidget **feedback_bars;
+GtkWidget **trigger_bars;
 
 GtkWidget *samplereadout;
 GtkWidget *msreadout;
@@ -135,6 +136,7 @@
   gtk_container_set_border_width(GTK_CONTAINER(limit_box),2);
 
   feedback_bars=calloc(input_ch,sizeof(*feedback_bars));
+  trigger_bars=calloc(input_ch,sizeof(*trigger_bars));
 
   /* set up blocksize config */
   for(i=64;i<=input_size*2;i*=2)block_choices++;
@@ -249,16 +251,19 @@
     char buffer[80];
     clipslider *cs=calloc(1,sizeof(*cs));
     GtkWidget *label;
-    GtkWidget *slider=multibar_new(8,slabels,slevels,HI_DECAY|ZERO_DAMP|PEAK_FOLLOW);
+    GtkWidget *slider=multibar_new(8,slabels,slevels,1,
+				   HI_DECAY|ZERO_DAMP);
     GtkWidget *readout=readout_new("0.00");
     GtkWidget *readoutdB=readout_new("-40 dB");
-    GtkWidget *bar=multibar_new(2,labels,levels,HI_DECAY|ZERO_DAMP|PEAK_FOLLOW);
+    GtkWidget *bar=multibar_new(2,labels,levels,0,
+				HI_DECAY|ZERO_DAMP);
 
     cs->slider=slider;
     cs->readout=readout;
     cs->readoutdB=readoutdB;
     cs->number=i;
     feedback_bars[i]=bar;
+    trigger_bars[i]=slider;
 
     gtk_widget_set_name(bar,"clipbar");
     multibar_thumb_set(MULTIBAR(slider),1.,0);
@@ -314,7 +319,8 @@
 
 void clippanel_feedback(void){
   int clip[input_ch],count;
-  if(pull_declip_feedback(clip,&count)){
+  double peak[input_ch];
+  if(pull_declip_feedback(clip,peak,&count)){
     int i;
     for(i=0;i<input_ch;i++){
       double val[2],zero[2];
@@ -322,9 +328,12 @@
       val[1]=(count?clip[i]*100./count-.1:-1);
       zero[1]=-1.;
       multibar_set(MULTIBAR(feedback_bars[i]),zero,val,2);
+      val[1]=(count?peak[i]:-1);
+      multibar_set(MULTIBAR(trigger_bars[i]),zero,val,2);
       if(clip[i]){
         multibar_setwarn(MULTIBAR(mainpanel_inbar));
         multibar_setwarn(MULTIBAR(feedback_bars[i]));
+	multibar_setwarn(MULTIBAR(trigger_bars[i]));
       }
     }
   }
@@ -332,6 +341,8 @@
 
 void clippanel_reset(void){
   int i;
-  for(i=0;i<input_ch;i++)
+  for(i=0;i<input_ch;i++){
     multibar_reset(MULTIBAR(feedback_bars[i]));
+    multibar_reset(MULTIBAR(trigger_bars[i]));
+  }
 }

<p><p>1.6       +16 -8     postfish/declip.c

Index: declip.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/declip.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- declip.c	13 Feb 2004 18:11:35 -0000	1.5
+++ declip.c	16 Feb 2004 05:00:54 -0000	1.6
@@ -60,6 +60,7 @@
 /* feedback! */
 typedef struct declip_feedback{
   feedback_generic parent_class;
+  double *peak;
   int *clipcount;
   int total;
 } declip_feedback;
@@ -69,25 +70,28 @@
 static feedback_generic *new_declip_feedback(void){
   declip_feedback *ret=malloc(sizeof(*ret));
   ret->clipcount=malloc((input_ch)*sizeof(*ret->clipcount));
+  ret->peak=malloc((input_ch)*sizeof(*ret->peak));
   return (feedback_generic *)ret;
 }
 
-static void push_declip_feedback(int *clip,int total){
+static void push_declip_feedback(int *clip,double *peak,int total){
   int i,n=input_ch;
   declip_feedback *f=(declip_feedback *)
     feedback_new(&feedpool,new_declip_feedback);
   memcpy(f->clipcount,clip,n*sizeof(*clip));
+  memcpy(f->peak,peak,n*sizeof(*peak));
   f->total=total;
   feedback_push(&feedpool,(feedback_generic *)f);
 }
 
-int pull_declip_feedback(int *clip,int *total){
+int pull_declip_feedback(int *clip,double *peak,int *total){
   declip_feedback *f=(declip_feedback *)feedback_pull(&feedpool);
   int i,j;
 
   if(!f)return 0;
 
   if(clip)memcpy(clip,f->clipcount,sizeof(*clip)*input_ch);
+  if(peak)memcpy(peak,f->peak,sizeof(*peak)*input_ch);
   if(total)*total=f->total;
 
   feedback_old(&feedpool,(feedback_generic *)f);
@@ -150,7 +154,7 @@
 int declip_reset(void){
   /* reset cached pipe state */
   fillstate=0;
-  while(pull_declip_feedback(NULL,NULL));
+  while(pull_declip_feedback(NULL,NULL,NULL));
   return 0;
 }
 
@@ -215,12 +219,13 @@
 static void declip(double *data,double *lap,double *out,
                    int blocksize,double trigger,
                    double epsilon, double iteration,
-		   int *runningtotal, int *runningcount){
+		   int *runningtotal, int *runningcount,double *peak){
   double freq[blocksize*2];
   double flag[blocksize*2];
   int    iterbound,i,j,count=0;
   
   for(i=blocksize/2;i<blocksize*3/2;i++){
+    if(fabs(data[i])>*peak)*peak=fabs(data[i]);
     flag[i]=0.;
     if(data[i]>=trigger || data[i]<=-trigger){
       flag[i]=1.;
@@ -274,6 +279,8 @@
   double local_trigger[input_ch];
   int total=0;
   int count[input_ch];
+  double peak[input_ch];
+
   time_linkage dummy;
 
   double local_convergence;
@@ -286,6 +293,7 @@
   pthread_mutex_unlock(&master_mutex);
 
   memset(count,0,sizeof(count));
+  memset(peak,0,sizeof(peak));
 
   if(pending_blocksize!=blocksize){
     if(blocksize){
@@ -327,7 +335,7 @@
         memcpy(work+blocksize,temp,sizeof(*work)*blocksize/2);
         declip(work,lap[i],0,blocksize,
                local_trigger[i],local_convergence,local_iterations,
-	       &total,count+i);
+	       &total,count+i,peak+i);
         
         memset(cache[i],0,sizeof(**cache)*input_size);
         in->data[i]=cache[i];
@@ -351,14 +359,14 @@
           memcpy(work+blocksize/2,temp+j,sizeof(*work)*blocksize);
           declip(work,lap[i],out.data[i]+j,blocksize,
                  local_trigger[i],local_convergence,local_iterations,
-		 &total,count+i);
+		 &total,count+i,peak+i);
         }
         memcpy(work+blocksize/2,temp+j,sizeof(*work)*blocksize/2);
         memcpy(work+blocksize,in->data[i],sizeof(*work)*blocksize/2);
 
         declip(work,lap[i],out.data[i]+j,blocksize,
                local_trigger[i],local_convergence,local_iterations,
-	       &total,count+i);
+	       &total,count+i,peak+i);
         
         cache[i]=in->data[i];
         in->data[i]=temp;
@@ -372,7 +380,7 @@
     }
   }
 
-  push_declip_feedback(count,total);
+  push_declip_feedback(count,peak,total);
 
  tidy_up:
   {

<p><p>1.3       +1 -0      postfish/declip.h

Index: declip.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/declip.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- declip.h	24 Dec 2003 09:49:16 -0000	1.2
+++ declip.h	16 Feb 2004 05:00:54 -0000	1.3
@@ -28,3 +28,4 @@
 extern int declip_setconvergence(double x);
 extern int declip_reset(void);
 extern time_linkage *declip_read(time_linkage *in);
+extern int pull_declip_feedback(int *clip,double *peak,int *total);

<p><p>1.28      +4 -2      postfish/mainpanel.c

Index: mainpanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/mainpanel.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- mainpanel.c	15 Feb 2004 15:14:14 -0000	1.27
+++ mainpanel.c	16 Feb 2004 05:00:54 -0000	1.28
@@ -593,8 +593,10 @@
     GtkWidget *out=gtk_label_new("out:");
     GtkWidget *show=gtk_label_new("show:");
 
-    panel->inbar=multibar_new(12,labels,levels, LO_ATTACK|LO_DECAY|HI_DECAY|PEAK_FOLLOW );
-    panel->outbar=multibar_new(12,labels,levels, LO_ATTACK|LO_DECAY|HI_DECAY|PEAK_FOLLOW );
+    panel->inbar=multibar_new(12,labels,levels, 0,
+			      LO_ATTACK|LO_DECAY|HI_DECAY|PEAK_FOLLOW );
+    panel->outbar=multibar_new(12,labels,levels, 0,
+			       LO_ATTACK|LO_DECAY|HI_DECAY|PEAK_FOLLOW );
 
     gtk_container_set_border_width(GTK_CONTAINER (ttable), 3);
     gtk_table_set_col_spacings(GTK_TABLE(ttable),5);

<p><p>1.17      +22 -13    postfish/multibar.c

Index: multibar.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- multibar.c	15 Feb 2004 22:38:14 -0000	1.16
+++ multibar.c	16 Feb 2004 05:00:54 -0000	1.17
@@ -347,7 +347,7 @@
     GdkGC *gc=parent->style->bg_gc[0];
     GdkGC *light_gc=parent->style->light_gc[0];
     GdkGC *dark_gc=parent->style->dark_gc[0];
-    GdkGC *mid_gc=parent->style->mid_gc[0];
+    GdkGC *mid_gc=widget->style->bg_gc[GTK_STATE_ACTIVE];
 
     /* blank side padding to bg of parent */
     gdk_draw_rectangle(m->backing,gc,1,0,0,xpad,height);
@@ -547,6 +547,7 @@
 static void size_request (GtkWidget *widget,GtkRequisition *requisition){
   int i,maxx=0,maxy=0,x,y,xpad;
   Multibar *m=MULTIBAR(widget);
+
   for(i=0;i<m->labels;i++){
     pango_layout_get_pixel_size(m->layout[i],&x,&y);
 
@@ -556,10 +557,18 @@
 
   maxy+=4;
 
-  requisition->width = (maxx*1.5+2)*m->labels;
+  if(m->thumbs==0){
+    xpad=2;
+  }else{
+    if(m->thumbs>1)
+      xpad=maxy+(maxy/2-1)/2-1+2;
+    else
+      xpad=maxy/2+1+2;
+  }
+
+  requisition->width = (maxx*1.5+2)*m->labels+xpad*2;
   requisition->height = maxy;
 
-  fprintf(stderr,"reqwidth=%d, maxx=%d, maxy=%d labels=%d\n",requisition->width,maxx,maxy,m->labels);
 }
 
 static gboolean multibar_focus (GtkWidget         *widget,
@@ -569,8 +578,6 @@
 
   if(m->thumbs==0)return FALSE;
 
-  fprintf(stderr,"thumbfocus=%d thumbs=%d ",m->thumbfocus,m->thumbs);
-
   switch(direction){
   case GTK_DIR_DOWN:
   case GTK_DIR_TAB_FORWARD:
@@ -598,12 +605,11 @@
   default:
     ret=FALSE;
   }
-  fprintf(stderr,"thumbfocus=%d thumbs=%d ",m->thumbfocus,m->thumbs);
 
   m->prev_thumbfocus=m->thumbfocus;
   if(ret==TRUE) gtk_widget_grab_focus(widget);
   draw_and_expose(widget);
-  fprintf(stderr,"thumbfocus=%d \n",m->thumbfocus);
+
   return ret;
 }
 
@@ -713,7 +719,7 @@
   for(i=0;i<m->thumbs;i++)
     m->thumbpixel[i]=val_to_pixel(widget,m->thumbval[i]);
   draw_and_expose(widget);
-  fprintf(stderr,"acwidth=%d\n",widget->allocation.width);
+
   return TRUE;
 }
 
@@ -959,7 +965,8 @@
   return m_type;
 }
 
-GtkWidget* multibar_new (int n, char **labels, double *levels, int flags){
+GtkWidget* multibar_new (int n, char **labels, double *levels, int thumbs,
+			 int flags){
   int i;
   GtkWidget *ret= GTK_WIDGET (g_object_new (multibar_get_type (), NULL));
   Multibar *m=MULTIBAR(ret);
@@ -979,6 +986,11 @@
   m->thumblo=levels[0];
   m->thumbhi=levels[n];
 
+  if(thumbs<0)thumbs=0;
+  if(thumbs>3)thumbs=3;
+  m->thumbs=thumbs;
+  if(m->thumbs!=0)  GTK_WIDGET_SET_FLAGS (m, GTK_CAN_FOCUS);
+
   {
     int events=gtk_widget_get_events(ret);
     gtk_widget_set_events(ret,              events|
@@ -1005,11 +1017,8 @@
   GtkWidget *w=GTK_WIDGET(m);
 
   if(n<0)return;
-  if(n>2)return;
+  if(n>=m->thumbs)return;
 
-  if(m->thumbs==0)  GTK_WIDGET_SET_FLAGS (m, GTK_CAN_FOCUS);
-  
-  if(n+1>m->thumbs)m->thumbs=n+1;
   {
     int x=m->thumbpixel[n]=val_to_pixel(w,v);
     m->thumbval[n]=v;

<p><p>1.9       +1 -1      postfish/multibar.h

Index: multibar.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- multibar.h	15 Feb 2004 15:14:15 -0000	1.8
+++ multibar.h	16 Feb 2004 05:00:54 -0000	1.9
@@ -80,7 +80,7 @@
 
 GType          multibar_get_type        (void);
 GtkWidget*     multibar_new             (int n, char **labels, double *levels,
-					 int flags);
+					 int thumbs, int flags);
 void	       multibar_clear           (Multibar *m);
 void	       multibar_set             (Multibar *m,double *lo,double *hi, int n);
 void	       multibar_thumb_set       (Multibar *m,double v, int n);

<p><p>1.4       +1 -1      postfish/postfish-gtkrc

Index: postfish-gtkrc
===================================================================
RCS file: /usr/local/cvsroot/postfish/postfish-gtkrc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- postfish-gtkrc	15 Feb 2004 15:14:15 -0000	1.3
+++ postfish-gtkrc	16 Feb 2004 05:00:54 -0000	1.4
@@ -41,7 +41,7 @@
 
 style "multibar" {
         bg[NORMAL]="#80a0ff" 
-        bg[ACTIVE]="#c0f0ff" 
+        bg[ACTIVE]="#b0b0b0" 
         bg[PRELIGHT]="#c0f0ff" 
 
         fg[NORMAL]="#000000" 

<p><p>1.29      +2 -2      postfish/version.h

Index: version.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/version.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- version.h	15 Feb 2004 22:38:15 -0000	1.28
+++ version.h	16 Feb 2004 05:00:54 -0000	1.29
@@ -1,2 +1,2 @@
-#define VERSION "$Id: version.h,v 1.28 2004/02/15 22:38:15 xiphmont Exp $ "
-/* DO NOT EDIT: Automated versioning hack [Sun Feb 15 10:22:58 EST 2004] */
+#define VERSION "$Id: version.h,v 1.29 2004/02/16 05:00:54 xiphmont Exp $ "
+/* DO NOT EDIT: Automated versioning hack [Mon Feb 16 00:00:26 EST 2004] */

<p><p>--- >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