Commit ca66dc34 authored by Monty Montgomery's avatar Monty Montgomery

Multibar changes:

non-pixel granularity enforcement
multiple thumb boundary bugfixes

Compandpanel:

the beginning


git-svn-id: https://svn.xiph.org/trunk/postfish@5850 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 6beba8b4
......@@ -12,10 +12,10 @@ 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 freq.c eq.c eqpanel.c
feedback.c freq.c eq.c eqpanel.c compand.c compandpanel.c
OBJ = main.o mainpanel.o multibar.o readout.o input.o output.o clippanel.o \
declip.o reconstruct.o smallft.o windowbutton.o subpanel.o \
feedback.o freq.o eq.o eqpanel.o
feedback.o freq.o eq.o eqpanel.o compand.o compandpanel.o
GCF = `pkg-config --cflags gtk+-2.0` -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
all:
......
......@@ -31,6 +31,7 @@
#include "feedback.h"
#include "freq.h"
#include "compand.h"
#include "compandpanel.h"
extern sig_atomic_t compand_active;
extern sig_atomic_t compand_visible;
......@@ -53,18 +54,18 @@ static void slider_change(GtkWidget *w,gpointer in){
cbar *b=(cbar *)in;
gdouble val=multibar_get_value(MULTIBAR(b->slider),0);
sprintf(buffer,"%+5.1f dB",val);
sprintf(buffer,"%+4.0f dB",val);
readout_set(READOUT(b->readoutg),buffer);
compand_g_set(b->number,val);
val=multibar_get_value(MULTIBAR(b->slider),1);
sprintf(buffer,"%+5.1f dB",val);
sprintf(buffer,"%+4.0f dB",val);
readout_set(READOUT(b->readoute),buffer);
compand_e_set(b->number,val);
val=multibar_get_value(MULTIBAR(b->slider),2);
sprintf(buffer,"%+5.1f dB",val);
readout_set(READOUT(b->readoute),buffer);
sprintf(buffer,"%+4.0f dB",val);
readout_set(READOUT(b->readoutc),buffer);
compand_c_set(b->number,val);
}
......@@ -91,9 +92,9 @@ void compandpanel_create(postfish_mainpanel *mp,
GtkWidget *label=gtk_label_new(labeltext);
gtk_widget_set_name(label,"smallmarker");
bars[i].readoutg=readout_new("+000 dB");
bars[i].readoute=readout_new("+000 dB");
bars[i].readoutc=readout_new("+000 dB");
bars[i].readoutg=readout_new(" +0 dB");
bars[i].readoute=readout_new(" +0 dB");
bars[i].readoutc=readout_new(" +0 dB");
bars[i].slider=multibar_new(14,labels,levels,3,
LO_DECAY|HI_DECAY|LO_ATTACK|HI_ATTACK);
bars[i].number=i;
......@@ -103,16 +104,17 @@ void compandpanel_create(postfish_mainpanel *mp,
multibar_thumb_set(MULTIBAR(bars[i].slider),-140.,1);
multibar_thumb_set(MULTIBAR(bars[i].slider),0.,2);
multibar_thumb_bounds(MULTIBAR(bars[i].slider),-140,0);
multibar_thumb_increment(MULTIBAR(bars[i].slider),1.,10.);
gtk_misc_set_alignment(GTK_MISC(label),1,.5);
gtk_table_attach(GTK_TABLE(slidertable),label,0,1,i,i+1,
GTK_FILL,0,10,0);
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readout,2,3,i,i+1,
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readoutg,2,3,i,i+1,
GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readout,3,4,i,i+1,
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readoute,3,4,i,i+1,
GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readout,4,5,i,i+1,
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readoutc,4,5,i,i+1,
GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(slidertable),bars[i].slider,1,2,i,i+1,
GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,0,0);
......@@ -149,8 +151,3 @@ void compandpanel_reset(void){
multibar_reset(MULTIBAR(bars[i].slider));
}
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Postfish is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
extern void compandpanel_create(postfish_mainpanel *mp,
GtkWidget *windowbutton,
GtkWidget *activebutton);
extern void compandpanel_feedback(int displayit);
extern void compandpanel_reset(void);
......@@ -48,7 +48,7 @@ int eq_reset(){
return freq_reset(&eq);
}
sig_atomic_t settings[freqs];
static sig_atomic_t settings[freqs];
void eq_set(int freq, double value){
settings[freq]=rint(value*10.);
......
......@@ -51,7 +51,7 @@ static void slider_change(GtkWidget *w,gpointer in){
bar *b=(bar *)in;
gdouble val=multibar_get_value(MULTIBAR(b->slider),0);
sprintf(buffer,"%+5.1f dB",val);
sprintf(buffer,"%+3.0f dB",val);
readout_set(READOUT(b->readout),buffer);
eq_set(b->number,val);
......@@ -80,7 +80,7 @@ void eqpanel_create(postfish_mainpanel *mp,
GtkWidget *label=gtk_label_new(labeltext);
gtk_widget_set_name(label,"smallmarker");
bars[i].readout=readout_new("+00.0 dB");
bars[i].readout=readout_new("+00 dB");
bars[i].slider=multibar_new(15,labels,levels,1,
LO_DECAY|HI_DECAY|LO_ATTACK|HI_ATTACK);
bars[i].number=i;
......@@ -88,6 +88,7 @@ void eqpanel_create(postfish_mainpanel *mp,
multibar_callback(MULTIBAR(bars[i].slider),slider_change,bars+i);
multibar_thumb_set(MULTIBAR(bars[i].slider),0.,0);
multibar_thumb_bounds(MULTIBAR(bars[i].slider),-40,30);
multibar_thumb_increment(MULTIBAR(bars[i].slider),1,10);
gtk_misc_set_alignment(GTK_MISC(label),1,.5);
......
......@@ -666,6 +666,7 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
panel->masterdB_s=multibar_slider_new(10,sliderlabels,sliderlevels,1);
multibar_thumb_set(MULTIBAR(panel->masterdB_s),0.,0);
multibar_thumb_increment(MULTIBAR(panel->masterdB_s),.1,1.);
gtk_misc_set_alignment(GTK_MISC(masterlabel),1,.5);
......@@ -854,7 +855,7 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
mainpanel_panelentry(panel,"_Declip ","[d]",0,clippanel_create);
mainpanel_panelentry(panel,"Cross_Talk ","[t]",1,0);
mainpanel_panelentry(panel,"_Compand/Gate ","[c]",2,0);
mainpanel_panelentry(panel,"_Compand/Gate ","[c]",2,compandpanel_create);
mainpanel_panelentry(panel,"_Equalizer ","[e]",3,eqpanel_create);
mainpanel_panelentry(panel,"_Limiter ","[l]",4,0);
mainpanel_panelentry(panel,"_Output Cal. ","[o]",5,0);
......
......@@ -28,6 +28,7 @@ typedef struct postfish_mainpanel postfish_mainpanel;
#include "clippanel.h"
#include "eqpanel.h"
#include "compandpanel.h"
struct postfish_mainpanel{
GtkWidget *topframe;
......
......@@ -57,9 +57,9 @@ static double compute_dampening(double width, double target,double current,doubl
/* call me roughly 10-20fps */
static void compute(GtkWidget *widget,double *lowvals, double *highvals, int n){
static void compute(Multibar *m,double *lowvals, double *highvals, int n){
int i,j,xpad;
Multibar *m=MULTIBAR(widget);
GtkWidget *widget=GTK_WIDGET(m);
double max=-400;
int height=widget->allocation.height;
int width=widget->allocation.width;
......@@ -355,7 +355,7 @@ static void draw(GtkWidget *widget,int n){
}
for(i=0;i<m->labels+1;i++){
int x=rint(((double)i)/m->labels*(widget->allocation.width-xpad*2))+xpad);
int x=rint(((double)i)/m->labels*(widget->allocation.width-xpad*2))+xpad;
int y=widget->allocation.height-lpad-upad;
int px,py;
int gc=0;
......@@ -686,8 +686,8 @@ static gboolean multibar_focus (GtkWidget *widget,
return ret;
}
static gint determine_thumb(GtkWidget *widget,int ix, int iy){
Multibar *m=MULTIBAR(widget);
static gint determine_thumb(Multibar *m,int ix, int iy){
GtkWidget *widget=GTK_WIDGET(m);
int height=widget->allocation.height;
double distances[3]={-1,-1,-1};
int thumb=-1;
......@@ -725,16 +725,16 @@ static gint determine_thumb(GtkWidget *widget,int ix, int iy){
return thumb;
}
static int pixel_bound(GtkWidget *w,int x){
Multibar *m=MULTIBAR(w);
static int pixel_bound(Multibar *m,int x){
GtkWidget *w=GTK_WIDGET(m);
if(x<0)return 0;
if(x>w->allocation.width-m->xpad*2)
return w->allocation.width-m->xpad*2;
return x;
}
static double pixel_to_val(GtkWidget *w,int x){
Multibar *m=MULTIBAR(w);
static double pixel_to_val(Multibar *m,int x){
GtkWidget *w=GTK_WIDGET(m);
int j;
for(j=0;j<=m->labels;j++){
......@@ -750,8 +750,8 @@ static double pixel_to_val(GtkWidget *w,int x){
return 0.;
}
static int val_to_pixel(GtkWidget *w,double v){
Multibar *m=MULTIBAR(w);
static int val_to_pixel(Multibar *m,double v){
GtkWidget *w=GTK_WIDGET(m);
int j,ret=0;
if(v<m->levels[0]){
......@@ -770,7 +770,7 @@ static int val_to_pixel(GtkWidget *w,double v){
}
}
ret=pixel_bound(w,ret);
ret=pixel_bound(m,ret);
return ret;
}
......@@ -788,11 +788,11 @@ static gboolean configure(GtkWidget *widget, GdkEventConfigure *event){
gdk_draw_rectangle(m->backing,widget->style->white_gc,1,0,0,widget->allocation.width,
widget->allocation.height);
compute(widget,0,0,0);
compute(m,0,0,0);
for(i=0;i<m->thumbs;i++)
m->thumbpixel[i]=val_to_pixel(widget,m->thumbval[i]);
m->thumblo_x=val_to_pixel(widget,m->thumblo);
m->thumbhi_x=val_to_pixel(widget,m->thumbhi);
m->thumbpixel[i]=val_to_pixel(m,m->thumbval[i]);
m->thumblo_x=val_to_pixel(m,m->thumblo);
m->thumbhi_x=val_to_pixel(m,m->thumbhi);
draw_and_expose(widget);
......@@ -801,35 +801,22 @@ static gboolean configure(GtkWidget *widget, GdkEventConfigure *event){
static void vals_bound(Multibar *m){
int i;
if(m->thumbsmall>0 && m->thumblarge>0)
for(i=0;i<m->thumbs;i++)
m->thumbval[i]=rint(m->thumbval[i]/m->thumbsmall)*m->thumbsmall;
for(i=0;i<m->thumbs;i++){
if(m->thumbval[i]<m->thumblo){
m->thumbval[i]=m->thumblo;
m->thumbpixel[i]=val_to_pixel(GTK_WIDGET(m),m->thumblo);
}
if(m->thumbval[i]>m->thumbhi){
m->thumbval[i]=m->thumbhi;
m->thumbpixel[i]=val_to_pixel(GTK_WIDGET(m),m->thumbhi);
}
if(m->thumbval[i]<m->thumblo)m->thumbval[i]=m->thumblo;
if(m->thumbval[i]>m->thumbhi)m->thumbval[i]=m->thumbhi;
m->thumbpixel[i]=val_to_pixel(m,m->thumbval[i]);
}
}
static gint multibar_motion(GtkWidget *w,
GdkEventMotion *event){
Multibar *m=MULTIBAR(w);
/* is a thumb already grabbed? */
if(m->thumbgrab>=0){
if(m->thumbfocus>=0){
double v=m->thumbval[m->thumbfocus];
int x=m->thumbpixel[m->thumbfocus];
int x=event->x+m->thumbx;
double v;
x=pixel_bound(w,x);
m->thumbval[m->thumbgrab]=pixel_to_val(w,x);
vals_bound(m);
v=m->thumbval[m->thumbgrab];
x=m->thumbpixel[m->thumbgrab]=val_to_pixel(w,v);
if(m->thumbgrab==2){
if(m->thumbfocus==2){
if(m->thumbpixel[1]>x){
m->thumbpixel[1]=x;
m->thumbval[1]=v;
......@@ -839,8 +826,8 @@ static gint multibar_motion(GtkWidget *w,
m->thumbval[0]=v;
}
}
if(m->thumbgrab==1){
if(m->thumbfocus==1){
if(m->thumbpixel[2]<x){
m->thumbpixel[2]=x;
m->thumbval[2]=v;
......@@ -850,8 +837,8 @@ static gint multibar_motion(GtkWidget *w,
m->thumbval[0]=v;
}
}
if(m->thumbgrab==0){
if(m->thumbfocus==0){
if(m->thumbpixel[2]<x){
m->thumbpixel[2]=x;
m->thumbval[2]=v;
......@@ -861,13 +848,32 @@ static gint multibar_motion(GtkWidget *w,
m->thumbval[1]=v;
}
}
}
}
static gint multibar_motion(GtkWidget *w,
GdkEventMotion *event){
Multibar *m=MULTIBAR(w);
/* is a thumb already grabbed? */
if(m->thumbgrab>=0){
int x=event->x+m->thumbx;
double v;
x=pixel_bound(m,x);
m->thumbval[m->thumbgrab]=pixel_to_val(m,x);
vals_bound(m);
v=m->thumbval[m->thumbgrab];
x=m->thumbpixel[m->thumbgrab]=val_to_pixel(m,v);
if(m->callback)m->callback(GTK_WIDGET(m),m->callbackp);
draw_and_expose(w);
}else{
/* nothing grabbed right now; determine if we're in a a thumb's area */
int thumb=determine_thumb(w,event->x-m->xpad,event->y);
int thumb=determine_thumb(m,event->x-m->xpad,event->y);
GtkStateType thumbstate[3];
thumbstate[0]=GTK_STATE_NORMAL;
thumbstate[1]=GTK_STATE_NORMAL;
......@@ -957,27 +963,59 @@ gboolean key_press(GtkWidget *w,GdkEventKey *event){
if(event->state&GDK_CONTROL_MASK) return FALSE;
if(m->thumbfocus>=0){
switch(event->keyval){
case GDK_minus:
x=m->thumbpixel[m->thumbfocus]-1;
break;
case GDK_underscore:
x=m->thumbpixel[m->thumbfocus]-10;
break;
case GDK_equal:
x=m->thumbpixel[m->thumbfocus]+1;
break;
case GDK_plus:
x=m->thumbpixel[m->thumbfocus]+10;
break;
default:
return FALSE;
if(m->thumbsmall>0 && m->thumblarge>0){
switch(event->keyval){
case GDK_minus:
m->thumbval[m->thumbfocus]-=m->thumbsmall;
break;
case GDK_underscore:
m->thumbval[m->thumbfocus]-=m->thumblarge;
break;
case GDK_equal:
m->thumbval[m->thumbfocus]+=m->thumbsmall;
break;
case GDK_plus:
m->thumbval[m->thumbfocus]+=m->thumblarge;
break;
default:
return FALSE;
}
vals_bound(m);
x=val_to_pixel(m,m->thumbval[m->thumbfocus]);
x=pixel_bound(m,x);
m->thumbpixel[m->thumbfocus]=x;
}else{
switch(event->keyval){
case GDK_minus:
x=m->thumbpixel[m->thumbfocus]-1;
break;
case GDK_underscore:
x=m->thumbpixel[m->thumbfocus]-10;
break;
case GDK_equal:
x=m->thumbpixel[m->thumbfocus]+1;
break;
case GDK_plus:
x=m->thumbpixel[m->thumbfocus]+10;
break;
default:
return FALSE;
}
x=pixel_bound(m,x);
m->thumbpixel[m->thumbfocus]=x;
m->thumbval[m->thumbfocus]=pixel_to_val(m,x);
vals_bound(m);
}
x=pixel_bound(w,x);
m->thumbpixel[m->thumbfocus]=x;
m->thumbval[m->thumbfocus]=pixel_to_val(w,x);
vals_bound(m);
if(m->callback)m->callback(GTK_WIDGET(m),m->callbackp);
draw_and_expose(w);
......@@ -1059,8 +1097,8 @@ GtkWidget* multibar_new (int n, char **labels, double *levels, int thumbs,
m->thumbgrab=-1;
m->thumblo=levels[0];
m->thumbhi=levels[n];
m->thumblo_x=val_to_pixel(ret,m->thumblo);
m->thumbhi_x=val_to_pixel(ret,m->thumbhi);
m->thumblo_x=val_to_pixel(m,m->thumblo);
m->thumbhi_x=val_to_pixel(m,m->thumbhi);
if(thumbs<0)thumbs=0;
if(thumbs>3)thumbs=3;
......@@ -1097,18 +1135,22 @@ GtkWidget* multibar_slider_new (int n, char **labels, double *levels,
void multibar_set(Multibar *m,double *lo, double *hi, int n){
GtkWidget *widget=GTK_WIDGET(m);
compute(widget,lo,hi,n);
compute(m,lo,hi,n);
draw_and_expose(widget);
}
void multibar_thumb_set(Multibar *m,double v, int n){
GtkWidget *w=GTK_WIDGET(m);
int x;
if(n<0)return;
if(n>=m->thumbs)return;
{
int x=m->thumbpixel[n]=val_to_pixel(w,v);
m->thumbval[n]=v;
vals_bound(m);
v=m->thumbval[n];
x=m->thumbpixel[n]=val_to_pixel(m,v);
m->thumbval[n]=v;
if(n==0){
......@@ -1191,8 +1233,20 @@ void multibar_thumb_bounds(Multibar *m,double lo, double hi){
m->thumblo=lo;
m->thumbhi=hi;
m->thumblo_x=val_to_pixel(w,lo);
m->thumbhi_x=val_to_pixel(w,hi);
m->thumblo_x=val_to_pixel(m,lo);
m->thumbhi_x=val_to_pixel(m,hi);
vals_bound(m);
if(m->callback)m->callback(GTK_WIDGET(m),m->callbackp);
draw_and_expose(w);
}
void multibar_thumb_increment(Multibar *m,double small, double large){
GtkWidget *w=GTK_WIDGET(m);
if(small>large)return;
m->thumbsmall=small;
m->thumblarge=large;
vals_bound(m);
if(m->callback)m->callback(GTK_WIDGET(m),m->callbackp);
......
......@@ -87,8 +87,10 @@ struct _Multibar{
int prev_thumbfocus;
int thumbgrab;
int thumbx;
double thumblo;
double thumbhi;
double thumblo;
double thumbhi;
double thumbsmall;
double thumblarge;
int thumblo_x;
int thumbhi_x;
......@@ -122,6 +124,7 @@ void multibar_callback (Multibar *m,
gpointer);
double multibar_get_value(Multibar *m,int n);
void multibar_thumb_bounds(Multibar *m,double lo, double hi);
void multibar_thumb_increment(Multibar *m,double small, double large);
G_END_DECLS
......
#define VERSION "$Id: version.h,v 1.34 2004/02/20 00:33:21 xiphmont Exp $ "
/* DO NOT EDIT: Automated versioning hack [Thu Feb 19 18:21:37 EST 2004] */
#define VERSION "$Id: version.h,v 1.35 2004/02/20 02:09:39 xiphmont Exp $ "
/* DO NOT EDIT: Automated versioning hack [Thu Feb 19 21:08:12 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