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)
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.
26 #include <gdk/gdkkeysyms.h>
29 #include "mainpanel.h"
33 #include "limitpanel.h"
36 static GtkWidget
*active
;
37 static GtkWidget
*t_slider
;
38 static GtkWidget
*k_slider
;
39 static GtkWidget
*d_slider
;
40 static GtkWidget
*a_slider
;
42 void limitpanel_state_to_config(int bank
){
43 config_set_integer("limit_active",bank
,0,0,0,0,limit_active
);
44 config_set_integer("limit_set",bank
,0,0,0,0,limitset
.thresh
);
45 config_set_integer("limit_set",bank
,0,0,0,1,limitset
.depth
);
46 config_set_integer("limit_set",bank
,0,0,0,2,limitset
.decay
);
49 void limitpanel_state_from_config(int bank
){
50 config_get_sigat("limit_active",bank
,0,0,0,0,&limit_active
);
51 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(active
),limit_active
);
53 config_get_sigat("limit_set",bank
,0,0,0,0,&limitset
.thresh
);
54 multibar_thumb_set(MULTIBAR(t_slider
),limitset
.thresh
*.1,0);
56 config_get_sigat("limit_set",bank
,0,0,0,1,&limitset
.depth
);
57 multibar_thumb_set(MULTIBAR(k_slider
),limitset
.depth
*.1,0);
59 config_get_sigat("limit_set",bank
,0,0,0,2,&limitset
.decay
);
60 multibar_thumb_set(MULTIBAR(d_slider
),limitset
.decay
*.1,0);
63 static void limit_change(GtkWidget
*w
,gpointer in
){
65 Readout
*r
=(Readout
*)in
;
66 float val
=multibar_get_value(MULTIBAR(w
),0);
68 sprintf(buffer
,"%+5.1fdB",val
);
69 readout_set(r
,buffer
);
71 limitset
.thresh
=rint(val
*10.);
74 static void depth_change(GtkWidget
*w
,gpointer in
){
76 Readout
*r
=(Readout
*)in
;
77 float val
=multibar_get_value(MULTIBAR(w
),0);
79 sprintf(buffer
,"%+5.1fdB",val
);
80 readout_set(r
,buffer
);
82 limitset
.depth
=rint(val
*10.);
85 static void decay_change(GtkWidget
*w
,gpointer in
){
87 Readout
*r
=(Readout
*)in
;
88 float v
=multibar_get_value(MULTIBAR(w
),0);
92 sprintf(buffer
," %4.2fms",v
);
94 sprintf(buffer
," %4.1fms",v
);
96 sprintf(buffer
," %4.0fms",v
);
98 sprintf(buffer
," %4.2fs",v
/1000.);
100 sprintf(buffer
," %4.1fs",v
/1000.);
103 readout_set(READOUT(r
),buffer
);
105 limitset
.decay
=rint(v
*10.);
108 void limitpanel_create(postfish_mainpanel
*mp
,
109 GtkWidget
*windowbutton
,
110 GtkWidget
*activebutton
){
113 char *labels
[9]={"","-80","-60","-40","-20","-10","-6","-3","+0"};
114 float levels
[9]={-80,-60,-50,-40,-30,-10,-6,-3,0};
116 char *labels2
[5]={"","-20","-10","-3","0"};
117 float levels2
[5]={-30,-20,-10,-3,0};
119 char *rlabels
[4]={"","6"," 20","40"};
120 float rlevels
[4]={0,3,10,20};
122 float timing_levels
[6]={.1,1,10,100,1000,10000};
123 char *timing_labels
[6]={"","1ms","10ms","100ms","1s","10s"};
125 char *shortcut
[]={" l "};
127 subpanel_generic
*panel
=subpanel_create(mp
,windowbutton
,&activebutton
,
130 "Hard _Limiter",shortcut
,
133 GtkWidget
*slidertable
=gtk_table_new(4,4,0);
135 GtkWidget
*label1
=gtk_label_new("knee bend");
136 GtkWidget
*label2
=gtk_label_new("knee depth");
137 GtkWidget
*label3
=gtk_label_new("decay speed");
138 GtkWidget
*label4
=gtk_label_new("attenuation");
140 GtkWidget
*readout1
=readout_new("+XXXXdB");
141 GtkWidget
*readout2
=readout_new("+XXXXdB");
142 GtkWidget
*readout3
=readout_new("+XXXXms");
144 GtkWidget
*slider2
=multibar_slider_new(5,labels2
,levels2
,1);
145 GtkWidget
*slider3
=multibar_slider_new(6,timing_labels
,timing_levels
,1);
149 t_slider
=multibar_new(9,labels
,levels
,1,HI_DECAY
|PEAK_FOLLOW
);
150 a_slider
=multibar_new(4,rlabels
,rlevels
,0,PEAK_FOLLOW
);
155 gtk_misc_set_alignment(GTK_MISC(label1
),1,.5);
156 gtk_misc_set_alignment(GTK_MISC(label2
),1,.5);
157 gtk_misc_set_alignment(GTK_MISC(label3
),1,.5);
158 gtk_widget_set_name(label4
,"scalemarker");
160 gtk_table_attach(GTK_TABLE(slidertable
),label1
,0,1,1,2,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,2,0);
161 gtk_table_attach(GTK_TABLE(slidertable
),label2
,0,1,2,3,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,2,0);
162 gtk_table_attach(GTK_TABLE(slidertable
),label3
,0,1,3,4,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,2,0);
163 gtk_table_attach(GTK_TABLE(slidertable
),label4
,3,4,0,1,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,0,0);
165 gtk_table_attach(GTK_TABLE(slidertable
),t_slider
,1,2,1,2,GTK_FILL
|GTK_EXPAND
,GTK_FILL
|GTK_EXPAND
,0,0);
166 gtk_table_attach(GTK_TABLE(slidertable
),a_slider
,3,4,1,2,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,0,0);
167 gtk_table_attach(GTK_TABLE(slidertable
),slider2
,1,2,2,3,GTK_FILL
|GTK_EXPAND
,GTK_FILL
|GTK_EXPAND
,0,4);
168 gtk_table_attach(GTK_TABLE(slidertable
),slider3
,1,2,3,4,GTK_FILL
|GTK_EXPAND
,GTK_FILL
|GTK_EXPAND
,0,0);
170 gtk_table_attach(GTK_TABLE(slidertable
),readout1
,2,3,1,2,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,0,0);
171 gtk_table_attach(GTK_TABLE(slidertable
),readout2
,2,3,2,3,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,0,4);
172 gtk_table_attach(GTK_TABLE(slidertable
),readout3
,2,3,3,4,GTK_FILL
,GTK_FILL
|GTK_EXPAND
,0,0);
174 gtk_container_add(GTK_CONTAINER(panel
->subpanel_box
),slidertable
);
176 multibar_callback(MULTIBAR(t_slider
),limit_change
,readout1
);
177 multibar_callback(MULTIBAR(slider2
),depth_change
,readout2
);
178 multibar_callback(MULTIBAR(slider3
),decay_change
,readout3
);
180 multibar_thumb_set(MULTIBAR(t_slider
),0.,0);
181 multibar_thumb_set(MULTIBAR(slider2
),0.,0);
182 multibar_thumb_set(MULTIBAR(slider3
),10.,0);
184 subpanel_show_all_but_toplevel(panel
);
188 static float *peakfeed
=0;
189 static float *attfeed
=0;
190 static float *zerofeed
=0;
192 void limitpanel_feedback(int displayit
){
195 peakfeed
=malloc(sizeof(*peakfeed
)*OUTPUT_CHANNELS
);
196 attfeed
=malloc(sizeof(*attfeed
)*OUTPUT_CHANNELS
);
197 zerofeed
=malloc(sizeof(*zerofeed
)*OUTPUT_CHANNELS
);
198 for(i
=0;i
<OUTPUT_CHANNELS
;i
++)zerofeed
[i
]=-150.;
201 if(pull_limit_feedback(peakfeed
,attfeed
)==1){
202 multibar_set(MULTIBAR(t_slider
),zerofeed
,peakfeed
,
203 OUTPUT_CHANNELS
,(displayit
&& limit_visible
));
204 multibar_set(MULTIBAR(a_slider
),zerofeed
,attfeed
,
205 OUTPUT_CHANNELS
,(displayit
&& limit_visible
));
209 void limitpanel_reset(void){
210 multibar_reset(MULTIBAR(t_slider
));
211 multibar_reset(MULTIBAR(a_slider
));