Commit 0904a271 authored by Monty Montgomery's avatar Monty Montgomery

Completed addition of configurable indicator dampening in multibar.c


git-svn-id: https://svn.xiph.org/trunk/postfish@5467 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 85542359
......@@ -357,15 +357,17 @@ static void update_input_feedback(double *peak,double *rms){
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);
......
......@@ -505,8 +505,8 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
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);
......
......@@ -72,6 +72,95 @@ static void draw(GtkWidget *widget,double *lowvals, double *highvals, int n){
}
/* 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 @@ GType multibar_get_type (void){
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 @@ GtkWidget* multibar_new (int n, char **labels, double *levels){
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 @@ void multibar_set(Multibar *m,double *lo, double *hi, int n){
widget->allocation.height);
}
......@@ -25,7 +25,12 @@ typedef struct bartack {
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 @@ struct _Multibar{
bartrack *bartrackers;
int bars;
int dampen_flags;
};
struct _MultibarClass{
......@@ -54,7 +60,8 @@ struct _MultibarClass{
};
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);
......
#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] */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment