Alex: Added the new sources for terminatorX 3.5
[terminatorX.git] / src / tX_vttgui.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999  Alexander K├Ânig
4  
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9  
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14  
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  
19     File: tX_vttgui.cc
20  
21     Description: This implements the gtk+ GUI for the virtual turntable
22                  class implemented in tX_vtt.cc. This code is not in tX_vtt.cc
23                  for mainly to keep the GUI code divided from the audio-rendering
24                  code and as gtk+ callback to C++ method call wrapper.
25 */    
26
27 #include <gtk/gtk.h>
28 #include "tX_vttgui.h"
29 #include "tX_vtt.h"
30 #include "tX_widget.h"
31 #include "tX_wavfunc.h"
32 #include "tX_mastergui.h"
33
34 #ifdef USE_FLASH
35 #include "tX_flash.h"
36 #endif
37 #include <stdio.h>
38
39 #define WID_DYN TRUE, TRUE, 0
40 #define WID_FIX FALSE, FALSE, 0
41
42 #ifdef EXTRA_FRAME
43
44 #define begin_panel(s); dummy=gtk_frame_new(s); \
45         gtk_container_set_border_width( GTK_CONTAINER (dummy), 5); \
46         gtk_widget_show(dummy); \
47         panel_hbox=gtk_vbox_new(FALSE, 0);\
48         gtk_container_add (GTK_CONTAINER(dummy), panel_hbox); \
49         gtk_widget_show(panel_hbox); \
50         label= gtk_label_new(s); \
51         gtk_notebook_append_page(GTK_NOTEBOOK(g->notebook), dummy, label        );
52
53 #else
54
55 #define begin_panel(s); \
56         panel_hbox=gtk_vbox_new(FALSE, 0);\
57         gtk_widget_show(panel_hbox); \
58         label= gtk_label_new(s); \
59         gtk_notebook_append_page(GTK_NOTEBOOK(g->notebook), panel_hbox, label   );
60
61 #endif  
62
63         
64 #define panel_add_item(w); row_vbox=gtk_hbox_new(FALSE,5); \
65         gtk_container_set_border_width(GTK_CONTAINER(row_vbox), 2); \
66         gtk_box_pack_start(GTK_BOX(row_vbox), w, WID_DYN); \
67         gtk_widget_show(w); \
68         gtk_box_pack_start(GTK_BOX(panel_hbox), row_vbox, WID_FIX); gtk_widget_show(row_vbox);
69
70 #define wpanel_add_item(w); \
71         gtk_box_pack_start(GTK_BOX(panel_hbox), w, WID_FIX); gtk_widget_show(row_vbox);
72
73 #define panel_add_label(s); dummy=gtk_label_new(s); \
74         gtk_misc_set_alignment(GTK_MISC(dummy), 0, 0.5); \
75         panel_add_item(dummy);
76
77 #define panel_add_hscale(a, d); dummy=gtk_hscale_new(GTK_ADJUSTMENT(a)); \
78         gtk_scale_set_digits(GTK_SCALE(dummy), d); \
79         gtk_scale_set_value_pos(GTK_SCALE(dummy), GTK_POS_RIGHT); \
80         panel_add_item(dummy);
81
82 #define begin_row(); row_vbox=gtk_hbox_new(FALSE, 5); \
83         gtk_container_set_border_width(GTK_CONTAINER(row_vbox), 5); \
84         gtk_box_pack_start(GTK_BOX(panel_hbox), row_vbox, WID_FIX); gtk_widget_show(row_vbox);
85         
86 #define row_add_item_fix(w); gtk_box_pack_start(GTK_BOX(row_vbox), w, WID_FIX); gtk_widget_show(w);
87 #define row_add_item_dyn(w); gtk_box_pack_start(GTK_BOX(row_vbox), w, WID_DYN); gtk_widget_show(w);
88
89 #define row_add_hscale(a, d); dummy=gtk_hscale_new(GTK_ADJUSTMENT(a)); \
90         gtk_scale_set_digits(GTK_SCALE(dummy), d); \
91         gtk_scale_set_value_pos(GTK_SCALE(dummy), GTK_POS_LEFT); \
92         row_add_item_dyn(dummy);
93         
94 #define row_add_label(s); dummy=gtk_label_new(s); \
95         gtk_misc_set_alignment(GTK_MISC(dummy), 0.5, 0.5); \
96         row_add_item_fix(dummy);
97         
98 #define FILENAME_BUTTON_MAX 25
99
100 void nicer_filename(char *dest, char *source)
101 {
102                 char *fn;
103                 char temp[PATH_MAX];
104                 int i;
105                 
106                 fn=strrchr(source, '/');
107                 if (fn) fn++;
108                 else fn=source;
109                 
110                 strcpy (temp, fn);
111                 
112                 fn=strrchr(temp, '.');
113                 if (fn) *fn=0;
114                 
115                 if (strlen(temp) > FILENAME_BUTTON_MAX)
116                 {
117                         temp[FILENAME_BUTTON_MAX-3]='.';
118                         temp[FILENAME_BUTTON_MAX-2]='.';
119                         temp[FILENAME_BUTTON_MAX-1]='.';
120                         temp[FILENAME_BUTTON_MAX]=0;
121                 } 
122                 strcpy (dest, temp);
123 }
124
125 GtkSignalFunc name_changed(GtkWidget *wid, vtt_class *vtt)
126 {
127         vtt->set_name(gtk_entry_get_text(GTK_ENTRY(wid)));
128 }
129
130 GtkSignalFunc volume_changed(GtkWidget *wid, vtt_class *vtt)
131 {
132         vtt->set_volume(GTK_ADJUSTMENT(wid)->value);
133 }
134
135 GtkSignalFunc pitch_changed(GtkWidget *wid, vtt_class *vtt)
136 {
137         vtt->set_pitch(GTK_ADJUSTMENT(wid)->value);
138 }
139
140 GtkSignalFunc cancel_load_file(GtkWidget *wid, vtt_class *vtt)
141 {
142         vtt->gui.file_dialog=NULL;
143         if (vtt->gui.fs) gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
144         return(0);
145 }
146
147 GtkSignalFunc do_load_file(GtkWidget *wid, vtt_class *vtt)
148 {
149         int ret;
150         char newfile[PATH_MAX];
151         char buffer[1024]="Couldn't open loop file: ";
152         char fn[FILENAME_BUTTON_MAX];
153         
154         int16_t *newbuffer;
155         unsigned int newsize;
156
157         strcpy(newfile, gtk_file_selection_get_filename(GTK_FILE_SELECTION(vtt->gui.fs)));
158         gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
159
160         ret = load_wav(newfile, &newbuffer, &newsize);
161         
162         if (ret)
163         {
164                 puts("error");
165         }
166         else
167         {
168                 vtt->set_file_data(newfile, newbuffer, newsize/sizeof(int16_t));
169
170                 nicer_filename(fn, newfile);
171                 
172                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), fn);
173         }       
174         vtt->gui.file_dialog=NULL;
175 }
176
177 GtkSignalFunc load_file(GtkWidget *wid, vtt_class *vtt)
178 {       
179         char buffer[512];
180         
181         if (vtt->gui.file_dialog)
182         {
183                 gdk_window_raise(vtt->gui.file_dialog);
184                 return(0);
185         }
186         
187         sprintf(buffer, "Select Audio File for %s", vtt->name);
188         vtt->gui.fs=gtk_file_selection_new(buffer);
189         
190         if (strlen(vtt->filename) > 0)
191         {
192                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs), vtt->filename);        
193         }
194         
195         gtk_widget_show(GTK_WIDGET(vtt->gui.fs));
196         
197         vtt->gui.file_dialog=vtt->gui.fs->window;
198         
199         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_load_file), vtt);
200         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_load_file), vtt);    
201         gtk_signal_connect (GTK_OBJECT(vtt->gui.fs), "delete-event", GTK_SIGNAL_FUNC(cancel_load_file), vtt);   
202 }
203
204
205 GtkSignalFunc delete_vtt(GtkWidget *wid, vtt_class *vtt)
206 {
207         delete(vtt);
208 }
209
210 GtkSignalFunc clone_vtt(GtkWidget *wid, vtt_class *vtt)
211 {
212         vtt->stop();
213 }
214
215 GtkSignalFunc trigger_vtt(GtkWidget *wid, vtt_class *vtt)
216 {
217         vtt->trigger();
218 }
219
220 GtkSignalFunc stop_vtt(GtkWidget *wid, vtt_class *vtt)
221 {
222         vtt->stop();
223 }
224
225 GtkSignalFunc autotrigger_toggled(GtkWidget *wid, vtt_class *vtt)
226 {
227         vtt->set_autotrigger(GTK_TOGGLE_BUTTON(wid)->active);
228 }
229
230 GtkSignalFunc loop_toggled(GtkWidget *wid, vtt_class *vtt)
231 {
232         vtt->set_loop(GTK_TOGGLE_BUTTON(wid)->active);
233 }
234
235 GtkSignalFunc lp_enabled(GtkWidget *wid, vtt_class *vtt)
236 {
237         vtt->lp_set_enable(GTK_TOGGLE_BUTTON(wid)->active);
238 }
239
240 GtkSignalFunc lp_gain_changed(GtkWidget *wid, vtt_class *vtt)
241 {
242         vtt->lp_set_gain(GTK_ADJUSTMENT(wid)->value);
243 }
244
245 GtkSignalFunc lp_reso_changed(GtkWidget *wid, vtt_class *vtt)
246 {
247         vtt->lp_set_reso(GTK_ADJUSTMENT(wid)->value);
248 }
249
250 GtkSignalFunc lp_freq_changed(GtkWidget *wid, vtt_class *vtt)
251 {
252         vtt->lp_set_freq(GTK_ADJUSTMENT(wid)->value);
253 }
254
255 GtkSignalFunc ec_enabled(GtkWidget *wid, vtt_class *vtt)
256 {
257         vtt->ec_set_enable(GTK_TOGGLE_BUTTON(wid)->active);
258 }
259
260 GtkSignalFunc ec_length_changed(GtkWidget *wid, vtt_class *vtt)
261 {
262         vtt->ec_set_length(GTK_ADJUSTMENT(wid)->value);
263 }
264
265 GtkSignalFunc ec_feedback_changed(GtkWidget *wid, vtt_class *vtt)
266 {
267         vtt->ec_set_feedback(GTK_ADJUSTMENT(wid)->value);
268 }
269
270 GtkSignalFunc master_setup(GtkWidget *wid, vtt_class *vtt)
271 {
272         vtt->set_sync_master(GTK_TOGGLE_BUTTON(wid)->active);
273 }
274
275 GtkSignalFunc client_setup(GtkWidget *wid, vtt_class *vtt)
276 {
277         int client;
278         int cycles;
279         
280         client=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client));   
281         cycles=(int) GTK_ADJUSTMENT(vtt->gui.cycles)->value;    
282         
283         vtt->set_sync_client(client, cycles);
284 }
285
286 GtkSignalFunc control_changed(GtkWidget *wid, vtt_class *vtt)
287 {
288         int x,y;
289         vtt_gui *g=&vtt->gui;
290         
291         if (GTK_TOGGLE_BUTTON(g->x_scratch)->active) x=CONTROL_SCRATCH;
292         else if (GTK_TOGGLE_BUTTON(g->x_volume)->active) x=CONTROL_VOLUME;
293         else if (GTK_TOGGLE_BUTTON(g->x_lp_cutoff)->active) x=CONTROL_CUTOFF;
294         else if (GTK_TOGGLE_BUTTON(g->x_ec_feedback)->active) x=CONTROL_FEEDBACK;
295         else if (GTK_TOGGLE_BUTTON(g->x_nothing)->active) x=CONTROL_NOTHING;
296
297         if (GTK_TOGGLE_BUTTON(g->y_scratch)->active) y=CONTROL_SCRATCH;
298         else if (GTK_TOGGLE_BUTTON(g->y_volume)->active) y=CONTROL_VOLUME;
299         else if (GTK_TOGGLE_BUTTON(g->y_lp_cutoff)->active) y=CONTROL_CUTOFF;
300         else if (GTK_TOGGLE_BUTTON(g->y_ec_feedback)->active) y=CONTROL_FEEDBACK;
301         else if (GTK_TOGGLE_BUTTON(g->y_nothing)->active) y=CONTROL_NOTHING;
302         
303         vtt->set_controls(x,y);
304 }
305
306 #define connect_entry(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "activate", (GtkSignalFunc) func, (void *) vtt);
307 #define connect_adj(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "value_changed", (GtkSignalFunc) func, (void *) vtt);
308 #define connect_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "clicked", (GtkSignalFunc) func, (void *) vtt);
309
310 void gui_connect_signals(vtt_class *vtt)
311 {
312         vtt_gui *g=&vtt->gui;
313
314         connect_entry(name, name_changed);
315         connect_adj(volume, volume_changed);
316         connect_adj(pitch, pitch_changed);
317         connect_button(file, load_file);
318         
319         connect_button(del, delete_vtt);
320 //      connect_button(clone, clone_vtt);
321         connect_button(trigger, trigger_vtt);
322         connect_button(stop, stop_vtt);
323         connect_button(autotrigger, autotrigger_toggled);
324         connect_button(loop, loop_toggled);
325         connect_button(sync_master, master_setup);
326         connect_button(sync_client, client_setup);
327         connect_adj(cycles, client_setup);
328         
329         connect_button(x_scratch, control_changed);
330         connect_button(x_volume, control_changed);
331         connect_button(x_lp_cutoff, control_changed);
332         connect_button(x_ec_feedback, control_changed);
333         connect_button(x_nothing, control_changed);
334
335         connect_button(y_scratch, control_changed);
336         connect_button(y_volume, control_changed);
337         connect_button(y_lp_cutoff, control_changed);
338         connect_button(y_ec_feedback, control_changed);
339         connect_button(y_nothing, control_changed);
340         
341         connect_button(lp_enable, lp_enabled);
342         connect_adj(lp_gain, lp_gain_changed);
343         connect_adj(lp_reso, lp_reso_changed);
344         connect_adj(lp_freq, lp_freq_changed);
345         
346         connect_button(ec_enable, ec_enabled);
347         connect_adj(ec_length, ec_length_changed);
348         connect_adj(ec_feedback, ec_feedback_changed);
349 }
350         
351 void build_vtt_gui(vtt_class *vtt)
352 {
353         GtkWidget *dummy;
354         GtkWidget *label;
355         GtkWidget *main_vbox;
356         GtkWidget *main_hbox;
357         GtkWidget *panel_hbox;
358         GtkWidget *row_vbox;
359         GSList *radio_group;
360         char nice_name[FILENAME_BUTTON_MAX];
361         
362         vtt_gui *g;
363         
364 //      puts("Creating");
365         
366         g=&vtt->gui;
367         vtt->have_gui=1;
368         g->frame=gtk_frame_new(vtt->name);
369         gtk_container_set_border_width( GTK_CONTAINER(g->frame), 5);
370         gtk_widget_show(g->frame);
371         
372         main_vbox=gtk_hbox_new(FALSE, 5);
373         gtk_container_set_border_width( GTK_CONTAINER(main_vbox), 5);
374
375         g->notebook=gtk_notebook_new();
376         gtk_notebook_set_tab_pos(GTK_NOTEBOOK(g->notebook), GTK_POS_LEFT);
377         gtk_box_pack_start(GTK_BOX(main_vbox), g->notebook, WID_FIX);
378         gtk_widget_show(g->notebook);
379
380         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
381         gtk_box_pack_start(GTK_BOX(main_vbox), g->display, WID_DYN);
382         gtk_widget_show(g->display);    
383         
384 #ifdef USE_FLASH
385         g->flash=gtk_tx_flash_new();
386         gtk_box_pack_start(GTK_BOX(main_vbox), g->flash, WID_FIX);
387         gtk_widget_show(g->flash);              
388 #endif  
389         
390         gtk_container_add(GTK_CONTAINER (g->frame), main_vbox);
391         gtk_widget_show(main_vbox);
392                 
393         begin_panel("Main");
394         
395         begin_row();
396         
397         g->name = gtk_entry_new_with_max_length(256);   
398         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
399         row_add_item_dyn(g->name);
400         gtk_widget_set_usize(g->name, 40, g->name->requisition.height);
401         
402         g->del=gtk_button_new_with_label("Delete");
403         row_add_item_fix(g->del);
404         
405         nicer_filename(nice_name, vtt->filename);
406         g->file = gtk_button_new_with_label(nice_name);
407         panel_add_item(g->file);
408                 
409         panel_add_label("Volume:");
410         
411         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
412         panel_add_hscale(g->volume, 3);
413         
414         panel_add_label("Pitch:");
415         
416         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
417         panel_add_hscale(g->pitch, 2);
418                 
419 /*      g->clone=gtk_button_new_with_label("Clone");
420         row_add_item_dyn(g->clone);*/
421         
422         begin_panel("Trigger");
423         
424         begin_row();
425         
426         g->trigger=gtk_button_new_with_label("Trigger!");
427         row_add_item_dyn(g->trigger);
428         
429         g->stop=gtk_button_new_with_label("Stop.");
430         row_add_item_dyn(g->stop);
431         
432         g->autotrigger=gtk_check_button_new_with_label("Autotrigger");
433         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
434         panel_add_item(g->autotrigger);
435         
436         g->loop=gtk_check_button_new_with_label("Loop");
437         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
438         panel_add_item(g->loop);
439         
440         g->sync_master=gtk_check_button_new_with_label("Sync Master");
441         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
442         panel_add_item(g->sync_master);
443         
444         begin_row();
445         
446         g->sync_client=gtk_check_button_new_with_label("Sync Client");
447         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
448         row_add_item_fix(g->sync_client);
449         
450         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,1));
451         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
452         row_add_item_dyn(dummy);
453         
454         begin_panel("X-Control");
455                 
456         g->x_scratch=gtk_radio_button_new_with_label(NULL, "Scratching");
457         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->x_scratch));
458         if (vtt->x_control==CONTROL_SCRATCH) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->x_scratch), 1);  
459         panel_add_item(g->x_scratch);
460
461         g->x_volume=gtk_radio_button_new_with_label(radio_group, "Volume");
462         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->x_volume));
463         if (vtt->x_control==CONTROL_VOLUME) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->x_volume), 1);    
464         panel_add_item(g->x_volume);
465         
466         g->x_lp_cutoff=gtk_radio_button_new_with_label(radio_group, "LP Cutoff Freq.");
467         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->x_lp_cutoff));
468         if (vtt->x_control==CONTROL_CUTOFF) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->x_lp_cutoff), 1); 
469         panel_add_item(g->x_lp_cutoff);
470         
471         g->x_ec_feedback=gtk_radio_button_new_with_label(radio_group, "Echo Feedback");
472         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->x_ec_feedback));
473         if (vtt->x_control==CONTROL_FEEDBACK) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->x_ec_feedback), 1);     
474         panel_add_item(g->x_ec_feedback);
475         
476         g->x_nothing=gtk_radio_button_new_with_label(radio_group, "Nothing");
477         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->x_nothing));
478         if (vtt->x_control==CONTROL_NOTHING) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->x_nothing), 1);  
479         panel_add_item(g->x_nothing);
480                 
481         begin_panel("Y-Control");
482         
483         g->y_scratch=gtk_radio_button_new_with_label(NULL, "Scratching");
484         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->y_scratch));
485         if (vtt->y_control==CONTROL_SCRATCH) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->y_scratch), 1);  
486         panel_add_item(g->y_scratch);
487
488         g->y_volume=gtk_radio_button_new_with_label(radio_group, "Volume");
489         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->y_volume));
490         if (vtt->y_control==CONTROL_VOLUME) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->y_volume), 1);    
491         panel_add_item(g->y_volume);
492         
493         g->y_lp_cutoff=gtk_radio_button_new_with_label(radio_group, "LP Cutoff Freq.");
494         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->y_lp_cutoff));
495         if (vtt->y_control==CONTROL_CUTOFF) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->y_lp_cutoff), 1); 
496         panel_add_item(g->y_lp_cutoff);
497         
498         g->y_ec_feedback=gtk_radio_button_new_with_label(radio_group, "Echo Feedback");
499         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->y_ec_feedback));
500         if (vtt->y_control==CONTROL_FEEDBACK) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->y_ec_feedback), 1);     
501         panel_add_item(g->y_ec_feedback);
502         
503         g->y_nothing=gtk_radio_button_new_with_label(radio_group, "Nothing");
504         radio_group=gtk_radio_button_group( GTK_RADIO_BUTTON(g->y_nothing));
505         if (vtt->y_control==CONTROL_NOTHING) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->y_nothing), 1);  
506         panel_add_item(g->y_nothing);
507                 
508         begin_panel("Lowpass");
509         
510         g->lp_enable=gtk_check_button_new_with_label("Enable");
511         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
512         panel_add_item(g->lp_enable);
513                 
514         panel_add_label("Input Gain:");
515         
516         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
517         panel_add_hscale(g->lp_gain, 2);
518
519         panel_add_label("Resonance:");
520         
521         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
522         panel_add_hscale(g->lp_reso, 2);
523         
524         panel_add_label("Frequency:");
525         
526         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
527         panel_add_hscale(g->lp_freq, 2);
528
529         begin_panel("Echo");
530
531         g->ec_enable=gtk_check_button_new_with_label("Enable");
532         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
533         panel_add_item(g->ec_enable);
534         
535         panel_add_label("Duration:");
536         
537         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 2, 0.1, 0.01, 0.001));
538         panel_add_hscale(g->ec_length, 2);
539         
540         panel_add_label("Feedback:");
541                 
542         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
543         panel_add_hscale(g->ec_feedback, 2);
544         
545         g->file_dialog=NULL;
546         
547         gui_connect_signals(vtt);
548 }
549
550 void gui_set_name(vtt_class *vtt, char *newname)
551 {
552         gtk_frame_set_label(GTK_FRAME(vtt->gui.frame), newname);
553         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
554 }
555
556 void gui_set_filename (vtt_class *vtt, char *newname)
557 {
558         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), newname);
559 }
560
561 void gui_update_display(vtt_class *vtt)
562 {
563         if (vtt->buffer) gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
564 }
565
566 void destroy_gui(vtt_class *vtt)
567 {
568         gtk_widget_destroy(vtt->gui.frame);
569 }
570
571 void recreate_gui(vtt_class *vtt, GtkWidget *daddy)
572 {
573         build_vtt_gui(vtt);
574         gtk_box_pack_start(GTK_BOX(daddy), vtt->gui.frame, TRUE, TRUE, 0);
575         gtk_widget_show(vtt->gui.frame);
576 }
577
578 void delete_gui(vtt_class *vtt)
579 {
580         gtk_widget_destroy(vtt->gui.frame);
581         rebuild_vtts(1);
582 }
583
584 void update_all_vtts()
585 {
586         list <vtt_class *> :: iterator vtt;
587         f_prec temp;
588         
589         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
590         {
591                 if ((*vtt)->is_playing)
592                 {
593                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
594 #ifdef USE_FLASH
595                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
596                         (*vtt)->max_value=0;
597                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp);
598 #endif          
599                 }
600         }
601 }
602
603 void cleanup_vtt(vtt_class *vtt)
604 {
605                 gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
606 #ifdef USE_FLASH
607                 gtk_tx_flash_set_level(vtt->gui.flash, 0.0);
608                 gtk_tx_flash_clear(vtt->gui.flash);
609 #endif          
610 }
611
612 void cleanup_all_vtts()
613 {
614         list <vtt_class *> :: iterator vtt;
615         
616         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
617         {
618                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
619 #ifdef USE_FLASH
620                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0);
621                 gtk_tx_flash_clear((*vtt)->gui.flash);
622 #endif          
623         }
624 }
625
626 void gui_clear_master_button(vtt_class *vtt)
627 {
628         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
629 }
630
631 void gui_show_frame(vtt_class *vtt, int show)
632 {
633         gtk_tx_show_frame(GTK_TX(vtt->gui.display), show);
634 }
635
636 void show_all_guis(int show)
637 {
638         list <vtt_class *> :: iterator vtt;
639         
640         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
641         {
642                 if (show)
643                 {
644                         gtk_widget_show((*vtt)->gui.notebook);
645                 }
646                 else
647                 {
648                         gtk_widget_hide((*vtt)->gui.notebook);          
649                 }
650         }
651 }