[xiph-cvs] cvs commit: postfish Makefile clippanel.c declip.c input.c mainpanel.c multibar.c multibar.h output.c postfish-gtkrc subpanel.c version.h
Monty
xiphmont at xiph.org
Fri Dec 26 01:55:58 PST 2003
xiphmont 03/12/26 04:55:58
Modified: . Makefile clippanel.c declip.c input.c mainpanel.c
multibar.c multibar.h output.c postfish-gtkrc
subpanel.c version.h
Log:
Basic declipper functionality and UI in place.
Monty
Revision Changes Path
1.11 +13 -0 postfish/Makefile
Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/postfish/Makefile,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Makefile 24 Dec 2003 09:49:16 -0000 1.10
+++ Makefile 26 Dec 2003 09:55:56 -0000 1.11
@@ -4,6 +4,11 @@
CC=gcc
LD=gcc
+INSTALL=install
+PREFIX=/usr/local
+BINDIR=$PREFIX/bin
+ETCDIR=/etc
+MANDIR=$PREFIX/man
SRC = main.c mainpanel.c multibar.c readout.c input.c output.c clippanel.c declip.c \
reconstruct.c smallft.c windowbutton.c subpanel.c feedback.c
@@ -32,3 +37,11 @@
./touch-version
$(LD) $(OBJ) $(CFLAGS) -o postfish `pkg-config --libs gtk+-2.0` -lpthread -lm
+install:
+ $(INSTALL) -d -m 0755 $(BINDIR)
+ $(INSTALL) -m 0755 postfish $(BINDIR)
+ $(INSTALL) -d -m 0755 $(ETCDIR)
+ $(INSTALL) -m 0644 postfish-gtkrc $(ETCDIR)
+# $(INSTALL) -d -m 0755 $(MANDIR)
+# $(INSTALL) -d -m 0755 $(MANDIR)/man1
+# $(INSTALL) -m 0644 postfish.1 $(MANDIR)/man1
<p><p>1.5 +23 -12 postfish/clippanel.c
Index: clippanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/clippanel.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- clippanel.c 24 Dec 2003 09:49:16 -0000 1.4
+++ clippanel.c 26 Dec 2003 09:55:57 -0000 1.5
@@ -44,6 +44,8 @@
GtkWidget *creadout;
GtkWidget *ireadout;
+GtkWidget *mainpanel_inbar;
+
typedef struct {
GtkWidget *slider;
GtkWidget *readout;
@@ -87,7 +89,7 @@
char buffer[80];
double percent=gtk_range_get_value(GTK_RANGE(w));
double sigfigs=percent*.05+2.8;
- double epsilon=pow(1.,-sigfigs);
+ double epsilon=pow(10.,-sigfigs);
sprintf(buffer,"%3.1f",sigfigs);
readout_set(READOUT(creadout),buffer);
@@ -96,15 +98,15 @@
readout_set(READOUT(ireadout),buffer);
declip_setconvergence(epsilon);
- declip_setiterations(percent);
+ declip_setiterations(percent*.01);
}
void clippanel_create(postfish_mainpanel *mp,
GtkWidget *windowbutton,
GtkWidget *activebutton){
int i;
- char *labels[3]={"1%","10%","100%"};
- double levels[4]={0.,1.,10.,100.};
+ char *labels[2]={"10%","100%"};
+ double levels[3]={0.,10.,100.};
int block_choices=0;
subpanel_generic *panel=subpanel_create(mp,windowbutton,activebutton,
@@ -113,7 +115,7 @@
GtkWidget *framebox=gtk_hbox_new(1,0);
GtkWidget *blocksize_box=gtk_vbox_new(0,0);
- GtkWidget *blocksize_frame=gtk_frame_new (" filter width / approx. lowest response ");
+ GtkWidget *blocksize_frame=gtk_frame_new (" filter width ");
GtkWidget *converge_frame=gtk_frame_new (" filter convergence ");
GtkWidget *converge_box=gtk_vbox_new(0,0);
GtkWidget *channel_table=gtk_table_new(input_ch,4,0);
@@ -135,7 +137,7 @@
GtkWidget *slider=gtk_hscale_new_with_range(0,block_choices-1,1);
GtkWidget *samplelabel=gtk_label_new("window sample width");
GtkWidget *mslabel=gtk_label_new("window time width");
- GtkWidget *hzlabel=gtk_label_new("approx. lowest response");
+ GtkWidget *hzlabel=gtk_label_new("approximate lowest response");
samplereadout=readout_new("00000 ");
msreadout=readout_new("00000 ms");
hzreadout=readout_new("00000 Hz");
@@ -175,8 +177,8 @@
GtkWidget *fastlabel=gtk_label_new("fastest");
GtkWidget *qualitylabel=gtk_label_new("best");
GtkWidget *slider=gtk_hscale_new_with_range(10,200,1);
- GtkWidget *clabel=gtk_label_new("significant figure target");
- GtkWidget *ilabel=gtk_label_new("iteration bound");
+ GtkWidget *clabel=gtk_label_new("significant figures target");
+ GtkWidget *ilabel=gtk_label_new("limit predicted iterations");
creadout=readout_new("000 ");
ireadout=readout_new("000%");
@@ -217,7 +219,7 @@
GtkWidget *readout=readout_new("0.00");
GtkWidget *readoutdB=readout_new("-40 dB");
GtkWidget *barframe=gtk_frame_new(NULL);
- GtkWidget *bar=multibar_new(3,labels,levels,0);
+ GtkWidget *bar=multibar_new(2,labels,levels,HI_DECAY|ZERO_DAMP);
cs->slider=slider;
cs->readout=readout;
@@ -266,7 +268,9 @@
trigger_slider_change(NULL,cs);
}
-
+
+ mainpanel_inbar=mp->inbar;
+
}
void clippanel_feedback(void){
@@ -274,8 +278,15 @@
if(pull_declip_feedback(clip,&count)){
int i;
for(i=0;i<input_ch;i++){
- double val=clip[i]*100./count,zero=0;
- multibar_set(MULTIBAR(feedback_bars[i]),&zero,&val,1);
+ double val[2],zero[2];
+ val[0]=-1.,zero[0]=-1.;
+ val[1]=(count?clip[i]*100./count-.1:-1);
+ zero[1]=-1.;
+ multibar_set(MULTIBAR(feedback_bars[i]),zero,val,2);
+ if(clip[i]){
+ multibar_setwarn(MULTIBAR(mainpanel_inbar));
+ multibar_setwarn(MULTIBAR(feedback_bars[i]));
+ }
}
}
}
<p><p>1.3 +70 -90 postfish/declip.c
Index: declip.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/declip.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- declip.c 24 Dec 2003 09:49:16 -0000 1.2
+++ declip.c 26 Dec 2003 09:55:57 -0000 1.3
@@ -27,43 +27,11 @@
#include "smallft.h"
#include "reconstruct.h"
#include "feedback.h"
-#include <stdio.h>
extern int input_rate;
extern int input_ch;
extern int input_size;
-void _analysis(char *base,int i,double *v,int n,int bark,int dB){
- int j;
- FILE *of;
- char buffer[80];
-
- sprintf(buffer,"%s_%d.m",base,i);
- of=fopen(buffer,"w");
-
- if(!of)perror("failed to open data dump file");
-
- for(j=0;j<n;j++){
- if(bark){
- float b=toBark((4000.f*j/n)+.25);
- fprintf(of,"%f ",b);
- }else
- fprintf(of,"%f ",(double)j);
-
- if(dB){
- if(j==0||j==n-1)
- fprintf(of,"%f\n",todB(v[j]));
- else{
- fprintf(of,"%f\n",todB(hypot(v[j],v[j+1])));
- j++;
- }
- }else{
- fprintf(of,"%f\n",v[j]);
- }
- }
- fclose(of);
-}
-
/* accessed only in playback thread/setup */
static drft_lookup fft;
static int blocksize=0;
@@ -258,11 +226,11 @@
if(data[i]>=trigger || data[i]<=-trigger){
flag[i]=1;
count++;
- *runningcount++;
}
}
*runningtotal+=blocksize*3/4;
+ *runningcount+=count;
if(declip_active){
@@ -279,14 +247,14 @@
}
if(iterbound<20)iterbound=20;
- reconstruct(&fft,data,freq,flag,epsilon*count,iterbound,blocksize);
+ if(count)reconstruct(&fft,data,freq,flag,epsilon*count,iterbound,blocksize);
if(out)
for(i=0;i<blocksize/2;i++)
out[i]=lap[i]+data[i]*window[i];
for(i=blocksize/2,j=0;i<blocksize;i++)
- lap[j]=data[i]*window[i];
+ lap[j++]=data[i]*window[i];
}else{
@@ -295,15 +263,15 @@
out[i]=data[i];
for(i=blocksize/2,j=0;i<blocksize;i++)
- lap[j]=data[i]*window[i]*window[i];
-
+ lap[j++]=data[i]*window[i]*window[i];
}
+ for(i=blocksize/2;i<input_size;i++)
+ lap[i]=0.;
}
/* called only by playback thread */
time_linkage *declip_read(time_linkage *in){
int i;
- double work[blocksize];
double local_trigger[input_ch];
int total=0;
int count[input_ch];
@@ -328,83 +296,95 @@
}
blocksize=pending_blocksize;
- widthlookup=malloc((blocksize>>1)*sizeof(*widthlookup));
+ lopad=1-rint(fromBark(toBark(0.)-width)*blocksize/input_rate);
+ hipad=rint(fromBark(toBark(input_rate*.5)+width)*blocksize/input_rate)+lopad;
+ widthlookup=malloc((hipad+1)*sizeof(*widthlookup));
for(i=0;i<blocksize/2;i++){
double bark=toBark(input_rate*i/blocksize);
int hi=rint(fromBark(bark-width)*blocksize/input_rate)-1+lopad;
int lo=rint(fromBark(bark+width)*blocksize/input_rate)+1+lopad;
-
- if(hi<0 || lo<0 || hi>65535 || lo<65535) return 0;
widthlookup[i]=(hi<<16)+lo;
}
- lopad=1-rint(fromBark(toBark(0.)-width)*blocksize/input_rate);
- hipad=rint(fromBark(toBark(input_rate*.5)+width)*blocksize/input_rate)+lopad;
drft_init(&fft,blocksize);
window=malloc(blocksize*sizeof(*window));
for(i=0;i<blocksize/8;i++) window[i]=0.;
- for(;i<blocksize*3/8;i++) window[i]=sin( (double)(i-blocksize/8)/blocksize*M_PIl );
+ for(;i<blocksize*3/8;i++) window[i]=sin( (double)(i-blocksize/8)/blocksize*M_PIl*2. );
for(;i<blocksize*5/8;i++) window[i]=1.;
- for(;i<blocksize*7/8;i++) window[i]=sin( (double)(blocksize*7/8-i)/blocksize*M_PIl );
+ for(;i<blocksize*7/8;i++) window[i]=sin( (double)(blocksize*7/8-i)/blocksize*M_PIl*2. );
for(;i<blocksize;i++) window[i]=0.;
for(i=0;i<blocksize;i++) window[i]*=window[i];
- for(i=0;i<blocksize;i++) window[i]=sin(window[i]*M_PIl);
+ for(i=0;i<blocksize;i++) window[i]=sin(window[i]*M_PIl*.5);
}
-
- switch(fillstate){
- case 0: /* prime the lapping and cache */
- for(i=0;i<input_ch;i++){
- int j;
- double *temp=in->data[i];
- total=0;
- memset(work,0,sizeof(*work)*blocksize/2);
- memcpy(work+blocksize/2,temp,sizeof(*work)*blocksize/2);
- declip(work,lap[i],0,blocksize,
- local_trigger[i],local_convergence,local_iterations,
- &total,count+i);
-
- memset(cache[i],0,sizeof(**cache)*input_size);
- in->data[i]=cache[i];
- cache[i]=temp;
- }
- cache_samples=in->samples;
- fillstate=1;
- if(in->samples==in->size)return 0;
- in->samples=0;
- /* fall through */
- case 1: /* nominal processing */
- for(i=0;i<input_ch;i++){
- double *temp=cache[i];
- int j;
- total=0;
- for(j=0;j+blocksize<out.size;j+=blocksize/2){
- memcpy(work,temp+j,sizeof(*work)*blocksize);
+ {
+ double work[blocksize];
+
+ switch(fillstate){
+ case 0: /* prime the lapping and cache */
+ for(i=0;i<input_ch;i++){
+ int j;
+ double *temp=in->data[i];
+ total=0;
+ memset(work,0,sizeof(*work)*blocksize/2);
+ memcpy(work+blocksize/2,temp,sizeof(*work)*blocksize/2);
+ declip(work,lap[i],0,blocksize,
+ local_trigger[i],local_convergence,local_iterations,
+ &total,count+i);
+
+ memset(cache[i],0,sizeof(**cache)*input_size);
+ in->data[i]=cache[i];
+ cache[i]=temp;
+ }
+ cache_samples=in->samples;
+ fillstate=1;
+ out.samples=0;
+ if(in->samples==in->size)goto tidy_up;
+
+ for(i=0;i<input_ch;i++)
+ memset(in->data[i],0,sizeof(**in->data)*in->size);
+ in->samples=0;
+ /* fall through */
+ case 1: /* nominal processing */
+ for(i=0;i<input_ch;i++){
+ double *temp=cache[i];
+ int j;
+ total=0;
+ for(j=0;j+blocksize<=out.size;j+=blocksize/2){
+ memcpy(work,temp+j,sizeof(*work)*blocksize);
+ declip(work,lap[i],out.data[i]+j,blocksize,
+ local_trigger[i],local_convergence,local_iterations,
+ &total,count+i);
+ }
+ memcpy(work,temp+j,sizeof(*work)*blocksize/2);
+ memcpy(work+blocksize/2,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);
+
+ cache[i]=in->data[i];
+ in->data[i]=temp;
}
- memcpy(work,temp+j,sizeof(*work)*blocksize/2);
- memcpy(work+blocksize/2,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);
-
- in->data[i]=cache[i];
- cache[i]=temp;
+ out.samples=cache_samples;
+ cache_samples=in->samples;
+ if(out.samples<out.size)fillstate=2;
+ break;
+ case 2: /* we've pushed out EOF already */
+ out.samples=0;
}
- out.samples=cache_samples;
- cache_samples=in->samples;
- if(out.samples<out.size)fillstate=2;
- break;
- case 2: /* we've pushed out EOF already */
- return 0;
}
- /* we're returning data, push feedback */
push_declip_feedback(count,total);
+ tidy_up:
+ {
+ int tozero=out.size-out.samples;
+ if(tozero)
+ for(i=0;i<out.channels;i++)
+ memset(out.data[i]+out.samples,0,sizeof(**out.data)*tozero);
+ }
+
return &out;
}
<p><p>1.13 +10 -2 postfish/input.c
Index: input.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/input.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- input.c 24 Dec 2003 09:49:16 -0000 1.12
+++ input.c 26 Dec 2003 09:55:57 -0000 1.13
@@ -439,14 +439,14 @@
cursor>=current_file_entry->end &&
current_file_entry->end!=-1){
pthread_mutex_unlock(&master_mutex);
- return &out; /* EOF */
+ goto tidy_up;
}
/* the streaming case */
if(feof(current_file_entry->f) &&
current_file_entry_number+1>=file_entries){
pthread_mutex_unlock(&master_mutex);
- return &out;
+ goto tidy_up;
}
pthread_mutex_unlock(&master_mutex);
@@ -550,6 +550,14 @@
push_input_feedback(peak,rms,cursor);
+ tidy_up:
+ {
+ int tozero=out.size-out.samples;
+ if(tozero)
+ for(j=0;j<out.channels;j++)
+ memset(out.data[j]+out.samples,0,sizeof(**out.data)*tozero);
+ }
+
return &out;
}
<p><p>1.25 +52 -47 postfish/mainpanel.c
Index: mainpanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/mainpanel.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- mainpanel.c 24 Dec 2003 09:49:16 -0000 1.24
+++ mainpanel.c 26 Dec 2003 09:55:57 -0000 1.25
@@ -581,43 +581,6 @@
gtk_widget_set_name(panel->leftback,"winpanel");
/* left side of main panel */
-
- //gtk_container_set_border_width (GTK_CONTAINER (panel->leftframe), 3);
- gtk_container_set_border_width (GTK_CONTAINER (panel->wintable), 3);
- gtk_frame_set_shadow_type(GTK_FRAME(panel->leftframe),GTK_SHADOW_ETCHED_IN);
- gtk_container_add(GTK_CONTAINER(panel->leftframe),panel->wintable);
-
- gtk_table_set_row_spacings(GTK_TABLE(panel->wintable),1);
-
- {
- GtkWidget *temp=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(temp),"<span size=\"x-small\">visible</span>");
- gtk_misc_set_alignment(GTK_MISC(temp),0,.5);
- gtk_table_attach_defaults(GTK_TABLE(panel->wintable),temp,0,1,0,1);
-
- temp=gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(temp),"<span size=\"x-small\">active</span>");
- gtk_misc_set_alignment(GTK_MISC(temp),1,.5);
- gtk_table_attach_defaults(GTK_TABLE(panel->wintable),temp,1,2,0,1);
- }
-
- mainpanel_panelentry(panel,"_Declip ","[d]",0,clippanel_create);
- mainpanel_panelentry(panel,"Cross_Talk ","[t]",1,0);
- mainpanel_panelentry(panel,"_Noise Filter ","[n]",2,0);
- mainpanel_panelentry(panel,"_Equalizer ","[e]",3,0);
- mainpanel_panelentry(panel,"_Compander ","[c]",4,0);
- mainpanel_panelentry(panel,"_Limiter ","[l]",5,0);
- mainpanel_panelentry(panel,"_Output Cal. ","[o]",6,0);
-
-
- g_signal_connect (G_OBJECT (panel->toplevel), "delete_event",
- G_CALLBACK (shutdown), NULL);
-
- g_signal_connect (G_OBJECT (panel->toplevel), "delete_event",
- G_CALLBACK (shutdown), NULL);
-
-
- /* right side of main panel */
{
char *labels[12]={"-96","-72","-60","-48","-36","-24",
"-16","-8","-3","0","+3","+6"};
@@ -844,6 +807,43 @@
}
+ /* right side of main panel */
+
+ //gtk_container_set_border_width (GTK_CONTAINER (panel->leftframe), 3);
+ gtk_container_set_border_width (GTK_CONTAINER (panel->wintable), 3);
+ gtk_frame_set_shadow_type(GTK_FRAME(panel->leftframe),GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(panel->leftframe),panel->wintable);
+
+ gtk_table_set_row_spacings(GTK_TABLE(panel->wintable),1);
+
+ {
+ GtkWidget *temp=gtk_label_new(NULL);
+ gtk_label_set_markup(GTK_LABEL(temp),"<span size=\"x-small\">visible</span>");
+ gtk_misc_set_alignment(GTK_MISC(temp),0,.5);
+ gtk_table_attach_defaults(GTK_TABLE(panel->wintable),temp,0,1,0,1);
+
+ temp=gtk_label_new(NULL);
+ gtk_label_set_markup(GTK_LABEL(temp),"<span size=\"x-small\">active</span>");
+ gtk_misc_set_alignment(GTK_MISC(temp),1,.5);
+ gtk_table_attach_defaults(GTK_TABLE(panel->wintable),temp,1,2,0,1);
+ }
+
+ mainpanel_panelentry(panel,"_Declip ","[d]",0,clippanel_create);
+ mainpanel_panelentry(panel,"Cross_Talk ","[t]",1,0);
+ mainpanel_panelentry(panel,"_Noise Filter ","[n]",2,0);
+ mainpanel_panelentry(panel,"_Equalizer ","[e]",3,0);
+ mainpanel_panelentry(panel,"_Compander ","[c]",4,0);
+ mainpanel_panelentry(panel,"_Limiter ","[l]",5,0);
+ mainpanel_panelentry(panel,"_Output Cal. ","[o]",6,0);
+
+
+ g_signal_connect (G_OBJECT (panel->toplevel), "delete_event",
+ G_CALLBACK (shutdown), NULL);
+
+ g_signal_connect (G_OBJECT (panel->toplevel), "delete_event",
+ G_CALLBACK (shutdown), NULL);
+
+
gtk_widget_show_all(panel->toplevel);
gtk_window_set_resizable(GTK_WINDOW(panel->toplevel),0);
@@ -865,9 +865,11 @@
int n=input_ch+2;
double *rms=alloca(sizeof(*rms)*(input_ch+2));
double *peak=alloca(sizeof(*peak)*(input_ch+2));
- if(pull_input_feedback(peak,rms,&time_cursor)){
+
+ if(pull_output_feedback(peak,rms)){
char buffer[14];
int i;
+
for(i=0;i<n;i++){
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->channelshow[i]))){
peak[i]=todB(peak[i]);
@@ -876,15 +878,13 @@
peak[i]=-400;
rms[i]=-400;
}
+
+ if(i<input_ch && peak[i]>=0.)multibar_setwarn(MULTIBAR(panel->outbar));
}
- multibar_set(MULTIBAR(panel->inbar),rms,peak,n);
- input_cursor_to_time(time_cursor,buffer);
- readout_set(READOUT(panel->cue),buffer);
-
- clippanel_feedback();
+ multibar_set(MULTIBAR(panel->outbar),rms,peak,n);
- if(pull_output_feedback(peak,rms)){
+ if(pull_input_feedback(peak,rms,&time_cursor)){
for(i=0;i<n;i++){
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->channelshow[i]))){
peak[i]=todB(peak[i]);
@@ -895,13 +895,16 @@
}
}
- multibar_set(MULTIBAR(panel->outbar),rms,peak,n);
+ multibar_set(MULTIBAR(panel->inbar),rms,peak,n);
+ input_cursor_to_time(time_cursor,buffer);
+ readout_set(READOUT(panel->cue),buffer);
}
-
+ clippanel_feedback();
+
}
}
-
+
}
static gboolean async_event_handle(GIOChannel *channel,
@@ -933,6 +936,8 @@
strcat(homerc,rcfile);
gtk_rc_add_default_file(homerc);
}
+ gtk_rc_add_default_file(".postfish-gtkrc");
+ gtk_rc_add_default_file("postfish-gtkrc");
gtk_init (&argc, &argv);
memset(labels,0,sizeof(labels));
<p><p>1.14 +173 -139 postfish/multibar.c
Index: multibar.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- multibar.c 24 Dec 2003 09:49:16 -0000 1.13
+++ multibar.c 26 Dec 2003 09:55:57 -0000 1.14
@@ -2,13 +2,13 @@
#include <stdlib.h>
#include "multibar.h"
-static double compute_dampening(double target,double current,double delta){
+static double compute_dampening(double target,double current,double delta,int zerodamp){
double raw_delta=target-current;
-
- if(target<0){
+
+ if(target<0 && !zerodamp){
if(current>0)
raw_delta=target-current;
- }else if(current<0){
+ }else if(current<0 && !zerodamp){
raw_delta=target-current;
}else if(raw_delta<0){
if(delta>0){
@@ -28,16 +28,11 @@
/* call me roughly 10-20fps */
-static void draw(GtkWidget *widget,double *lowvals, double *highvals, int n){
+static void compute(GtkWidget *widget,double *lowvals, double *highvals, int n){
int i,j;
Multibar *m=MULTIBAR(widget);
double max=-400;
- if(!m->boxcolor){
- m->boxcolor=gdk_gc_new(m->backing);
- gdk_gc_copy(m->boxcolor,widget->style->black_gc);
- }
-
if(n>m->bars){
if(!m->bartrackers)
m->bartrackers=calloc(n,sizeof(*m->bartrackers));
@@ -59,12 +54,6 @@
}else if(n<m->bars)
m->bars=n;
- for(i=0;i<n;i++)
- if(highvals[i]>=0.){
- m->clipdelay=15*10; /* ~ ten second hold */
- break;
- }
-
for(i=0;i<n;i++)
if(highvals[i]>max)max=highvals[i];
@@ -88,7 +77,6 @@
}
{
- int x=-1;
int *pixhi=alloca(n*sizeof(*pixhi));
int *pixlo=alloca(n*sizeof(*pixlo));
@@ -130,7 +118,7 @@
double dello=m->bartrackers[i].pixeldeltalo;
/* hi */
- delhi = compute_dampening(pixhi[i],trackhi,delhi);
+ delhi = compute_dampening(pixhi[i],trackhi,delhi,m->dampen_flags & ZERO_DAMP);
if(pixhi[i]>trackhi){
if(m->dampen_flags & HI_ATTACK)pixhi[i]=trackhi+delhi;
@@ -141,7 +129,7 @@
m->bartrackers[i].pixeldeltahi=delhi;
/* lo */
- dello = compute_dampening(pixlo[i],tracklo,dello);
+ dello = compute_dampening(pixlo[i],tracklo,dello,m->dampen_flags & ZERO_DAMP);
if(pixlo[i]>tracklo){
if(m->dampen_flags & LO_ATTACK)pixlo[i]=tracklo+dello;
}else{
@@ -152,129 +140,143 @@
}
- /* draw the pixel positions */
- while(x<widget->allocation.width){
- int r=0xffff,g=0xffff,b=0xffff;
- GdkColor rgb={0,0,0,0};
- int next=widget->allocation.width;
- for(i=0;i<n;i++){
- if(pixlo[i]>x && pixlo[i]<next)next=pixlo[i];
- if(pixhi[i]>x && pixhi[i]<next)next=pixhi[i];
- }
+ }
+}
+
+static void draw(GtkWidget *widget,int n){
+ int i,j,x=-1;
+ Multibar *m=MULTIBAR(widget);
+
+ if(!m->boxcolor){
+ m->boxcolor=gdk_gc_new(m->backing);
+ gdk_gc_copy(m->boxcolor,widget->style->black_gc);
+ }
+
+ /* draw the pixel positions */
+ while(x<widget->allocation.width){
+ int r=0xffff,g=0xffff,b=0xffff;
+ GdkColor rgb={0,0,0,0};
+ int next=widget->allocation.width;
+ for(i=0;i<n;i++){
+ if(m->bartrackers[i].pixelposlo>x && m->bartrackers[i].pixelposlo<next)
+ next=m->bartrackers[i].pixelposlo;
+ if(m->bartrackers[i].pixelposhi>x && m->bartrackers[i].pixelposhi<next)
+ next=m->bartrackers[i].pixelposhi;
+ }
- for(i=0;i<n;i++){
- if(pixlo[i]<=x && pixhi[i]>=next){
- switch(i%8){
- case 0:
- r*=.65;
- g*=.65;
- b*=.65;
- break;
- case 1:
- r*=1.;
- g*=.5;
- b*=.5;
- break;
- case 2:
- r*=.6;
- g*=.6;
- b*=1.;
- break;
- case 3:
- r*=.4;
- g*=.9;
- b*=.4;
- break;
- case 4:
- r*=.7;
- g*=.6;
- b*=.3;
- break;
- case 5:
- r*=.7;
- g*=.4;
- b*=.8;
- break;
- case 6:
- r*=.3;
- g*=.7;
- b*=.7;
- break;
- case 7:
- r*=.4;
- g*=.4;
- b*=.4;
- break;
- }
+ for(i=0;i<n;i++){
+ if(m->bartrackers[i].pixelposlo<=x && m->bartrackers[i].pixelposhi>=next){
+ switch(i%8){
+ case 0:
+ r*=.65;
+ g*=.65;
+ b*=.65;
+ break;
+ case 1:
+ r*=1.;
+ g*=.5;
+ b*=.5;
+ break;
+ case 2:
+ r*=.6;
+ g*=.6;
+ b*=1.;
+ break;
+ case 3:
+ r*=.4;
+ g*=.9;
+ b*=.4;
+ break;
+ case 4:
+ r*=.7;
+ g*=.6;
+ b*=.3;
+ break;
+ case 5:
+ r*=.7;
+ g*=.4;
+ b*=.8;
+ break;
+ case 6:
+ r*=.3;
+ g*=.7;
+ b*=.7;
+ break;
+ case 7:
+ r*=.4;
+ g*=.4;
+ b*=.4;
+ break;
}
}
- rgb.red=r;
- rgb.green=g;
- rgb.blue=b;
- gdk_gc_set_rgb_fg_color(m->boxcolor,&rgb);
- gdk_draw_rectangle(m->backing,m->boxcolor,1,x+1,1,next-x,widget->allocation.height-3);
-
- x=next;
}
+ rgb.red=r;
+ rgb.green=g;
+ rgb.blue=b;
+ gdk_gc_set_rgb_fg_color(m->boxcolor,&rgb);
+ gdk_draw_rectangle(m->backing,m->boxcolor,1,x+1,1,next-x,widget->allocation.height-3);
+
+ x=next;
+ }
-
- if(m->clipdelay){
- gdk_draw_line (m->backing,
- widget->style->fg_gc[1],
- 0, 0, widget->allocation.width-1, 0);
-
- gdk_draw_line (m->backing,
- widget->style->fg_gc[1],
- 0, widget->allocation.height-2,
- widget->allocation.width-1, widget->allocation.height-2);
- }else{
- gdk_draw_line (m->backing,
- widget->style->white_gc,
- 0, 0, widget->allocation.width-1, 0);
-
- gdk_draw_line (m->backing,
- widget->style->white_gc,
- 0, widget->allocation.height-2,
- widget->allocation.width-1, widget->allocation.height-2);
- }
+
+ if(m->clipdelay){
+ gdk_draw_line (m->backing,
+ widget->style->fg_gc[1],
+ 0, 0, widget->allocation.width-1, 0);
- /* peak follower */
- {
- int x=-10;
- for(j=0;j<=m->labels+1;j++)
- if(m->peak>=m->levels[j]){
- if(m->peak<=m->levels[j+1]){
- double del=(m->peak-m->levels[j])/(m->levels[j+1]-m->levels[j]);
- x=(j+del)/m->labels*widget->allocation.width;
- break;
- }else if (j==m->labels){
- x=widget->allocation.width+1;
- }
- }else
+ gdk_draw_line (m->backing,
+ widget->style->fg_gc[1],
+ 0, widget->allocation.height-2,
+ widget->allocation.width-1, widget->allocation.height-2);
+ }else{
+ gdk_draw_line (m->backing,
+ widget->style->white_gc,
+ 0, 0, widget->allocation.width-1, 0);
+
+ gdk_draw_line (m->backing,
+ widget->style->white_gc,
+ 0, widget->allocation.height-2,
+ widget->allocation.width-1, widget->allocation.height-2);
+ }
+
+ /* peak follower */
+ {
+ int x=-10;
+ for(j=0;j<=m->labels+1;j++)
+ if(m->peak>=m->levels[j]){
+ if(m->peak<=m->levels[j+1]){
+ double del=(m->peak-m->levels[j])/(m->levels[j+1]-m->levels[j]);
+ x=(j+del)/m->labels*widget->allocation.width;
break;
+ }else if (j==m->labels){
+ x=widget->allocation.width+1;
+ }
+ }else
+ break;
+
+ for(j=0;j<n;j++)
+ if(x<m->bartrackers[j].pixelposhi)
+ x=m->bartrackers[j].pixelposhi;
+
+ {
+ int y=widget->allocation.height-1;
- for(j=0;j<n;j++)
- if(x<pixhi[j])x=pixhi[j];
-
- {
- int y=widget->allocation.height-1;
-
- gdk_draw_line(m->backing,widget->style->fg_gc[0],
- x-3,0,x+3,0);
- gdk_draw_line(m->backing,widget->style->fg_gc[0],
- x-2,1,x+2,1);
- gdk_draw_line(m->backing,widget->style->fg_gc[0],
- x-1,2,x+1,2);
- gdk_draw_line(m->backing,widget->style->fg_gc[0],
- x-3,y-1,x+3,y-1);
- gdk_draw_line(m->backing,widget->style->fg_gc[0],
- x-2,y-2,x+2,y-2);
- gdk_draw_line(m->backing,widget->style->fg_gc[0],
- x-1,y-3,x+1,y-3);
+ gdk_draw_line(m->backing,widget->style->fg_gc[0],
+ x-3,0,x+3,0);
+ gdk_draw_line(m->backing,widget->style->fg_gc[0],
+ x-2,1,x+2,1);
+ gdk_draw_line(m->backing,widget->style->fg_gc[0],
+ x-1,2,x+1,2);
+ gdk_draw_line(m->backing,widget->style->fg_gc[0],
+ x-3,y-1,x+3,y-1);
+ gdk_draw_line(m->backing,widget->style->fg_gc[0],
+ x-2,y-2,x+2,y-2);
+ gdk_draw_line(m->backing,widget->style->fg_gc[0],
+ x-1,y-3,x+1,y-3);
- gdk_draw_line(m->backing,widget->style->fg_gc[1],
- x,1,x,y-2);
- }
+ gdk_draw_line(m->backing,widget->style->fg_gc[1],
+ x,1,x,y-2);
}
}
@@ -285,11 +287,11 @@
int gc=0;
if(m->levels[i+1]>=0)gc=1;
-
+
gdk_draw_line (m->backing,
widget->style->text_gc[gc],
x, 0, x, y);
-
+
pango_layout_get_pixel_size(m->layout[i],&px,&py);
x-=px+2;
y-=py;
@@ -301,7 +303,6 @@
m->layout[i]);
}
-
}
static gboolean configure(GtkWidget *widget, GdkEventConfigure *event){
@@ -317,7 +318,15 @@
gdk_draw_rectangle(m->backing,widget->style->white_gc,1,0,0,widget->allocation.width,
widget->allocation.height);
- draw(widget,0,0,0);
+ compute(widget,0,0,0);
+ draw(widget,0);
+ gdk_draw_drawable(widget->window,
+ widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+ m->backing,
+ 0, 0,
+ 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
return TRUE;
}
@@ -410,7 +419,13 @@
void multibar_set(Multibar *m,double *lo, double *hi, int n){
GtkWidget *widget=GTK_WIDGET(m);
- draw(widget,lo,hi,n);
+ compute(widget,lo,hi,n);
+
+ if(!GTK_WIDGET_DRAWABLE(widget))return;
+ if(!GDK_IS_DRAWABLE(widget->window))return;
+ if(!GDK_IS_DRAWABLE(m->backing))return;
+
+ draw(widget,n);
gdk_draw_drawable(widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
m->backing,
@@ -418,7 +433,6 @@
0, 0,
widget->allocation.width,
widget->allocation.height);
-
}
void multibar_reset(Multibar *m){
@@ -428,3 +442,23 @@
m->clipdelay=0;
multibar_set(m,NULL,NULL,0);
}
+
+void multibar_setwarn(Multibar *m){
+ GtkWidget *widget=GTK_WIDGET(m);
+ if(!m->clipdelay){
+ m->clipdelay=15*10;
+
+ if(!GTK_WIDGET_DRAWABLE(widget))return;
+ if(!GDK_IS_DRAWABLE(widget->window))return;
+ if(!GDK_IS_DRAWABLE(m->backing))return;
+ draw(widget,m->bars);
+ gdk_draw_drawable(widget->window,
+ widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+ m->backing,
+ 0, 0,
+ 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
+ }else
+ m->clipdelay=15*10; /* ~ ten second hold */
+}
<p><p>1.7 +2 -0 postfish/multibar.h
Index: multibar.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/multibar.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- multibar.h 16 Oct 2003 23:10:16 -0000 1.6
+++ multibar.h 26 Dec 2003 09:55:57 -0000 1.7
@@ -31,6 +31,7 @@
#define LO_ATTACK (1<<1)
#define HI_DECAY (1<<2)
#define LO_DECAY (1<<3)
+#define ZERO_DAMP (1<<4)
struct _Multibar{
@@ -65,6 +66,7 @@
int flags);
void multibar_clear (Multibar *m);
void multibar_set (Multibar *m,double *lo,double *hi, int n);
+void multibar_setwarn (Multibar *m);
void multibar_reset (Multibar *m);
G_END_DECLS
<p><p>1.11 +42 -38 postfish/output.c
Index: output.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/output.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- output.c 24 Dec 2003 09:49:16 -0000 1.10
+++ output.c 26 Dec 2003 09:55:57 -0000 1.11
@@ -124,7 +124,7 @@
return 0;
}
-static FILE *playback_startup(int outfileno, int ch, int r){
+static FILE *playback_startup(int outfileno, int ch, int r, int *bep){
FILE *playback_fd=NULL;
int format=AFMT_S16_NE;
int rate=r,channels=ch,ret;
@@ -168,6 +168,7 @@
}
}else{
WriteWav(playback_fd,ch,r,16,-1);
+ *bep=0;
}
return playback_fd;
@@ -180,7 +181,8 @@
int bigendianp=(AFMT_S16_NE==AFMT_S16_BE?1:0);
FILE *playback_fd=NULL;
int setupp=0;
- time_linkage *ret;
+ time_linkage *link;
+ int result;
off_t count=0;
long last=-1;
@@ -200,34 +202,37 @@
if(playback_exit)break;
/* get data */
- if(!(ret=input_read()))break;
- //!(ret=declip_read()))break;
-
+ link=input_read();
+ result=link->samples;
+ link=declip_read(link);
+ result|=link->samples;
+
+ if(!result)break;
/************/
-
-
-
+
+
+
/* temporary; this would be frequency domain in the finished postfish */
- if(ret && ret->samples>0){
+ if(link->samples>0){
double scale=fromdB(master_att/10.);
- for(i=0;i<ret->samples;i++)
- for(j=0;j<ret->channels;j++)
- ret->data[j][i]*=scale;
+ for(i=0;i<link->samples;i++)
+ for(j=0;j<link->channels;j++)
+ link->data[j][i]*=scale;
}
/************/
- if(ret && ret->samples>0){
+ if(link->samples>0){
memset(rms,0,sizeof(*rms)*(input_ch+2));
memset(peak,0,sizeof(*peak)*(input_ch+2));
- ch=ret->channels;
- rate=ret->rate;
-
+ ch=link->channels;
+ rate=link->rate;
+
/* lazy playbak setup; we couldn't do it until we had rate and
channel information from the pipeline */
if(!setupp){
- playback_fd=playback_startup(outfileno,ch,rate);
+ playback_fd=playback_startup(outfileno,ch,rate,&bigendianp);
if(!playback_fd){
playback_active=0;
playback_exit=0;
@@ -235,21 +240,21 @@
}
setupp=1;
}
-
- if(audiobufsize<ret->channels*ret->samples*2){
- audiobufsize=ret->channels*ret->samples*2;
+
+ if(audiobufsize<link->channels*link->samples*2){
+ audiobufsize=link->channels*link->samples*2;
audiobuf=realloc(audiobuf,sizeof(*audiobuf)*audiobufsize);
}
/* final limiting and conversion */
- for(k=0,i=0;i<ret->samples;i++){
+ for(k=0,i=0;i<link->samples;i++){
double mean=0.;
double div=0.;
double divrms=0.;
-
- for(j=0;j<ret->channels;j++){
- double dval=ret->data[j][i];
+
+ for(j=0;j<link->channels;j++){
+ double dval=link->data[j][i];
int val=rint(dval*32767.);
if(val>32767)val=32767;
if(val<-32768)val=-32768;
@@ -260,41 +265,40 @@
audiobuf[k++]=val;
audiobuf[k++]=val>>8;
}
-
+
if(fabs(dval)>peak[j])peak[j]=fabs(dval);
rms[j]+= dval*dval;
mean+=dval;
-
+
}
-
+
/* mean */
mean/=j;
if(fabs(mean)>peak[input_ch])peak[input_ch]=fabs(mean);
rms[input_ch]+= mean*mean;
-
+
/* div */
- for(j=0;j<ret->channels;j++){
- double dval=mean-ret->data[j][i];
+ for(j=0;j<link->channels;j++){
+ double dval=mean-link->data[j][i];
if(fabs(dval)>peak[input_ch+1])peak[input_ch+1]=fabs(dval);
divrms+=dval*dval;
}
- rms[input_ch+1]+=divrms/ret->channels;
-
+ rms[input_ch+1]+=divrms/link->channels;
+
}
for(j=0;j<input_ch+2;j++){
- rms[j]/=ret->samples;
+ rms[j]/=link->samples;
rms[j]=sqrt(rms[j]);
}
- count+=fwrite(audiobuf,1,ret->channels*ret->samples*2,playback_fd);
-
+ count+=fwrite(audiobuf,1,link->channels*link->samples*2,playback_fd);
+
/* inform Lord Vader his shuttle is ready */
push_output_feedback(peak,rms);
write(eventpipe[1],"",1);
-
- }else
- break; /* eof */
+
+ }
}
if(playback_fd){
<p><p>1.2 +40 -6 postfish/postfish-gtkrc
Index: postfish-gtkrc
===================================================================
RCS file: /usr/local/cvsroot/postfish/postfish-gtkrc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- postfish-gtkrc 20 Dec 2003 11:24:17 -0000 1.1
+++ postfish-gtkrc 26 Dec 2003 09:55:57 -0000 1.2
@@ -3,12 +3,25 @@
bg[ACTIVE]="#c0f0ff"
bg[PRELIGHT]="#c0f0ff"
- font_name = "sans 8"
+ font_name = "sans 8"
+ GtkButton::relief = none
+
GtkButton::focus-padding = 0
GtkButton::focus-line-width = 1
GtkButton::interior-focus = 0
}
+style "panel-label" {
+ font_name = "sans bold 11"
+}
+
+style "frame-label" {
+ font_name = "sans bold 10"
+}
+style "frame-text" {
+ font_name = "sans 9"
+}
+
style "check-poppy" {
bg[NORMAL]="#80a0ff"
@@ -33,13 +46,21 @@
font_name = "sans 8"
}
+style "clipbar" {
+ fg[NORMAL]="#404040"
+ fg[ACTIVE]="#ff8080"
+ text[NORMAL]="#c0c0d0"
+ text[ACTIVE]="#c0c0d0"
+ font_name = "sans 8"
+}
+
style "readout" {
base[NORMAL]="#ffffff"
base[ACTIVE]="#ffffff"
bg[NORMAL]="#ffffff"
bg[ACTIVE]="#ffffff"
- font_name = "fixed"
+ font_name = "fixed 8"
GtkMisc::xpad = 10
GtkMisc::xalign = 1.0
GtkWidget::width-request=100
@@ -95,17 +116,30 @@
widget "*.color2" style "mid"
widget "*.color3" style "side"
+widget "*.panelbox*" style "darkpanel"
widget "*.winpanel" style "darkpanel"
+widget "*.choiceframe.*" style "frame-text"
+widget "*.GtkFrame.GtkLabel" style "frame-label"
+
widget "*.Readout*" style "readout"
widget "*.GtkEntry" style "readout"
widget "*.GtkHScale" style "slider"
-widget "*.GtkToggleButton.*" style "button-poppy"
-widget "*.GtkToggleButton" style "button-poppy"
-widget "*.GtkButton.*" style "button-poppy"
+widget "*.GtkToggleButton*" style "button-poppy"
widget "*.reset*" style "quitbutton"
-widget "*.GtkButton" style "button-poppy"
+widget "*.GtkButton*" style "button-poppy"
widget "*.GtkCheckButton" style "check-poppy"
+widget "*.Windowbutton*" style "button-poppy"
widget "*.quitbutton" style "quitbutton"
widget "*.quitbutton.GtkLabel" style "quitbutton"
+
+widget "*.panelbutton*" style "button-poppy"
+widget "*.panelbutton*.GtkLabel" style "panel-label"
widget "*.Multibar*" style "multibar"
+
+widget "*.clipbar*" style "clipbar"
+
+
+
+
+
<p><p>1.2 +21 -0 postfish/subpanel.c
Index: subpanel.c
===================================================================
RCS file: /usr/local/cvsroot/postfish/subpanel.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- subpanel.c 24 Dec 2003 09:49:16 -0000 1.1
+++ subpanel.c 26 Dec 2003 09:55:57 -0000 1.2
@@ -72,6 +72,23 @@
return FALSE;
}
+static gboolean rebind_space(GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer in){
+ /* do not capture Alt accellerators */
+ if(event->state&GDK_MOD1_MASK) return FALSE;
+ if(event->state&GDK_CONTROL_MASK) return FALSE;
+
+ if(event->keyval==GDK_space){
+ subpanel_generic *p=in;
+ GdkEvent copy=*(GdkEvent *)event;
+ copy.any.window=p->mainpanel->toplevel->window;
+ gtk_main_do_event((GdkEvent *)(©));
+ return TRUE;
+ }
+ return FALSE;
+}
+
static gboolean forward_events(GtkWidget *widget,
GdkEvent *event,
gpointer in){
@@ -130,6 +147,10 @@
gtk_frame_set_label_widget(GTK_FRAME(topframe),toplabelbox);
+ /* space *always* means play/pause */
+ g_signal_connect (G_OBJECT (panel->subpanel_toplevel), "key-press-event",
+ G_CALLBACK (rebind_space),
+ panel);
/* forward unhandled events to the main window */
g_signal_connect_after (G_OBJECT (panel->subpanel_toplevel), "key-press-event",
G_CALLBACK (forward_events),
<p><p>1.23 +2 -2 postfish/version.h
Index: version.h
===================================================================
RCS file: /usr/local/cvsroot/postfish/version.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- version.h 24 Dec 2003 09:49:16 -0000 1.22
+++ version.h 26 Dec 2003 09:55:57 -0000 1.23
@@ -1,2 +1,2 @@
-#define VERSION "$Id: version.h,v 1.22 2003/12/24 09:49:16 xiphmont Exp $ "
-/* DO NOT EDIT: Automated versioning hack [Wed Dec 24 04:43:27 EST 2003] */
+#define VERSION "$Id: version.h,v 1.23 2003/12/26 09:55:57 xiphmont Exp $ "
+/* DO NOT EDIT: Automated versioning hack [Fri Dec 26 04:54:29 EST 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