dd checks/rejection for absurdly huge codebooks.
[xiph/unicode.git] / postfish / singlepanel.c
blob5160d7c44b89daeb60dbde98091269ec12c34d16
1 /*
3 * postfish
4 *
5 * Copyright (C) 2002-2005 Monty
7 * Postfish is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * Postfish is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Postfish; see the file COPYING. If not, write to the
19 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "postfish.h"
25 #include <gtk/gtk.h>
26 #include <gdk/gdkkeysyms.h>
27 #include "readout.h"
28 #include "multibar.h"
29 #include "mainpanel.h"
30 #include "subpanel.h"
31 #include "feedback.h"
32 #include "singlecomp.h"
33 #include "singlepanel.h"
34 #include "config.h"
36 typedef struct {
37 GtkWidget *slider;
38 GtkWidget *readouto;
39 GtkWidget *readoutu;
40 sig_atomic_t *vu;
41 sig_atomic_t *vo;
42 } cbar;
44 typedef struct{
45 Multibar *s;
46 Readout *r;
47 sig_atomic_t *v;
48 } callback_arg_rv;
50 typedef struct{
51 Multibar *s;
52 Readout *r0;
53 Readout *r1;
54 sig_atomic_t *v0;
55 sig_atomic_t *v1;
56 } callback_arg_rv2;
58 typedef struct singlecomp_panel_state{
59 subpanel_generic *panel;
61 GtkWidget *o_peak;
62 GtkWidget *o_rms;
63 GtkWidget *o_knee;
64 GtkWidget *u_peak;
65 GtkWidget *u_rms;
66 GtkWidget *u_knee;
67 GtkWidget *b_peak;
68 GtkWidget *b_rms;
70 callback_arg_rv over_compand;
71 callback_arg_rv under_compand;
72 callback_arg_rv base_compand;
74 callback_arg_rv over_lookahead;
75 callback_arg_rv under_lookahead;
77 callback_arg_rv2 over_timing;
78 callback_arg_rv2 under_timing;
79 callback_arg_rv2 base_timing;
81 singlecomp_settings *ms;
82 cbar bar;
84 } singlecomp_panel_state;
86 static singlecomp_panel_state *master_panel;
87 static singlecomp_panel_state **channel_panel;
89 static void singlepanel_state_to_config_helper(int bank,singlecomp_settings *s,int A){
90 config_set_integer("singlecompand_active",bank,A,0,0,0,s->panel_active);
91 config_set_integer("singlecompand_thresh",bank,A,0,0,0,s->u_thresh);
92 config_set_integer("singlecompand_thresh",bank,A,0,0,1,s->o_thresh);
94 config_set_integer("singlecompand_over_set",bank,A,0,0,0,s->o_mode);
95 config_set_integer("singlecompand_over_set",bank,A,0,0,1,s->o_softknee);
96 config_set_integer("singlecompand_over_set",bank,A,0,0,2,s->o_ratio);
97 config_set_integer("singlecompand_over_set",bank,A,0,0,3,s->o_attack);
98 config_set_integer("singlecompand_over_set",bank,A,0,0,4,s->o_decay);
99 config_set_integer("singlecompand_over_set",bank,A,0,0,5,s->o_lookahead);
101 config_set_integer("singlecompand_under_set",bank,A,0,0,0,s->u_mode);
102 config_set_integer("singlecompand_under_set",bank,A,0,0,1,s->u_softknee);
103 config_set_integer("singlecompand_under_set",bank,A,0,0,2,s->u_ratio);
104 config_set_integer("singlecompand_under_set",bank,A,0,0,3,s->u_attack);
105 config_set_integer("singlecompand_under_set",bank,A,0,0,4,s->u_decay);
106 config_set_integer("singlecompand_under_set",bank,A,0,0,5,s->u_lookahead);
108 config_set_integer("singlecompand_base_set",bank,A,0,0,0,s->b_mode);
109 config_set_integer("singlecompand_base_set",bank,A,0,0,2,s->b_ratio);
110 config_set_integer("singlecompand_base_set",bank,A,0,0,3,s->b_attack);
111 config_set_integer("singlecompand_base_set",bank,A,0,0,4,s->b_decay);
114 void singlepanel_state_to_config(int bank){
115 int i;
116 singlepanel_state_to_config_helper(bank,&singlecomp_master_set,0);
117 for(i=0;i<input_ch;i++)
118 singlepanel_state_to_config_helper(bank,singlecomp_channel_set+i,i+1);
121 static void singlepanel_state_from_config_helper(int bank,singlecomp_settings *s,
122 singlecomp_panel_state *p,int A){
124 config_get_sigat("singlecompand_active",bank,A,0,0,0,&s->panel_active);
125 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->panel->subpanel_activebutton[0]),s->panel_active);
127 config_get_sigat("singlecompand_thresh",bank,A,0,0,0,&s->u_thresh);
128 multibar_thumb_set(MULTIBAR(p->bar.slider),s->u_thresh,0);
129 config_get_sigat("singlecompand_thresh",bank,A,0,0,1,&s->o_thresh);
130 multibar_thumb_set(MULTIBAR(p->bar.slider),s->o_thresh,1);
132 config_get_sigat("singlecompand_over_set",bank,A,0,0,0,&s->o_mode);
133 if(s->o_mode)
134 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->o_peak),1);
135 else
136 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->o_rms),1);
138 config_get_sigat("singlecompand_over_set",bank,A,0,0,1,&s->o_softknee);
139 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->o_knee),s->o_softknee);
140 config_get_sigat("singlecompand_over_set",bank,A,0,0,2,&s->o_ratio);
141 multibar_thumb_set(p->over_compand.s,1000./s->o_ratio,0);
142 config_get_sigat("singlecompand_over_set",bank,A,0,0,3,&s->o_attack);
143 multibar_thumb_set(p->over_timing.s,s->o_attack*.1,0);
144 config_get_sigat("singlecompand_over_set",bank,A,0,0,4,&s->o_decay);
145 multibar_thumb_set(p->over_timing.s,s->o_decay*.1,1);
146 config_get_sigat("singlecompand_over_set",bank,A,0,0,5,&s->o_lookahead);
147 multibar_thumb_set(p->over_lookahead.s,s->o_lookahead*.1,0);
149 config_get_sigat("singlecompand_under_set",bank,A,0,0,0,&s->u_mode);
150 if(s->u_mode)
151 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->u_peak),1);
152 else
153 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->u_rms),1);
155 config_get_sigat("singlecompand_under_set",bank,A,0,0,1,&s->u_softknee);
156 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->u_knee),s->u_softknee);
157 config_get_sigat("singlecompand_under_set",bank,A,0,0,2,&s->u_ratio);
158 multibar_thumb_set(p->under_compand.s,1000./s->u_ratio,0);
159 config_get_sigat("singlecompand_under_set",bank,A,0,0,3,&s->u_attack);
160 multibar_thumb_set(p->under_timing.s,s->u_attack*.1,0);
161 config_get_sigat("singlecompand_under_set",bank,A,0,0,4,&s->u_decay);
162 multibar_thumb_set(p->under_timing.s,s->u_decay*.1,1);
163 config_get_sigat("singlecompand_under_set",bank,A,0,0,5,&s->u_lookahead);
164 multibar_thumb_set(p->under_lookahead.s,s->u_lookahead*.1,0);
166 config_get_sigat("singlecompand_base_set",bank,A,0,0,0,&s->b_mode);
167 if(s->b_mode)
168 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->b_peak),1);
169 else
170 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->b_rms),1);
171 config_get_sigat("singlecompand_base_set",bank,A,0,0,2,&s->b_ratio);
172 multibar_thumb_set(p->base_compand.s,1000./s->b_ratio,0);
173 config_get_sigat("singlecompand_base_set",bank,A,0,0,3,&s->b_attack);
174 multibar_thumb_set(p->base_timing.s,s->b_attack*.1,0);
175 config_get_sigat("singlecompand_base_set",bank,A,0,0,4,&s->b_decay);
176 multibar_thumb_set(p->base_timing.s,s->b_decay*.1,1);
180 void singlepanel_state_from_config(int bank){
181 int i;
182 singlepanel_state_from_config_helper(bank,&singlecomp_master_set,master_panel,0);
183 for(i=0;i<input_ch;i++)
184 singlepanel_state_from_config_helper(bank,singlecomp_channel_set+i,channel_panel[i],i+1);
187 static void compand_change(GtkWidget *w,gpointer in){
188 callback_arg_rv *ca=(callback_arg_rv *)in;
189 char buffer[80];
190 float val=1./multibar_get_value(MULTIBAR(w),0);
192 if(val==1.){
193 sprintf(buffer," off");
194 }else if(val>=10){
195 sprintf(buffer,"%4.1f:1",val);
196 }else if(val>=1){
197 sprintf(buffer,"%4.2f:1",val);
198 }else if(val>.10001){
199 sprintf(buffer,"1:%4.2f",1./val);
200 }else{
201 sprintf(buffer,"1:%4.1f",1./val);
204 readout_set(ca->r,buffer);
206 *ca->v=rint(val*1000.);
209 static void timing_change(GtkWidget *w,gpointer in){
210 callback_arg_rv2 *ca=(callback_arg_rv2 *)in;
212 float attack=multibar_get_value(MULTIBAR(w),0);
213 float decay=multibar_get_value(MULTIBAR(w),1);
214 char buffer[80];
216 if(attack<10){
217 sprintf(buffer,"%4.2fms",attack);
218 }else if(attack<100){
219 sprintf(buffer,"%4.1fms",attack);
220 }else if (attack<1000){
221 sprintf(buffer,"%4.0fms",attack);
222 }else if (attack<10000){
223 sprintf(buffer,"%4.2fs",attack/1000.);
224 }else{
225 sprintf(buffer,"%4.1fs",attack/1000.);
227 readout_set(ca->r0,buffer);
229 if(decay<10){
230 sprintf(buffer,"%4.2fms",decay);
231 }else if(decay<100){
232 sprintf(buffer,"%4.1fms",decay);
233 }else if (decay<1000){
234 sprintf(buffer,"%4.0fms",decay);
235 }else if (decay<10000){
236 sprintf(buffer,"%4.2fs",decay/1000.);
237 }else{
238 sprintf(buffer,"%4.1fs",decay/1000.);
240 readout_set(ca->r1,buffer);
242 *ca->v0=rint(attack*10.);
243 *ca->v1=rint(decay*10.);
246 static void lookahead_change(GtkWidget *w,gpointer in){
247 callback_arg_rv *ca=(callback_arg_rv *)in;
248 char buffer[80];
249 Readout *r=ca->r;
250 float val=multibar_get_value(MULTIBAR(w),0);
252 sprintf(buffer,"%3.0f%%",val);
253 readout_set(r,buffer);
255 *ca->v=rint(val*10.);
258 static void slider_change(GtkWidget *w,gpointer in){
259 char buffer[80];
260 cbar *b=(cbar *)in;
261 int o,u;
263 u=multibar_get_value(MULTIBAR(w),0);
264 sprintf(buffer,"%+4ddB",u);
265 readout_set(READOUT(b->readoutu),buffer);
266 *b->vu=u;
268 o=multibar_get_value(MULTIBAR(w),1);
269 sprintf(buffer,"%+4ddB",o);
270 readout_set(READOUT(b->readouto),buffer);
271 *b->vo=o;
274 static void mode_rms(GtkButton *b,gpointer in){
275 sig_atomic_t *var=(sig_atomic_t *)in;
276 *var=0;
279 static void mode_peak(GtkButton *b,gpointer in){
280 sig_atomic_t *var=(sig_atomic_t *)in;
281 *var=1;
284 static void mode_knee(GtkToggleButton *b,gpointer in){
285 int mode=gtk_toggle_button_get_active(b);
286 sig_atomic_t *var=(sig_atomic_t *)in;
287 *var=mode;
290 static singlecomp_panel_state *singlepanel_create_helper (postfish_mainpanel *mp,
291 subpanel_generic *panel,
292 singlecomp_settings *scset){
294 char *labels[15]={"","130","120","110","100","90","80","70",
295 "60","50","40","30","20","10","0"};
296 float levels[15]={-140,-130,-120,-110,-100,-90,-80,-70,-60,-50,-40,
297 -30,-20,-10,0};
299 float compand_levels[9]={.1,.25,.5,.6667,1,1.5,2,4,10};
300 char *compand_labels[9]={"","4:1","2:1","1:1.5","1:1","1:1.5","1:2","1:4","1:10"};
302 float timing_levels[6]={.5,1,10,100,1000,10000};
303 char *timing_labels[6]={"","1ms","10ms","100ms","1s","10s"};
305 float per_levels[9]={0,12.5,25,37.5,50,62.5,75,87.5,100};
306 char *per_labels[9]={"0%","","25%","","50%","","75%","","100%"};
308 singlecomp_panel_state *ps=calloc(1,sizeof(singlecomp_panel_state));
309 ps->ms=scset;
310 ps->panel=panel;
312 GtkWidget *sliderframe=gtk_frame_new(NULL);
313 GtkWidget *allbox=gtk_vbox_new(0,0);
314 GtkWidget *slidertable=gtk_table_new(2,3,0);
316 GtkWidget *overlabel=gtk_label_new("Over threshold compand ");
317 GtkWidget *overtable=gtk_table_new(6,4,0);
319 GtkWidget *underlabel=gtk_label_new("Under threshold compand ");
320 GtkWidget *undertable=gtk_table_new(5,4,0);
322 GtkWidget *baselabel=gtk_label_new("Global compand ");
323 GtkWidget *basetable=gtk_table_new(3,4,0);
325 gtk_widget_set_name(overlabel,"framelabel");
326 gtk_widget_set_name(underlabel,"framelabel");
327 gtk_widget_set_name(baselabel,"framelabel");
329 gtk_misc_set_alignment(GTK_MISC(overlabel),0,.5);
330 gtk_misc_set_alignment(GTK_MISC(underlabel),0,.5);
331 gtk_misc_set_alignment(GTK_MISC(baselabel),0,.5);
335 GtkWidget *label1=gtk_label_new("compand threshold");
336 GtkWidget *label2=gtk_label_new("under");
337 GtkWidget *label3=gtk_label_new("over");
339 gtk_misc_set_alignment(GTK_MISC(label1),.5,1.);
340 gtk_misc_set_alignment(GTK_MISC(label2),.5,1.);
341 gtk_misc_set_alignment(GTK_MISC(label3),.5,1.);
342 gtk_widget_set_name(label2,"scalemarker");
343 gtk_widget_set_name(label3,"scalemarker");
345 gtk_table_attach(GTK_TABLE(slidertable),label2,0,1,0,1,GTK_FILL,GTK_FILL|GTK_EXPAND,2,0);
346 gtk_table_attach(GTK_TABLE(slidertable),label1,1,2,0,1,GTK_FILL,GTK_FILL|GTK_EXPAND,2,0);
347 gtk_table_attach(GTK_TABLE(slidertable),label3,2,3,0,1,GTK_FILL,GTK_FILL|GTK_EXPAND,2,0);
349 gtk_container_add(GTK_CONTAINER(sliderframe),slidertable);
351 //gtk_frame_set_shadow_type(GTK_FRAME(sliderframe),GTK_SHADOW_NONE);
353 gtk_container_set_border_width(GTK_CONTAINER(sliderframe),4);
354 gtk_container_set_border_width(GTK_CONTAINER(slidertable),10);
358 gtk_box_pack_start(GTK_BOX(panel->subpanel_box),allbox,0,0,0);
359 gtk_box_pack_start(GTK_BOX(allbox),sliderframe,0,0,0);
362 GtkWidget *hs1=gtk_hseparator_new();
363 GtkWidget *hs2=gtk_hseparator_new();
365 //gtk_box_pack_start(GTK_BOX(allbox),hs3,0,0,0);
366 gtk_box_pack_start(GTK_BOX(allbox),overtable,0,0,10);
367 gtk_box_pack_start(GTK_BOX(allbox),hs1,0,0,0);
368 gtk_box_pack_start(GTK_BOX(allbox),undertable,0,0,10);
369 gtk_box_pack_start(GTK_BOX(allbox),hs2,0,0,0);
370 gtk_box_pack_start(GTK_BOX(allbox),basetable,0,0,10);
372 gtk_container_set_border_width(GTK_CONTAINER(overtable),5);
373 gtk_container_set_border_width(GTK_CONTAINER(undertable),5);
374 gtk_container_set_border_width(GTK_CONTAINER(basetable),5);
378 /* under compand: mode and knee */
380 GtkWidget *envelopebox=gtk_hbox_new(0,0);
381 GtkWidget *rms_button=gtk_radio_button_new_with_label(NULL,"RMS");
382 GtkWidget *peak_button=
383 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rms_button),
384 "peak");
385 GtkWidget *knee_button=gtk_check_button_new_with_label("soft knee");
387 gtk_box_pack_start(GTK_BOX(envelopebox),underlabel,0,0,0);
388 gtk_box_pack_end(GTK_BOX(envelopebox),peak_button,0,0,5);
389 gtk_box_pack_end(GTK_BOX(envelopebox),rms_button,0,0,5);
390 gtk_box_pack_end(GTK_BOX(envelopebox),knee_button,0,0,5);
392 g_signal_connect (G_OBJECT (knee_button), "clicked",
393 G_CALLBACK (mode_knee), &ps->ms->u_softknee);
394 g_signal_connect (G_OBJECT (rms_button), "clicked",
395 G_CALLBACK (mode_rms), &ps->ms->u_mode);
396 g_signal_connect (G_OBJECT (peak_button), "clicked",
397 G_CALLBACK (mode_peak), &ps->ms->u_mode);
399 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rms_button),1);
400 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(knee_button),1);
401 gtk_table_attach(GTK_TABLE(undertable),envelopebox,0,4,0,1,GTK_FILL,0,0,0);
403 ps->u_rms=rms_button;
404 ps->u_peak=peak_button;
405 ps->u_knee=knee_button;
408 /* under compand: ratio */
411 GtkWidget *label=gtk_label_new("compand ratio:");
412 GtkWidget *readout=readout_new("1.55:1");
413 GtkWidget *slider=multibar_slider_new(9,compand_labels,compand_levels,1);
415 ps->under_compand.s=MULTIBAR(slider);
416 ps->under_compand.r=READOUT(readout);
417 ps->under_compand.v=&ps->ms->u_ratio;
419 multibar_callback(MULTIBAR(slider),compand_change,&ps->under_compand);
420 multibar_thumb_set(MULTIBAR(slider),1.,0);
422 gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
424 gtk_table_set_row_spacing(GTK_TABLE(undertable),0,4);
425 gtk_table_attach(GTK_TABLE(undertable),label,0,1,1,2,GTK_FILL,0,2,0);
426 gtk_table_attach(GTK_TABLE(undertable),slider,1,3,1,2,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
427 gtk_table_attach(GTK_TABLE(undertable),readout,3,4,1,2,GTK_FILL,0,0,0);
431 /* under compand: timing */
434 GtkWidget *label=gtk_label_new("attack/decay:");
435 GtkWidget *readout0=readout_new(" 100ms");
436 GtkWidget *readout1=readout_new(" 100ms");
437 GtkWidget *slider=multibar_slider_new(6,timing_labels,timing_levels,2);
439 ps->under_timing.s=MULTIBAR(slider);
440 ps->under_timing.r0=READOUT(readout0);
441 ps->under_timing.r1=READOUT(readout1);
442 ps->under_timing.v0=&ps->ms->u_attack;
443 ps->under_timing.v1=&ps->ms->u_decay;
445 multibar_callback(MULTIBAR(slider),timing_change,&ps->under_timing);
446 multibar_thumb_set(MULTIBAR(slider),1,0);
447 multibar_thumb_set(MULTIBAR(slider),100,1);
449 gtk_misc_set_alignment(GTK_MISC(label),1,.5);
451 gtk_table_set_row_spacing(GTK_TABLE(undertable),2,4);
452 gtk_table_attach(GTK_TABLE(undertable),label,0,1,4,5,GTK_FILL,0,2,0);
453 gtk_table_attach(GTK_TABLE(undertable),slider,1,2,4,5,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
454 gtk_table_attach(GTK_TABLE(undertable),readout0,2,3,4,5,GTK_FILL,0,0,0);
455 gtk_table_attach(GTK_TABLE(undertable),readout1,3,4,4,5,GTK_FILL,0,0,0);
459 /* under compand: lookahead */
462 GtkWidget *label=gtk_label_new("lookahead:");
463 GtkWidget *readout=readout_new("100%");
464 GtkWidget *slider=multibar_slider_new(9,per_labels,per_levels,1);
466 ps->under_lookahead.s=MULTIBAR(slider);
467 ps->under_lookahead.r=READOUT(readout);
468 ps->under_lookahead.v=&ps->ms->u_lookahead;
470 multibar_callback(MULTIBAR(slider),lookahead_change,&ps->under_lookahead);
471 multibar_thumb_set(MULTIBAR(slider),100.,0);
472 multibar_thumb_increment(MULTIBAR(slider),1.,10.);
474 gtk_misc_set_alignment(GTK_MISC(label),1,.5);
476 gtk_table_set_row_spacing(GTK_TABLE(undertable),3,4);
477 gtk_table_attach(GTK_TABLE(undertable),label,0,1,3,4,GTK_FILL,0,2,0);
478 gtk_table_attach(GTK_TABLE(undertable),slider,1,3,3,4,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
479 gtk_table_attach(GTK_TABLE(undertable),readout,3,4,3,4,GTK_FILL,0,0,0);
482 /* over compand: mode and knee */
484 GtkWidget *envelopebox=gtk_hbox_new(0,0);
485 GtkWidget *rms_button=gtk_radio_button_new_with_label(NULL,"RMS");
486 GtkWidget *peak_button=
487 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rms_button),
488 "peak");
489 GtkWidget *knee_button=gtk_check_button_new_with_label("soft knee");
491 gtk_box_pack_start(GTK_BOX(envelopebox),overlabel,0,0,0);
492 gtk_box_pack_end(GTK_BOX(envelopebox),peak_button,0,0,5);
493 gtk_box_pack_end(GTK_BOX(envelopebox),rms_button,0,0,5);
494 gtk_box_pack_end(GTK_BOX(envelopebox),knee_button,0,0,5);
496 g_signal_connect (G_OBJECT (knee_button), "clicked",
497 G_CALLBACK (mode_knee), &ps->ms->o_softknee);
498 g_signal_connect (G_OBJECT (rms_button), "clicked",
499 G_CALLBACK (mode_rms), &ps->ms->o_mode);
500 g_signal_connect (G_OBJECT (peak_button), "clicked",
501 G_CALLBACK (mode_peak), &ps->ms->o_mode);
503 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rms_button),1);
504 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(knee_button),1);
505 gtk_table_attach(GTK_TABLE(overtable),envelopebox,0,4,0,1,GTK_FILL,0,0,0);
506 ps->o_rms=rms_button;
507 ps->o_peak=peak_button;
508 ps->o_knee=knee_button;
511 /* over compand: ratio */
514 GtkWidget *label=gtk_label_new("compand ratio:");
515 GtkWidget *readout=readout_new("1.55:1");
516 GtkWidget *slider=multibar_slider_new(9,compand_labels,compand_levels,1);
518 ps->over_compand.s=MULTIBAR(slider);
519 ps->over_compand.r=READOUT(readout);
520 ps->over_compand.v=&ps->ms->o_ratio;
522 multibar_callback(MULTIBAR(slider),compand_change,&ps->over_compand);
523 multibar_thumb_set(MULTIBAR(slider),1.,0);
525 gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
527 gtk_table_set_row_spacing(GTK_TABLE(overtable),0,4);
528 gtk_table_attach(GTK_TABLE(overtable),label,0,1,1,2,GTK_FILL,0,2,0);
529 gtk_table_attach(GTK_TABLE(overtable),slider,1,3,1,2,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
530 gtk_table_attach(GTK_TABLE(overtable),readout,3,4,1,2,GTK_FILL,0,0,0);
534 /* over compand: timing */
537 GtkWidget *label=gtk_label_new("attack/decay:");
538 GtkWidget *readout0=readout_new(" 100ms");
539 GtkWidget *readout1=readout_new(" 100ms");
540 GtkWidget *slider=multibar_slider_new(6,timing_labels,timing_levels,2);
542 ps->over_timing.s=MULTIBAR(slider);
543 ps->over_timing.r0=READOUT(readout0);
544 ps->over_timing.r1=READOUT(readout1);
545 ps->over_timing.v0=&ps->ms->o_attack;
546 ps->over_timing.v1=&ps->ms->o_decay;
548 multibar_callback(MULTIBAR(slider),timing_change,&ps->over_timing);
549 multibar_thumb_set(MULTIBAR(slider),1,0);
550 multibar_thumb_set(MULTIBAR(slider),100,1);
552 gtk_misc_set_alignment(GTK_MISC(label),1,.5);
554 gtk_table_set_row_spacing(GTK_TABLE(overtable),2,4);
555 gtk_table_attach(GTK_TABLE(overtable),label,0,1,5,6,GTK_FILL,0,2,0);
556 gtk_table_attach(GTK_TABLE(overtable),slider,1,2,5,6,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
557 gtk_table_attach(GTK_TABLE(overtable),readout0,2,3,5,6,GTK_FILL,0,0,0);
558 gtk_table_attach(GTK_TABLE(overtable),readout1,3,4,5,6,GTK_FILL,0,0,0);
562 /* over compand: lookahead */
565 GtkWidget *label=gtk_label_new("lookahead:");
566 GtkWidget *readout=readout_new("100%");
567 GtkWidget *slider=multibar_slider_new(9,per_labels,per_levels,1);
569 ps->over_lookahead.s=MULTIBAR(slider);
570 ps->over_lookahead.r=READOUT(readout);
571 ps->over_lookahead.v=&ps->ms->o_lookahead;
573 multibar_callback(MULTIBAR(slider),lookahead_change,&ps->over_lookahead);
574 multibar_thumb_set(MULTIBAR(slider),100.,0);
575 multibar_thumb_increment(MULTIBAR(slider),1.,10.);
577 gtk_misc_set_alignment(GTK_MISC(label),1,.5);
579 gtk_table_set_row_spacing(GTK_TABLE(overtable),3,4);
580 gtk_table_attach(GTK_TABLE(overtable),label,0,1,3,4,GTK_FILL,0,2,0);
581 gtk_table_attach(GTK_TABLE(overtable),slider,1,3,3,4,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
582 gtk_table_attach(GTK_TABLE(overtable),readout,3,4,3,4,GTK_FILL,0,0,0);
586 /* base compand: mode */
588 GtkWidget *envelopebox=gtk_hbox_new(0,0);
589 GtkWidget *rms_button=gtk_radio_button_new_with_label(NULL,"RMS");
590 GtkWidget *peak_button=
591 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rms_button),
592 "peak");
594 gtk_box_pack_start(GTK_BOX(envelopebox),baselabel,0,0,0);
595 gtk_box_pack_end(GTK_BOX(envelopebox),peak_button,0,0,5);
596 gtk_box_pack_end(GTK_BOX(envelopebox),rms_button,0,0,5);
598 g_signal_connect (G_OBJECT (rms_button), "clicked",
599 G_CALLBACK (mode_rms), &ps->ms->b_mode);
600 g_signal_connect (G_OBJECT (peak_button), "clicked",
601 G_CALLBACK (mode_peak), &ps->ms->b_mode);
603 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rms_button),1);
604 gtk_table_attach(GTK_TABLE(basetable),envelopebox,0,4,0,1,GTK_FILL,0,0,0);
605 ps->b_rms=rms_button;
606 ps->b_peak=peak_button;
609 /* base compand: ratio */
612 GtkWidget *label=gtk_label_new("compand ratio:");
613 GtkWidget *readout=readout_new("1.55:1");
614 GtkWidget *slider=multibar_slider_new(9,compand_labels,compand_levels,1);
616 ps->base_compand.s=MULTIBAR(slider);
617 ps->base_compand.r=READOUT(readout);
618 ps->base_compand.v=&ps->ms->b_ratio;
620 multibar_callback(MULTIBAR(slider),compand_change,&ps->base_compand);
621 multibar_thumb_set(MULTIBAR(slider),1.,0);
623 gtk_misc_set_alignment(GTK_MISC(label),1.,.5);
625 gtk_table_set_row_spacing(GTK_TABLE(basetable),0,4);
626 gtk_table_attach(GTK_TABLE(basetable),label,0,1,1,2,GTK_FILL,0,2,0);
627 gtk_table_attach(GTK_TABLE(basetable),slider,1,3,1,2,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
628 gtk_table_attach(GTK_TABLE(basetable),readout,3,4,1,2,GTK_FILL,0,0,0);
632 /* base compand: timing */
635 GtkWidget *label=gtk_label_new("attack/decay:");
636 GtkWidget *readout0=readout_new(" 100ms");
637 GtkWidget *readout1=readout_new(" 100ms");
638 GtkWidget *slider=multibar_slider_new(6,timing_labels,timing_levels,2);
640 ps->base_timing.s=MULTIBAR(slider);
641 ps->base_timing.r0=READOUT(readout0);
642 ps->base_timing.r1=READOUT(readout1);
643 ps->base_timing.v0=&ps->ms->b_attack;
644 ps->base_timing.v1=&ps->ms->b_decay;
646 multibar_callback(MULTIBAR(slider),timing_change,&ps->base_timing);
647 multibar_thumb_set(MULTIBAR(slider),1,0);
648 multibar_thumb_set(MULTIBAR(slider),100,1);
650 gtk_misc_set_alignment(GTK_MISC(label),1,.5);
652 gtk_table_set_row_spacing(GTK_TABLE(basetable),2,4);
653 gtk_table_attach(GTK_TABLE(basetable),label,0,1,4,5,GTK_FILL,0,2,0);
654 gtk_table_attach(GTK_TABLE(basetable),slider,1,2,4,5,GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,2,0);
655 gtk_table_attach(GTK_TABLE(basetable),readout0,2,3,4,5,GTK_FILL,0,0,0);
656 gtk_table_attach(GTK_TABLE(basetable),readout1,3,4,4,5,GTK_FILL,0,0,0);
660 /* threshold control */
663 ps->bar.readoutu=readout_new(" +0");
664 ps->bar.readouto=readout_new(" +0");
665 ps->bar.slider=multibar_new(15,labels,levels,2,HI_DECAY|LO_DECAY|LO_ATTACK|PEAK_FOLLOW);
666 ps->bar.vu=&ps->ms->u_thresh;
667 ps->bar.vo=&ps->ms->o_thresh;
669 multibar_callback(MULTIBAR(ps->bar.slider),slider_change,&ps->bar);
670 multibar_thumb_set(MULTIBAR(ps->bar.slider),-140.,0);
671 multibar_thumb_set(MULTIBAR(ps->bar.slider),0.,1);
672 multibar_thumb_bounds(MULTIBAR(ps->bar.slider),-140,0);
673 multibar_thumb_increment(MULTIBAR(ps->bar.slider),1.,10.);
676 gtk_table_attach(GTK_TABLE(slidertable),ps->bar.readoutu,0,1,1,2,
677 0,0,0,0);
678 gtk_table_attach(GTK_TABLE(slidertable),ps->bar.slider,1,2,1,2,
679 GTK_FILL|GTK_EXPAND,GTK_EXPAND,0,0);
680 gtk_table_attach(GTK_TABLE(slidertable),ps->bar.readouto,2,3,1,2,
681 0,0,0,0);
684 subpanel_show_all_but_toplevel(panel);
686 return ps;
689 static float *peakfeed=0;
690 static float *rmsfeed=0;
692 void singlepanel_feedback(int displayit){
693 int j,k;
694 if(!peakfeed){
695 peakfeed=malloc(sizeof(*peakfeed)*max(input_ch,OUTPUT_CHANNELS));
696 rmsfeed=malloc(sizeof(*rmsfeed)*max(input_ch,OUTPUT_CHANNELS));
699 if(pull_singlecomp_feedback_master(peakfeed,rmsfeed)==1)
700 multibar_set(MULTIBAR(master_panel->bar.slider),rmsfeed,peakfeed,
701 OUTPUT_CHANNELS,(displayit && singlecomp_master_set.panel_visible));
703 /* channel panels are a bit different; we want each in its native color */
704 if(pull_singlecomp_feedback_channel(peakfeed,rmsfeed)==1){
705 for(j=0;j<input_ch;j++){
706 float rms[input_ch];
707 float peak[input_ch];
709 for(k=0;k<input_ch;k++){
710 rms[k]=-150;
711 peak[k]=-150;
714 rms[j]=rmsfeed[j];
715 peak[j]=peakfeed[j];
717 multibar_set(MULTIBAR(channel_panel[j]->bar.slider),rms,peak,
718 input_ch,(displayit && singlecomp_channel_set[j].panel_visible));
723 void singlepanel_reset(void){
724 int j;
725 multibar_reset(MULTIBAR(master_panel->bar.slider));
726 for(j=0;j<input_ch;j++)
727 multibar_reset(MULTIBAR(channel_panel[j]->bar.slider));
731 void singlepanel_create_master(postfish_mainpanel *mp,
732 GtkWidget *windowbutton,
733 GtkWidget *activebutton){
735 char *shortcut[]={" s "};
736 subpanel_generic *panel=subpanel_create(mp,windowbutton,&activebutton,
737 &singlecomp_master_set.panel_active,
738 &singlecomp_master_set.panel_visible,
739 "_Singleband Compand",shortcut,
740 0,1);
741 master_panel=singlepanel_create_helper(mp,panel,&singlecomp_master_set);
744 void singlepanel_create_channel(postfish_mainpanel *mp,
745 GtkWidget **windowbutton,
746 GtkWidget **activebutton){
747 int i;
749 channel_panel=calloc(input_ch,sizeof(*channel_panel));
751 /* a panel for each channel */
752 for(i=0;i<input_ch;i++){
753 subpanel_generic *panel;
754 char buffer[80];
756 sprintf(buffer,"_Singleband Compand (channel %d)",i+1);
757 panel=subpanel_create(mp,windowbutton[i],activebutton+i,
758 &singlecomp_channel_set[i].panel_active,
759 &singlecomp_channel_set[i].panel_visible,
760 buffer,NULL,
761 i,1);
763 channel_panel[i]=singlepanel_create_helper(mp,panel,singlecomp_channel_set+i);