Commit affc4a72 authored by Monty Montgomery's avatar Monty Montgomery

Having Postfish around in a state where I keep tinkering on it is

still proving distracting.

So that's it.  I'm calling this a prerelease commit and putting it
out of mind.  I'll come back when OggFile hits beta.

Have at.  



git-svn-id: https://svn.xiph.org/trunk/postfish@6774 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 637b80f1
......@@ -3,14 +3,19 @@
# and Fuck its little dog Libtool too
ADD_DEF= -DUGLY_IEEE754_FLOAT32_HACK=1 -maltivec
# use for PPC with altivec. IF YOU HAVE ALTIVEC, YOU MUST USE THIS
# LINE, otherwise FFTW3 will randomly crash whenever it uses Altivec
# and any math denormalizes.
# The PPC build *must* use -maltivec, even if the target is a non-altivec machine
#ADD_DEF= -DUGLY_IEEE754_FLOAT32_HACK=1 -maltivec
# use the below for x86 and most other platforms where 'float' is 32 bit IEEE754
ADD_DEF= -DUGLY_IEEE754_FLOAT32_HACK=1
# use the below for anything without IEE754 floats (eg, VAX)
# ADD_DEF=
CC=gcc
LD=gcc
INSTALL=install
......@@ -23,12 +28,14 @@ SRC = main.c mainpanel.c multibar.c readout.c input.c output.c clippanel.c \
declip.c reconstruct.c multicompand.c windowbutton.c subpanel.c \
feedback.c freq.c eq.c eqpanel.c compandpanel.c subband.c lpc.c \
bessel.c suppresspanel.c suppress.c singlecomp.c singlepanel.c \
limit.c limitpanel.c mute.c mixpanel.c mix.c reverb.c reverbpanel.c
limit.c limitpanel.c mute.c mixpanel.c mix.c reverb.c reverbpanel.c \
outpanel.c config.c
OBJ = main.o mainpanel.o multibar.o readout.o input.o output.o clippanel.o \
declip.o reconstruct.o multicompand.o windowbutton.o subpanel.o \
feedback.o freq.o eq.o eqpanel.o compandpanel.o subband.o lpc.o \
bessel.o suppresspanel.o suppress.o singlecomp.o singlepanel.o \
limit.o limitpanel.o mute.o mixpanel.o mix.o reverb.o reverbpanel.o
limit.o limitpanel.o mute.o mixpanel.o mix.o reverb.o reverbpanel.o \
outpanel.o config.o
GCF = -DETCDIR=\\\"$(ETCDIR)\\\" `pkg-config --cflags gtk+-2.0` -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
all:
......
......@@ -29,24 +29,24 @@
#include "mainpanel.h"
#include "subpanel.h"
#include "declip.h"
#include "config.h"
extern sig_atomic_t *declip_active;
extern sig_atomic_t declip_visible;
extern int input_ch;
extern int input_size;
extern int input_rate;
extern sig_atomic_t declip_converge;
static GtkWidget **feedback_bars;
static GtkWidget **trigger_bars;
GtkWidget **feedback_bars;
GtkWidget **trigger_bars;
static GtkWidget *width_bar;
static GtkWidget *samplereadout;
static GtkWidget *msreadout;
static GtkWidget *hzreadout;
GtkWidget *samplereadout;
GtkWidget *msreadout;
GtkWidget *hzreadout;
GtkWidget *depth_readout;
GtkWidget *limit_readout;
static GtkWidget *depth_bar;
static GtkWidget *depth_readout;
static GtkWidget *limit_bar;
static GtkWidget *limit_readout;
GtkWidget *mainpanel_inbar;
static GtkWidget *mainpanel_inbar;
static subpanel_generic *panel;
typedef struct {
GtkWidget *slider;
......@@ -55,6 +55,37 @@ typedef struct {
int number;
} clipslider;
void clippanel_state_to_config(int bank){
config_set_vector("clippanel_active",bank,0,0,0,input_ch,declip_active);
config_set_integer("clippanel_width",bank,0,0,0,0,declip_pending_blocksize);
config_set_integer("clippanel_convergence",bank,0,0,0,0,declip_convergence);
config_set_integer("clippanel_throttle",bank,0,0,0,0,declip_iterations);
config_set_vector("clippanel_trigger",bank,0,0,0,input_ch,declip_chtrigger);
}
void clippanel_state_from_config(int bank){
int i;
config_get_vector("clippanel_active",bank,0,0,0,input_ch,declip_active);
config_get_sigat("clippanel_width",bank,0,0,0,0,&declip_pending_blocksize);
config_get_sigat("clippanel_convergence",bank,0,0,0,0,&declip_convergence);
config_get_sigat("clippanel_throttle",bank,0,0,0,0,&declip_iterations);
config_get_vector("clippanel_trigger",bank,0,0,0,input_ch,declip_chtrigger);
{
int i=0,j=declip_pending_blocksize;
while(j>64){j>>=1;i++;}
multibar_thumb_set(MULTIBAR(width_bar),i,0);
}
multibar_thumb_set(MULTIBAR(depth_bar),declip_convergence*-.1,0);
multibar_thumb_set(MULTIBAR(limit_bar),declip_iterations*.1,0);
for(i=0;i<input_ch;i++){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel->subpanel_activebutton[i]),
declip_active[i]);
multibar_thumb_set(MULTIBAR(trigger_bars[i]),declip_chtrigger[i]*.0001,0);
}
}
static void trigger_slider_change(GtkWidget *w,gpointer in){
char buffer[80];
clipslider *p=(clipslider *)in;
......@@ -66,8 +97,7 @@ static void trigger_slider_change(GtkWidget *w,gpointer in){
sprintf(buffer,"%3.0fdB",todB(linear));
readout_set(READOUT(p->readoutdB),buffer);
declip_settrigger(linear,p->number);
declip_chtrigger[p->number]=rint(linear*10000.);
}
static void blocksize_slider_change(GtkWidget *w,gpointer in){
......@@ -83,8 +113,8 @@ static void blocksize_slider_change(GtkWidget *w,gpointer in){
sprintf(buffer,"%5dHz",(int)rint(input_rate*2./blocksize));
readout_set(READOUT(hzreadout),buffer);
declip_setblock(blocksize);
declip_pending_blocksize=blocksize;
}
static void depth_slider_change(GtkWidget *w,gpointer in){
......@@ -94,7 +124,7 @@ static void depth_slider_change(GtkWidget *w,gpointer in){
sprintf(buffer,"%3ddB",(int)dB);
readout_set(READOUT(depth_readout),buffer);
declip_setconvergence(fromdB(-dB));
declip_convergence=rint(-dB*10.);
}
static void limit_slider_change(GtkWidget *w,gpointer in){
......@@ -104,7 +134,7 @@ static void limit_slider_change(GtkWidget *w,gpointer in){
sprintf(buffer,"%3d%%",(int)percent);
readout_set(READOUT(limit_readout),buffer);
declip_setiterations(percent*.01);
declip_iterations=rint(percent*10.);
}
static void active_callback(gpointer in,int activenum){
......@@ -120,11 +150,6 @@ void clippanel_create(postfish_mainpanel *mp,
float levels[3]={0.,10.,100.};
int block_choices=0;
subpanel_generic *panel=subpanel_create(mp,windowbutton[0],activebutton,
declip_active,&declip_visible,
"_Declipping filter setup",NULL,
0,input_ch);
GtkWidget *framebox=gtk_hbox_new(1,0);
GtkWidget *framebox_right=gtk_vbox_new(0,0);
GtkWidget *blocksize_box=gtk_vbox_new(0,0);
......@@ -135,6 +160,11 @@ void clippanel_create(postfish_mainpanel *mp,
GtkWidget *limit_box=gtk_vbox_new(0,0);
GtkWidget *channel_table=gtk_table_new(input_ch,5,0);
panel=subpanel_create(mp,windowbutton[0],activebutton,
declip_active,&declip_visible,
"_Declipping filter setup",NULL,
0,input_ch);
subpanel_set_active_callback(panel,0,active_callback);
gtk_widget_set_name(blocksize_box,"choiceframe");
......@@ -182,10 +212,11 @@ void clippanel_create(postfish_mainpanel *mp,
gtk_table_attach(GTK_TABLE(table),hzreadout,1,2,3,4,GTK_FILL,0,5,0);
gtk_container_add(GTK_CONTAINER(blocksize_box),table);
width_bar=slider;
multibar_thumb_increment(MULTIBAR(slider),1.,1.);
multibar_callback(MULTIBAR(slider),blocksize_slider_change,0);
multibar_thumb_set(MULTIBAR(slider),2.,0);
multibar_thumb_set(MULTIBAR(slider),4.,0);
}
gtk_container_add(GTK_CONTAINER(blocksize_frame),blocksize_box);
......@@ -214,6 +245,7 @@ void clippanel_create(postfish_mainpanel *mp,
gtk_container_add(GTK_CONTAINER(converge_box),table);
depth_bar=slider;
multibar_thumb_increment(MULTIBAR(slider),1.,10.);
multibar_callback(MULTIBAR(slider),depth_slider_change,0);
multibar_thumb_set(MULTIBAR(slider),60.,0);
......@@ -244,6 +276,7 @@ void clippanel_create(postfish_mainpanel *mp,
gtk_container_add(GTK_CONTAINER(limit_box),table);
limit_bar=slider;
multibar_thumb_increment(MULTIBAR(slider),1.,10.);
multibar_callback(MULTIBAR(slider),limit_slider_change,0);
multibar_thumb_set(MULTIBAR(slider),100.,0);
......
......@@ -28,3 +28,6 @@ extern void clippanel_create(postfish_mainpanel *mp,
GtkWidget **activebutton);
extern void clippanel_feedback(int workp);
extern void clippanel_reset(void);
extern void clippanel_state_from_config(int bank);
extern void clippanel_state_to_config(int bank);
......@@ -31,13 +31,7 @@
#include "feedback.h"
#include "multicompand.h"
#include "compandpanel.h"
extern int input_ch;
extern int input_size;
extern int input_rate;
extern multicompand_settings multi_master_set;
extern multicompand_settings *multi_channel_set;
#include "config.h"
typedef struct {
GtkWidget *label;
......@@ -49,11 +43,13 @@ typedef struct {
} cbar;
typedef struct{
Multibar *s;
Readout *r;
sig_atomic_t *v;
} callback_arg_rv;
typedef struct{
Multibar *s;
Readout *r0;
Readout *r1;
sig_atomic_t *v0;
......@@ -66,6 +62,21 @@ typedef struct{
} callback_arg_mi;
typedef struct multi_panel_state{
subpanel_generic *panel;
GtkWidget *over_rms;
GtkWidget *over_peak;
GtkWidget *over_softknee;
GtkWidget *under_rms;
GtkWidget *under_peak;
GtkWidget *under_softknee;
GtkWidget *base_rms;
GtkWidget *base_peak;
GtkWidget *octave[3];
callback_arg_rv over_compand;
callback_arg_rv under_compand;
callback_arg_rv base_compand;
......@@ -92,6 +103,127 @@ typedef struct multi_panel_state{
static multi_panel_state *master_panel;
static multi_panel_state **channel_panel;
static void compandpanel_state_to_config_helper(int bank,multicompand_settings *s,int A){
int i;
config_set_integer("multicompand_active",bank,A,0,0,0,s->panel_active);
config_set_integer("multicompand_freqbank",bank,A,0,0,0,s->active_bank);
for(i=0;i<multicomp_banks;i++){
config_set_vector("multicompand_under_thresh",bank,A,i,0,multicomp_freqs_max,s->bc[i].static_u);
config_set_vector("multicompand_over_thresh",bank,A,i,0,multicomp_freqs_max,s->bc[i].static_o);
}
config_set_integer("multicompand_over_set",bank,A,0,0,0,s->over_mode);
config_set_integer("multicompand_over_set",bank,A,0,0,1,s->over_softknee);
config_set_integer("multicompand_over_set",bank,A,0,0,2,s->over_ratio);
config_set_integer("multicompand_over_set",bank,A,0,0,3,s->over_attack);
config_set_integer("multicompand_over_set",bank,A,0,0,4,s->over_decay);
config_set_integer("multicompand_over_set",bank,A,0,0,5,s->over_lookahead);
config_set_integer("multicompand_under_set",bank,A,0,0,0,s->under_mode);
config_set_integer("multicompand_under_set",bank,A,0,0,1,s->under_softknee);
config_set_integer("multicompand_under_set",bank,A,0,0,2,s->under_ratio);
config_set_integer("multicompand_under_set",bank,A,0,0,3,s->under_attack);
config_set_integer("multicompand_under_set",bank,A,0,0,4,s->under_decay);
config_set_integer("multicompand_under_set",bank,A,0,0,5,s->under_lookahead);
config_set_integer("multicompand_base_set",bank,A,0,0,0,s->base_mode);
config_set_integer("multicompand_base_set",bank,A,0,0,2,s->base_ratio);
config_set_integer("multicompand_base_set",bank,A,0,0,3,s->base_attack);
config_set_integer("multicompand_base_set",bank,A,0,0,4,s->base_decay);
}
void compandpanel_state_to_config(int bank){
int i;
compandpanel_state_to_config_helper(bank,&multi_master_set,0);
for(i=0;i<input_ch;i++)
compandpanel_state_to_config_helper(bank,multi_channel_set+i,i+1);
}
static void static_octave(GtkWidget *w,gpointer in);
static void compandpanel_state_from_config_helper(int bank,multicompand_settings *s,
multi_panel_state *p,int A){
int i;
config_get_sigat("multicompand_active",bank,A,0,0,0,&s->panel_active);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->panel->subpanel_activebutton[0]),s->panel_active);
config_get_sigat("multicompand_freqbank",bank,A,0,0,0,&s->active_bank);
for(i=0;i<multicomp_banks;i++){
config_get_vector("multicompand_under_thresh",bank,A,i,0,multicomp_freqs_max,s->bc[i].static_u);
config_get_vector("multicompand_over_thresh",bank,A,i,0,multicomp_freqs_max,s->bc[i].static_o);
}
config_get_sigat("multicompand_over_set",bank,A,0,0,0,&s->over_mode);
if(s->over_mode)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->over_peak),1);
else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->over_rms),1);
config_get_sigat("multicompand_over_set",bank,A,0,0,1,&s->over_softknee);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->over_softknee),s->over_softknee);
config_get_sigat("multicompand_over_set",bank,A,0,0,2,&s->over_ratio);
multibar_thumb_set(p->over_compand.s,1000./s->over_ratio,0);
config_get_sigat("multicompand_over_set",bank,A,0,0,3,&s->over_attack);
multibar_thumb_set(p->over_timing.s,s->over_attack*.1,0);
config_get_sigat("multicompand_over_set",bank,A,0,0,4,&s->over_decay);
multibar_thumb_set(p->over_timing.s,s->over_decay*.1,1);
config_get_sigat("multicompand_over_set",bank,A,0,0,5,&s->over_lookahead);
multibar_thumb_set(p->over_lookahead.s,s->over_lookahead*.1,0);
config_get_sigat("multicompand_under_set",bank,A,0,0,0,&s->under_mode);
if(s->under_mode)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->under_peak),1);
else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->under_rms),1);
config_get_sigat("multicompand_under_set",bank,A,0,0,1,&s->under_softknee);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->under_softknee),s->under_softknee);
config_get_sigat("multicompand_under_set",bank,A,0,0,2,&s->under_ratio);
multibar_thumb_set(p->under_compand.s,1000./s->under_ratio,0);
config_get_sigat("multicompand_under_set",bank,A,0,0,3,&s->under_attack);
multibar_thumb_set(p->under_timing.s,s->under_attack*.1,0);
config_get_sigat("multicompand_under_set",bank,A,0,0,4,&s->under_decay);
multibar_thumb_set(p->under_timing.s,s->under_decay*.1,1);
config_get_sigat("multicompand_under_set",bank,A,0,0,5,&s->under_lookahead);
multibar_thumb_set(p->under_lookahead.s,s->under_lookahead*.1,0);
config_get_sigat("multicompand_base_set",bank,A,0,0,0,&s->base_mode);
if(s->base_mode)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->base_peak),1);
else
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->base_rms),1);
config_get_sigat("multicompand_base_set",bank,A,0,0,2,&s->base_ratio);
multibar_thumb_set(p->base_compand.s,1000./s->base_ratio,0);
config_get_sigat("multicompand_base_set",bank,A,0,0,3,&s->base_attack);
multibar_thumb_set(p->base_timing.s,s->base_attack*.1,0);
config_get_sigat("multicompand_base_set",bank,A,0,0,4,&s->base_decay);
multibar_thumb_set(p->base_timing.s,s->base_decay*.1,1);
/* setting the active bank also redisplays all the sliders */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->octave[s->active_bank]),1);
/* safe to call blindly; if the above already triggered the work, this is a no op */
switch(s->active_bank){
case 0:
static_octave(0,&p->octave_full);
break;
case 1:
static_octave(0,&p->octave_half);
break;
case 2:
static_octave(0,&p->octave_third);
break;
}
}
void compandpanel_state_from_config(int bank){
int i;
compandpanel_state_from_config_helper(bank,&multi_master_set,master_panel,0);
for(i=0;i<input_ch;i++)
compandpanel_state_from_config_helper(bank,multi_channel_set+i,channel_panel[i],i+1);
}
static void compand_change(GtkWidget *w,gpointer in){
callback_arg_rv *ca=(callback_arg_rv *)in;
char buffer[80];
......@@ -509,10 +641,11 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
float per_levels[9]={0,12.5,25,37.5,50,62.5,75,87.5,100};
char *per_labels[9]={"0%","","25%","","50%","","75%","","100%"};
multi_panel_state *ps=calloc(1,sizeof(multi_panel_state));
multi_panel_state *ps=calloc(1,sizeof(*ps));
ps->inactive_updatep=1;
ps->bank_active=2;
ps->ms=ms;
ps->panel=panel;
GtkWidget *hbox=gtk_hbox_new(0,0);
GtkWidget *sliderbox=gtk_vbox_new(0,0);
......@@ -590,6 +723,10 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
gtk_container_set_border_width(GTK_CONTAINER(sliderframe),4);
ps->octave[0]=octave_a;
ps->octave[1]=octave_b;
ps->octave[2]=octave_c;
}
gtk_box_pack_start(GTK_BOX(panel->subpanel_box),hbox,0,0,0);
......@@ -637,6 +774,9 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rms_button),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(knee_button),1);
gtk_table_attach(GTK_TABLE(undertable),envelopebox,0,4,0,1,GTK_FILL,0,0,0);
ps->under_rms=rms_button;
ps->under_peak=peak_button;
ps->under_softknee=knee_button;
}
/* under compand: ratio */
......@@ -646,6 +786,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout=readout_new("1.55:1");
GtkWidget *slider=multibar_slider_new(9,compand_labels,compand_levels,1);
ps->under_compand.s=MULTIBAR(slider);
ps->under_compand.r=READOUT(readout);
ps->under_compand.v=&ps->ms->under_ratio;
......@@ -669,6 +810,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout1=readout_new(" 100ms");
GtkWidget *slider=multibar_slider_new(6,timing_labels,timing_levels,2);
ps->under_timing.s=MULTIBAR(slider);
ps->under_timing.r0=READOUT(readout0);
ps->under_timing.r1=READOUT(readout1);
ps->under_timing.v0=&ps->ms->under_attack;
......@@ -695,6 +837,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout=readout_new("100%");
GtkWidget *slider=multibar_slider_new(9,per_labels,per_levels,1);
ps->under_lookahead.s=MULTIBAR(slider);
ps->under_lookahead.r=READOUT(readout);
ps->under_lookahead.v=&ps->ms->under_lookahead;
......@@ -733,6 +876,9 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rms_button),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(knee_button),1);
gtk_table_attach(GTK_TABLE(overtable),envelopebox,0,4,0,1,GTK_FILL,0,0,0);
ps->over_rms=rms_button;
ps->over_peak=peak_button;
ps->over_softknee=knee_button;
}
/* over compand: ratio */
......@@ -742,6 +888,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout=readout_new("1.55:1");
GtkWidget *slider=multibar_slider_new(9,compand_labels,compand_levels,1);
ps->over_compand.s=MULTIBAR(slider);
ps->over_compand.r=READOUT(readout);
ps->over_compand.v=&ps->ms->over_ratio;
......@@ -765,6 +912,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout1=readout_new(" 100ms");
GtkWidget *slider=multibar_slider_new(6,timing_labels,timing_levels,2);
ps->over_timing.s=MULTIBAR(slider);
ps->over_timing.r0=READOUT(readout0);
ps->over_timing.r1=READOUT(readout1);
ps->over_timing.v0=&ps->ms->over_attack;
......@@ -791,6 +939,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout=readout_new("100%");
GtkWidget *slider=multibar_slider_new(9,per_labels,per_levels,1);
ps->over_lookahead.s=MULTIBAR(slider);
ps->over_lookahead.r=READOUT(readout);
ps->over_lookahead.v=&ps->ms->over_lookahead;
......@@ -825,6 +974,8 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
G_CALLBACK (mode_peak), &ps->ms->base_mode);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rms_button),1);
gtk_table_attach(GTK_TABLE(basetable),envelopebox,0,4,0,1,GTK_FILL,0,0,0);
ps->base_rms=rms_button;
ps->base_peak=peak_button;
}
/* base compand: ratio */
......@@ -834,6 +985,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout=readout_new("1.55:1");
GtkWidget *slider=multibar_slider_new(9,compand_labels,compand_levels,1);
ps->base_compand.s=MULTIBAR(slider);
ps->base_compand.r=READOUT(readout);
ps->base_compand.v=&ps->ms->base_ratio;
......@@ -857,6 +1009,7 @@ static multi_panel_state *compandpanel_create(postfish_mainpanel *mp,
GtkWidget *readout1=readout_new(" 100ms");
GtkWidget *slider=multibar_slider_new(6,timing_labels,timing_levels,2);
ps->base_timing.s=MULTIBAR(slider);
ps->base_timing.r0=READOUT(readout0);
ps->base_timing.r1=READOUT(readout1);
ps->base_timing.v0=&ps->ms->base_attack;
......
......@@ -31,5 +31,7 @@ extern void compandpanel_create_channel(postfish_mainpanel *mp,
extern void compandpanel_feedback(int displayit);
extern void compandpanel_reset(void);
extern void compandpanel_state_to_config(int bank);
extern void compandpanel_state_from_config(int bank);
/*
*
* 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.
*
*
*/
#include "postfish.h"
#include "config.h"
#include <errno.h>
#include <string.h>
#include <ctype.h>
typedef struct {
char *key;
int bank;
int A;
int B;
int C;
int vals;
int *vec;
char *string;
} configentry;
static int configentries=0;
static configentry *config_list=0;
static int look_for_key(char *key,int bank,int A, int B, int C){
int i;
for(i=0;i<configentries;i++)
if(!strcmp(key,config_list[i].key) &&
config_list[i].bank==bank &&
config_list[i].A==A &&
config_list[i].B==B &&
config_list[i].C==C)return i;
return -1;
}
/* query the loaded config; this is just an interface to pre-parsed
input */
const char *config_get_string(char *key,int bank, int A, int B, int C){
int i=look_for_key(key,bank,A,B,C);
if(i==-1)return NULL;
return config_list[i].string;
}
int config_get_integer(char *key,int bank, int A, int B, int C,int valnum, int *val){
int i=look_for_key(key,bank,A,B,C);
if(i==-1)return -1;
if(valnum<config_list[i].vals){
*val=config_list[i].vec[valnum];
return 0;
}
return -1;
}
int config_get_sigat(char *key,int bank, int A, int B, int C,int valnum, sig_atomic_t *val){
int ival=*val;
int ret=config_get_integer(key, bank, A, B, C,valnum, &ival);
*val=ival;
return ret;
}
int config_get_vector(char *key,int bank, int A, int B, int C,int n, sig_atomic_t *v){
int i=look_for_key(key,bank,A,B,C),j;
if(i==-1)return -1;
for(j=0;j<n && j<config_list[i].vals;j++)
v[j]=config_list[i].vec[j];
return 0;
}
static configentry *old_or_new(char *key,int bank,int A, int B, int C){
int i=look_for_key(key,bank,A,B,C);
if(i==-1){
/* create a new entry */
i=configentries;
configentries++;
if(config_list){
config_list=realloc(config_list,sizeof(*config_list)*configentries);
memset(&config_list[i],0,sizeof(*config_list));
}else{
config_list=calloc(1,sizeof(*config_list));
}
config_list[i].key=strdup(key);
config_list[i].bank=bank;
config_list[i].A=A;
config_list[i].B=B;
config_list[i].C=C;
}