Commit e28a9f3b authored by Monty Montgomery's avatar Monty Montgomery

link the trigger slider into live peak data


git-svn-id: https://svn.xiph.org/trunk/postfish@5828 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 5e68e549
......@@ -37,6 +37,7 @@ extern int input_rate;
extern sig_atomic_t declip_converge;
GtkWidget **feedback_bars;
GtkWidget **trigger_bars;
GtkWidget *samplereadout;
GtkWidget *msreadout;
......@@ -135,6 +136,7 @@ void clippanel_create(postfish_mainpanel *mp,
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 @@ void clippanel_create(postfish_mainpanel *mp,
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_create(postfish_mainpanel *mp,
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 @@ void clippanel_feedback(void){
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_feedback(void){
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]));
}
}
......@@ -60,6 +60,7 @@ static double iterations=0.;
/* feedback! */
typedef struct declip_feedback{
feedback_generic parent_class;
double *peak;
int *clipcount;
int total;
} declip_feedback;
......@@ -69,25 +70,28 @@ static feedback_generic_pool feedpool;
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_setconvergence(double c){
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 sliding_bark_average(double *f,double *w, int n,double width){
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 @@ time_linkage *declip_read(time_linkage *in){
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 @@ time_linkage *declip_read(time_linkage *in){
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 @@ time_linkage *declip_read(time_linkage *in){
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 @@ time_linkage *declip_read(time_linkage *in){
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 @@ time_linkage *declip_read(time_linkage *in){
}
}
push_declip_feedback(count,total);
push_declip_feedback(count,peak,total);
tidy_up:
{
......
......@@ -28,3 +28,4 @@ extern int declip_setiterations(double x);
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);
......@@ -593,8 +593,10 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
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);
......
......@@ -347,7 +347,7 @@ static void draw(GtkWidget *widget,int n){
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 gboolean expose( GtkWidget *widget, GdkEventExpose *event ){
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 @@ static void size_request (GtkWidget *widget,GtkRequisition *requisition){
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 @@ static gboolean multibar_focus (GtkWidget *widget,
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 @@ static gboolean multibar_focus (GtkWidget *widget,
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 @@ static gboolean configure(GtkWidget *widget, GdkEventConfigure *event){
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 @@ GType multibar_get_type (void){
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 @@ GtkWidget* multibar_new (int n, char **labels, double *levels, int flags){
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 @@ void multibar_thumb_set(Multibar *m,double v, int n){
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;
......
......@@ -80,7 +80,7 @@ struct _MultibarClass{
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);
......
......@@ -41,7 +41,7 @@ style "slider" {
style "multibar" {
bg[NORMAL]="#80a0ff"
bg[ACTIVE]="#c0f0ff"
bg[ACTIVE]="#b0b0b0"
bg[PRELIGHT]="#c0f0ff"
fg[NORMAL]="#000000"
......
#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] */
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