[xiph-cvs] cvs commit: postfish input.c mainpanel.c multibar.c multibar.h version.h
Monty
xiphmont at xiph.org
Tue Oct 14 19:01:47 PDT 2003
xiphmont 03/10/14 22:01:47
Modified: . input.c mainpanel.c multibar.c multibar.h version.h
Log:
Completed addition of configurable indicator dampening in multibar.c
Revision Changes Path
1.4 +10 -8 postfish/input.c
Index: input.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/input.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- input.c 14 Oct 2003 08:39:08 -0000 1.3
+++ input.c 15 Oct 2003 02:01:46 -0000 1.4
@@ -357,15 +357,17 @@
input_rms=calloc(n,sizeof(*input_rms));
input_peak=calloc(n,sizeof(*input_peak));
}
-
- if(input_feedback==0)
- for(i=0;i<n;i++)input_peak[i]*=.9;
- for(i=0;i<n;i++)input_rms[i]=.8*input_rms[i]+.2*rms[i];
- for(i=0;i<n;i++)
- if(peak[i]>input_peak[i])
- input_peak[i]=peak[i];
-
+ if(input_feedback==0){
+ memcpy(input_peak,peak,sizeof(*peak)*n);
+ memcpy(input_rms,rms,sizeof(*rms)*n);
+ }else{
+ for(i=0;i<n;i++){
+ if(peak[i]>input_peak[i])
+ input_peak[i]=peak[i];
+ input_rms[i]=.5*input_rms[i]+.5*rms[i];
+ }
+ }
input_feedback=1;
pthread_mutex_unlock(&master_mutex);
<p><p>1.10 +2 -2 postfish/mainpanel.c
Index: mainpanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/mainpanel.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- mainpanel.c 14 Oct 2003 08:39:08 -0000 1.9
+++ mainpanel.c 15 Oct 2003 02:01:46 -0000 1.10
@@ -505,8 +505,8 @@
GtkWidget *inframe=gtk_frame_new(NULL);
GtkWidget *outframe=gtk_frame_new(NULL);
- panel->inbar=multibar_new(12,labels,levels);
- panel->outbar=multibar_new(12,labels,levels);
+ panel->inbar=multibar_new(12,labels,levels, LO_ATTACK|LO_DECAY|HI_DECAY );
+ panel->outbar=multibar_new(12,labels,levels, LO_ATTACK|LO_DECAY|HI_DECAY );
gtk_container_set_border_width(GTK_CONTAINER (ttable), 3);
gtk_table_set_col_spacings(GTK_TABLE(ttable),5);
<p><p>1.5 +91 -3 postfish/multibar.c
Index: multibar.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- multibar.c 14 Oct 2003 08:39:08 -0000 1.4
+++ multibar.c 15 Oct 2003 02:01:46 -0000 1.5
@@ -72,6 +72,95 @@
}
+ /* dampen movement according to setup */
+ if(n>m->bars){
+ if(!m->bartrackers)
+ m->bartrackers=calloc(n,sizeof(*m->bartrackers));
+ else{
+ m->bartrackers=realloc(m->bartrackers,
+ n*sizeof(*m->bartrackers));
+ memset(m->bartrackers+m->bars,0,
+ sizeof(*m->bartrackers)*(n-m->bars));
+ }
+
+ for(i=m->bars;i<n;i++){
+ m->bartrackers[i].pixelposlo=pixlo[i];
+ m->bartrackers[i].pixelposhi=pixhi[i];
+ m->bartrackers[i].pixeldeltalo=0;
+ m->bartrackers[i].pixeldeltahi=0;
+ }
+
+ m->bars=n;
+ }else if(n<m->bars)
+ m->bars=n;
+
+ for(i=0;i<n;i++){
+ double trackhi=m->bartrackers[i].pixelposhi;
+ double tracklo=m->bartrackers[i].pixelposlo;
+ double delhi=m->bartrackers[i].pixeldeltahi;
+ double dello=m->bartrackers[i].pixeldeltalo;
+
+ /* hi */
+ if(pixhi[i]>trackhi){
+ /* hi attack */
+ if(m->dampen_flags & HI_ATTACK){
+ /* damp the attack */
+ if(delhi<0.)
+ delhi=1.;
+ else
+ delhi+=2;
+ pixhi[i]=trackhi+delhi;
+ }else
+ if(delhi<0.)delhi=0.;
+
+ }else{
+ /* hi decay */
+ if(m->dampen_flags & HI_DECAY){
+ /* damp the decay */
+ if(delhi>0.)
+ delhi=-1.;
+ else
+ delhi-=2;
+ pixhi[i]=trackhi+delhi;
+ }else
+ if(delhi>0.)delhi=0.;
+
+ }
+ m->bartrackers[i].pixelposhi=pixhi[i];
+ m->bartrackers[i].pixeldeltahi=delhi;
+
+ /* lo */
+ if(pixlo[i]>tracklo){
+ /* lo attack */
+ if(m->dampen_flags & LO_ATTACK){
+ /* damp the attack */
+ if(dello<0.)
+ dello=1.;
+ else
+ dello+=2;
+ pixlo[i]=tracklo+dello;
+ }else
+ if(dello<0.)dello=0.;
+
+ }else{
+ /* lo decay */
+ if(m->dampen_flags & LO_DECAY){
+ /* damp the decay */
+ if(dello>0.)
+ dello=-1.;
+ else
+ dello-=2;
+ pixlo[i]=tracklo+dello;
+ }else
+ if(dello>0.)dello=0.;
+
+ }
+ m->bartrackers[i].pixelposlo=pixlo[i];
+ m->bartrackers[i].pixeldeltalo=dello;
+
+ }
+
+ /* draw the pixel positions */
while(x<widget->allocation.width){
int r=0xffff,g=0xffff,b=0xffff;
GdkColor rgb={0,0,0,0};
@@ -289,7 +378,7 @@
return m_type;
}
-GtkWidget* multibar_new (int n, char **labels, double *levels){
+GtkWidget* multibar_new (int n, char **labels, double *levels, int flags){
int i;
GtkWidget *ret= GTK_WIDGET (g_object_new (multibar_get_type (), NULL));
Multibar *m=MULTIBAR(ret);
@@ -303,6 +392,7 @@
for(i=0;i<m->labels;i++)
m->layout[i]=gtk_widget_create_pango_layout(ret,labels[i]);
+ m->dampen_flags=flags;
return ret;
}
@@ -318,5 +408,3 @@
widget->allocation.height);
}
-
-
<p><p>1.4 +9 -2 postfish/multibar.h
Index: multibar.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- multibar.h 14 Oct 2003 22:59:12 -0000 1.3
+++ multibar.h 15 Oct 2003 02:01:46 -0000 1.4
@@ -25,7 +25,12 @@
double pixelposlo;
double pixeldeltahi;
double pixeldeltalo;
-}
+} bartrack;
+
+#define HI_ATTACK (1<<0)
+#define LO_ATTACK (1<<1)
+#define HI_DECAY (1<<2)
+#define LO_DECAY (1<<3)
struct _Multibar{
@@ -44,6 +49,7 @@
bartrack *bartrackers;
int bars;
+ int dampen_flags;
};
struct _MultibarClass{
@@ -54,7 +60,8 @@
};
GType multibar_get_type (void);
-GtkWidget* multibar_new (int n, char **labels, double *levels);
+GtkWidget* multibar_new (int n, char **labels, double *levels,
+ int flags);
void multibar_clear (Multibar *m);
void multibar_set (Multibar *m,double *lo,double *hi, int n);
<p><p>1.4 +2 -2 postfish/version.h
Index: version.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/version.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- version.h 14 Oct 2003 19:25:07 -0000 1.3
+++ version.h 15 Oct 2003 02:01:46 -0000 1.4
@@ -1,2 +1,2 @@
-#define VERSION "$Id: version.h,v 1.3 2003/10/14 19:25:07 xiphmont Exp $ "
-/* DO NOT EDIT: Automated versioning hack [Tue Oct 14 15:23:56 EDT 2003] */
+#define VERSION "$Id: version.h,v 1.4 2003/10/15 02:01:46 xiphmont Exp $ "
+/* DO NOT EDIT: Automated versioning hack [Tue Oct 14 22:00:08 EDT 2003] */
<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