fixed wav-write, xfree-4-input-hack and adrian's solo patch - alex
[terminatorX.git] / src / tX_vttgui.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999, 2000  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 <gdk/gdk.h>
28 #include <gtk/gtk.h>
29 #include "tX_vttgui.h"
30 #include "tX_vtt.h"
31 #include "tX_widget.h"
32 #include "tX_mastergui.h"
33 #include "tX_loaddlg.h"
34 #include "tX_prelis.h"
35 #include "tX_pbutton.h"
36 #include "tX_global.h"
37 #include "tX_extdial.h"
38 #include "tX_panel.h"
39 #include "tX_ladspa.h"
40
41 #ifdef USE_DIAL
42 #include "tX_dial.h"
43 #endif
44
45 #ifdef USE_FLASH
46 #include "tX_flash.h"
47 #endif
48 #include <stdio.h>
49
50 #define WID_DYN TRUE, TRUE, 0
51 #define WID_FIX FALSE, FALSE, 0
52
53 #define FILENAME_BUTTON_MAX 20
54
55 void nicer_filename(char *dest, char *source)
56 {
57                 char *fn;
58                 char temp[PATH_MAX];
59                 int i;
60                 
61                 fn=strrchr(source, '/');
62                 if (fn) fn++;
63                 else fn=source;
64                 
65                 strcpy (temp, fn);
66                 
67                 fn=strrchr(temp, '.');
68                 if (fn) *fn=0;
69                 
70                 if (strlen(temp) > FILENAME_BUTTON_MAX)
71                 {
72                         temp[FILENAME_BUTTON_MAX-3]='.';
73                         temp[FILENAME_BUTTON_MAX-2]='.';
74                         temp[FILENAME_BUTTON_MAX-1]='.';
75                         temp[FILENAME_BUTTON_MAX]=0;
76                 } 
77                 strcpy (dest, temp);
78 }
79
80 void name_changed(GtkWidget *wid, vtt_class *vtt)
81 {
82         vtt->set_name(gtk_entry_get_text(GTK_ENTRY(wid)));
83 }
84
85 void volume_changed(GtkWidget *wid, vtt_class *vtt)
86 {
87         vtt->sp_volume.receive_gui_value(2.0-GTK_ADJUSTMENT(wid)->value);
88 }
89
90 void pan_changed(GtkWidget *wid, vtt_class *vtt)
91 {
92       vtt->sp_pan.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
93 }
94
95 void pitch_changed(GtkWidget *wid, vtt_class *vtt)
96 {
97         vtt->sp_pitch.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
98 }
99
100 GtkSignalFunc trigger_prelis(GtkWidget *w)
101 {
102         GtkFileSelection *fs;
103         
104         fs=GTK_FILE_SELECTION(gtk_widget_get_toplevel(w));
105         
106         prelis_start(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)));
107         return(0);
108 }
109
110 void cancel_load_file(GtkWidget *wid, vtt_class *vtt)
111 {
112         prelis_stop();
113         
114         vtt->gui.file_dialog=NULL;
115         if (vtt->gui.fs) gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
116 }
117
118 int quit_load_file(GtkWidget *wid, vtt_class *vtt)
119 {
120         //vtt->gui.file_dialog=NULL;
121         //prelis_stop();
122         return 1;
123 }
124
125 char global_filename_buffer[PATH_MAX];
126
127 void load_part(char *newfile, vtt_class *vtt)
128 {
129         int ret=0;
130         char *fn;
131
132         ld_create_loaddlg(TX_LOADDLG_MODE_SINGLE, 1);
133         ld_set_filename(newfile);
134
135         ret = vtt->load_file(newfile);
136         
137         ld_destroy();
138         if (ret)
139         {
140                 switch(ret)
141                 {
142                         case TX_AUDIO_ERR_ALLOC:
143                         tx_note("Error loading file: failed to allocate memory");
144                         break;
145                         case TX_AUDIO_ERR_PIPE_READ:
146                         tx_note("Error loading file: broken pipe (File not supported/corrupt?)");
147                         break;
148                         case TX_AUDIO_ERR_SOX:
149                         tx_note("Error loading file: couldn't execute sox");
150                         break;
151                         case TX_AUDIO_ERR_MPG123:
152                         tx_note("Error loading file: couldn't execute mpg123");
153                         break;
154                         case TX_AUDIO_ERR_WAV_NOTFOUND:
155                         tx_note("Error loading file: file not found");
156                         break;
157                         case TX_AUDIO_ERR_NOT_16BIT:
158                         tx_note("Error loading file: RIFF/WAV is not 16 Bit.");
159                         break;
160                         case TX_AUDIO_ERR_NOT_MONO:
161                         tx_note("Error loading file: RIFF/WAV is not mono");
162                         break;
163                         case TX_AUDIO_ERR_WAV_READ:
164                         tx_note("Error loading file: RIFF/WAV corrupt?");
165                         break;
166                         case TX_AUDIO_ERR_NOT_SUPPORTED:
167                         tx_note("Error loading file: filetype not supported.");
168                         break;
169                         default:                                        
170                         tx_note("OOPS: An unknown error occured - This shouldn't happen :(");   
171                 }
172         }
173         else
174         {
175                 nicer_filename(global_filename_buffer, newfile);
176 //              strcpy(global_filename_buffer, fn);
177                 
178                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
179         }       
180 }
181
182 void do_load_file(GtkWidget *wid, vtt_class *vtt)
183 {
184         int ret;
185         char newfile[PATH_MAX];
186         char buffer[1024]="Couldn't open loop file: ";
187         char fn[FILENAME_BUTTON_MAX];
188         
189         int16_t *newbuffer;
190         unsigned int newsize;
191         
192         prelis_stop();
193
194         strcpy(newfile, gtk_file_selection_get_filename(GTK_FILE_SELECTION(vtt->gui.fs)));
195         gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
196         
197         load_part(newfile, vtt);
198         
199         if (!globals.current_path)
200         {
201                 free(globals.current_path);
202                 globals.current_path = NULL;
203         }
204
205         globals.current_path = strdup(newfile);
206
207         vtt->gui.file_dialog=NULL;
208 }
209
210 void drop_file(GtkWidget *widget, GdkDragContext *context,
211                 gint x, gint y, GtkSelectionData *selection_data,
212                 guint info, guint time, vtt_class *vtt)
213 {
214         char filename[PATH_MAX];
215         char *fn;
216         int s;
217         void *prr;
218         
219         strncpy(filename, (char *) selection_data->data, (size_t) selection_data->length);
220         filename[selection_data->length]=0;
221
222         fn = strchr (filename, '\r');
223         *fn=0;  
224         
225         fn = strchr (filename, ':');
226         if (fn) fn++; else fn=(char *) selection_data->data;
227         
228         load_part(fn, vtt);
229 }
230
231
232 GtkSignalFunc load_file(GtkWidget *wid, vtt_class *vtt)
233 {       
234         char buffer[512];
235         
236         if (vtt->gui.file_dialog)
237         {
238                 //puts("praise");
239                 gdk_window_raise(vtt->gui.file_dialog);
240                 return(0);
241         }
242         
243         sprintf(buffer, "Select Audio File for %s", vtt->name);
244         vtt->gui.fs=gtk_file_selection_new(buffer);
245         
246         if (strlen(vtt->filename) > 0)
247         {
248                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs), vtt->filename);        
249         }
250         
251         gtk_widget_show(GTK_WIDGET(vtt->gui.fs));
252         
253         vtt->gui.file_dialog=vtt->gui.fs->window;
254         
255         if (globals.current_path)
256                 {
257                         gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs),globals.current_path);
258                 }
259         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_load_file), vtt);
260         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_load_file), vtt);    
261         gtk_signal_connect (GTK_OBJECT(vtt->gui.fs), "delete-event", GTK_SIGNAL_FUNC(quit_load_file), vtt);     
262         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->file_list), "select_row", GTK_SIGNAL_FUNC(trigger_prelis), vtt->gui.fs);
263 }
264
265
266 void delete_vtt(GtkWidget *wid, vtt_class *vtt)
267 {
268         if (audioon) tx_note("Sorry, you'll have to stop playback first.");
269         else
270         delete(vtt);
271 }
272
273 void edit_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
274 {
275         char command[2*PATH_MAX];
276
277         if (vtt->samples_in_buffer == 0)
278         {
279                 tx_note("Nothing to edit.");
280         }
281         else
282         if (strlen(globals.file_editor)>0)
283         {
284                 sprintf(command, "%s \"%s\" &", globals.file_editor, vtt->filename);
285                 system(command); /*) tx_note("Failed to run the soundfile editor."); */
286         }
287         else
288         {
289                 tx_note("No soundfile editor configured.");
290         }
291 }
292
293 void reload_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
294 {
295         char reload_buffer[PATH_MAX];
296         
297         while (gtk_events_pending()) gtk_main_iteration();
298         
299 //      puts(vtt->filename);
300         if (vtt->samples_in_buffer > 0)
301         {
302                 strcpy(reload_buffer, vtt->filename);
303                 load_part(reload_buffer, vtt);
304         }
305         else tx_note("Nothing to reload.");
306 }
307
308 void clone_vtt(GtkWidget *wid, vtt_class *vtt)
309 {
310         vtt->stop();
311 }
312
313 void trigger_vtt(GtkWidget *wid, vtt_class *vtt)
314 {
315         vtt->sp_trigger.receive_gui_value((float) 1.0);
316 }
317
318 void stop_vtt(GtkWidget *wid, vtt_class *vtt)
319 {
320         vtt->sp_trigger.receive_gui_value((float) 0.0);
321 }
322
323 void autotrigger_toggled(GtkWidget *wid, vtt_class *vtt)
324 {
325         vtt->set_autotrigger(GTK_TOGGLE_BUTTON(wid)->active);
326 }
327
328 void loop_toggled(GtkWidget *wid, vtt_class *vtt)
329 {
330         vtt->sp_loop.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
331 }
332
333 void lp_enabled(GtkWidget *wid, vtt_class *vtt)
334 {
335         vtt->sp_lp_enable.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
336 }
337
338 void lp_gain_changed(GtkWidget *wid, vtt_class *vtt)
339 {
340         vtt->sp_lp_gain.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
341 }
342
343 void lp_reso_changed(GtkWidget *wid, vtt_class *vtt)
344 {
345         vtt->sp_lp_reso.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
346 }
347
348 void lp_freq_changed(GtkWidget *wid, vtt_class *vtt)
349 {
350         vtt->sp_lp_freq.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
351 }
352
353 void ec_enabled(GtkWidget *wid, vtt_class *vtt)
354 {
355         vtt->sp_ec_enable.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
356 }
357
358 void ec_length_changed(GtkWidget *wid, vtt_class *vtt)
359 {
360         vtt->sp_ec_length.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
361 }
362
363 void ec_feedback_changed(GtkWidget *wid, vtt_class *vtt)
364 {
365         vtt->sp_ec_feedback.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
366 }
367
368 void ec_pan_changed(GtkWidget *wid, vtt_class *vtt)
369 {
370         vtt->sp_ec_pan.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
371 }
372
373 void ec_volume_changed(GtkWidget *wid, vtt_class *vtt)
374 {
375         vtt->sp_ec_volume.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
376 }
377
378 void master_setup(GtkWidget *wid, vtt_class *vtt)
379 {
380         vtt->set_sync_master(GTK_TOGGLE_BUTTON(wid)->active);
381 }
382
383 void client_setup(GtkWidget *wid, vtt_class *vtt)
384 {
385         int client;
386         
387         client=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client));   
388         vtt->sp_sync_client.receive_gui_value(client);
389 }
390
391 void client_setup_number(GtkWidget *wid, vtt_class *vtt)
392 {
393         int cycles;
394         
395         cycles=(int) GTK_ADJUSTMENT(vtt->gui.cycles)->value;    
396         
397         vtt->sp_sync_cycles.receive_gui_value(cycles);
398 }
399
400 void mute_volume(GtkWidget *widget, vtt_class *vtt)
401 {
402        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
403                vtt->set_mute(1);
404        else
405                vtt->set_mute(0);
406        //vtt->sp_volume.receive_gui_value(0);
407 }
408
409 void solo_vtt(GtkWidget *widget, vtt_class *vtt)
410 {
411        list <vtt_class *> :: iterator it_vtt;
412
413        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
414                
415                for (it_vtt=vtt_class::main_list.begin(); it_vtt!=vtt_class::main_list.end(); it_vtt++) {
416                        (*it_vtt)->set_mute(1);
417                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*it_vtt)->gui.mute), TRUE);
418                }
419                
420                vtt->set_mute(0);
421                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.mute), FALSE);
422
423        }
424        else {
425                for (it_vtt=vtt_class::main_list.begin(); it_vtt!=vtt_class::main_list.end(); it_vtt++) {
426                        (*it_vtt)->set_mute(0);
427                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*it_vtt)->gui.mute), FALSE);
428                }
429        }
430
431 }      
432
433 void vg_display_xcontrol(vtt_class *vtt)
434 {
435         char buffer[2048];
436         
437         if (vtt->x_par)
438         {
439                 strcpy(buffer, vtt->x_par->get_name());
440                 if (strlen(buffer)>35) 
441                 {
442                         buffer[34] = '.';
443                         buffer[35] = '.';
444                         buffer[36] = '.';
445                         buffer[37] = 0;                 
446                 }
447                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), buffer);                
448         }
449         else
450         {
451                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), "Nothing");
452         }
453 }
454
455 void vg_display_ycontrol(vtt_class *vtt)
456 {
457         char buffer[2048];
458         
459         if (vtt->y_par)
460         {
461                 strcpy(buffer, vtt->y_par->get_name());
462                 if (strlen(buffer)>26) 
463                 {
464                         buffer[24] = '.';
465                         buffer[25] = '.';
466                         buffer[26] = '.';
467                         buffer[27] = 0;                 
468                 }
469                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), buffer);                
470         }
471         else
472         {
473                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), "Nothing");
474         }
475 }
476
477 void vg_xcontrol_dis(GtkWidget *wid, vtt_class *vtt)
478 {
479         vtt->set_x_input_parameter(NULL);
480 }
481
482 void vg_ycontrol_dis(GtkWidget *wid, vtt_class *vtt)
483 {
484         vtt->set_y_input_parameter(NULL);
485 }
486
487 void vg_xcontrol_set(GtkWidget *wid, tX_seqpar *sp)
488 {
489         vtt_class *vtt=(vtt_class *) sp->vtt;
490         vtt->set_x_input_parameter(sp);
491 }
492
493 void vg_ycontrol_set(GtkWidget *wid, tX_seqpar *sp)
494 {
495         vtt_class *vtt=(vtt_class *) sp->vtt;
496         vtt->set_y_input_parameter(sp);
497 }
498
499 void vg_control_menu_popup(vtt_class *vtt, int axis)
500 {
501         list <tX_seqpar *> :: iterator sp;
502         vtt_gui *g=&vtt->gui;
503         GtkWidget *item;
504
505         if (g->par_menu) gtk_object_destroy(GTK_OBJECT(g->par_menu));
506         g->par_menu=gtk_menu_new();
507         
508         item = gtk_menu_item_new_with_label("Nothing");
509         gtk_menu_append(GTK_MENU(g->par_menu), item);
510         gtk_widget_show(item);
511         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_dis), vtt);
512         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_dis), vtt);
513         
514         
515         for (sp=tX_seqpar::all.begin(); sp!=tX_seqpar::all.end(); sp++)
516         {
517                 if (((*sp)->is_mappable) && ((*sp)->vtt) == (void*) vtt)
518                 {
519                         item = gtk_menu_item_new_with_label((*sp)->get_name());
520                         gtk_menu_append(GTK_MENU(g->par_menu), item);
521                         gtk_widget_show(item);
522                         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_set), (void*) (*sp));
523                         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_set), (void*) (*sp));
524                 }
525         }
526         gtk_menu_popup (GTK_MENU(g->par_menu), NULL, NULL, NULL, NULL, 0, 0);
527 }
528
529 void vg_xcontrol_popup(GtkWidget *wid, vtt_class *vtt) 
530 {
531         vg_control_menu_popup(vtt, 1);
532 }
533
534 void vg_ycontrol_popup(GtkWidget *wid, vtt_class *vtt)
535 {
536         vg_control_menu_popup(vtt, 0);
537 }
538
539 static vtt_class * fx_vtt;
540
541 void new_effect(GtkWidget *wid, LADSPA_Plugin *plugin)
542 {
543         fx_vtt->add_effect(plugin);
544 }
545
546 void fx_button_pressed(GtkWidget *wid, vtt_class *vtt)
547 {
548         vtt_gui *g=&vtt->gui;
549         GtkWidget *item;
550         int i;
551         LADSPA_Plugin *plugin;
552         char buffer[1024];
553         char oldfile[1024]="";
554         GtkWidget *submenu;
555
556         fx_vtt=vtt; /* AAAAARGH - Long live ugly code */
557
558         if (g->ladspa_menu) gtk_object_destroy(GTK_OBJECT(g->ladspa_menu));
559         g->ladspa_menu=gtk_menu_new();
560         
561         for (i=0; i<LADSPA_Plugin::getPluginCount(); i++)
562         {
563                 plugin=LADSPA_Plugin::getPluginByIndex(i);
564                 if (strcmp(plugin->get_file_name(), oldfile))
565                 {
566                         strcpy(oldfile, plugin->get_file_name());
567                         item = gtk_menu_item_new_with_label(oldfile);
568                         submenu=gtk_menu_new();
569                         gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
570                         gtk_menu_append(GTK_MENU(g->ladspa_menu), item);
571                         gtk_widget_show(item);
572                 }
573                 sprintf(buffer, "%s - [%i, %s]", plugin->getName(), plugin->getUniqueID(), plugin->getLabel());
574                 item=gtk_menu_item_new_with_label(buffer);
575                 gtk_menu_append(GTK_MENU(submenu), item);
576                 gtk_widget_show(item);
577                 gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(new_effect), plugin);
578         }
579         
580         gtk_menu_popup (GTK_MENU(g->ladspa_menu), NULL, NULL, NULL, NULL, 0, 0);
581 }
582
583 #define connect_entry(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "activate", (GtkSignalFunc) func, (void *) vtt);
584 #define connect_adj(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "value_changed", (GtkSignalFunc) func, (void *) vtt);
585 #define connect_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "clicked", (GtkSignalFunc) func, (void *) vtt);
586 #define connect_press_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "pressed", (GtkSignalFunc) func, (void *) vtt);
587 #define connect_rel_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "released", (GtkSignalFunc) func, (void *) vtt);
588
589 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel);
590
591 void gui_connect_signals(vtt_class *vtt)
592 {
593         vtt_gui *g=&vtt->gui;
594
595         connect_entry(name, name_changed);
596         connect_adj(volume, volume_changed);
597         connect_button(edit, edit_vtt_buffer);
598         connect_button(reload, reload_vtt_buffer);
599         connect_adj(pitch, pitch_changed);
600         connect_adj(pan, pan_changed);
601         connect_button(file, load_file);
602         
603         connect_button(del, delete_vtt);
604 //      connect_button(clone, clone_vtt);
605         connect_button(trigger, trigger_vtt);
606         connect_button(stop, stop_vtt);
607         connect_button(autotrigger, autotrigger_toggled);
608         connect_button(loop, loop_toggled);
609         connect_button(sync_master, master_setup);
610         connect_button(sync_client, client_setup);
611         connect_adj(cycles, client_setup_number);
612 /*      
613         connect_button(x_scratch, control_changed);
614         connect_button(x_volume, control_changed);
615         connect_button(x_lp_cutoff, control_changed);
616         connect_button(x_ec_feedback, control_changed);
617         connect_button(x_nothing, control_changed);
618
619         connect_button(y_scratch, control_changed);
620         connect_button(y_volume, control_changed);
621         connect_button(y_lp_cutoff, control_changed);
622         connect_button(y_ec_feedback, control_changed);
623         connect_button(y_nothing, control_changed);
624 */      
625         connect_button(fx_button, fx_button_pressed);
626         
627         connect_button(lp_enable, lp_enabled);
628         connect_adj(lp_gain, lp_gain_changed);
629         connect_adj(lp_reso, lp_reso_changed);
630         connect_adj(lp_freq, lp_freq_changed);
631         
632         connect_button(ec_enable, ec_enabled);
633         connect_adj(ec_length, ec_length_changed);
634         connect_adj(ec_feedback, ec_feedback_changed);
635         connect_adj(ec_pan, ec_pan_changed);
636         connect_adj(ec_volume, ec_volume_changed);      
637         connect_button(x_control, vg_xcontrol_popup);
638         connect_button(y_control, vg_ycontrol_popup);
639
640         static GtkTargetEntry drop_types [] = {
641                 { "text/uri-list", 0, 0}
642         };
643         static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
644         
645         gtk_drag_dest_set (GTK_WIDGET (g->file), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
646                         drop_types, n_drop_types,
647                         GDK_ACTION_COPY);
648                                                 
649         gtk_signal_connect (GTK_OBJECT (g->file), "drag_data_received",
650                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
651
652         gtk_drag_dest_set (GTK_WIDGET (g->display), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
653                         drop_types, n_drop_types,
654                         GDK_ACTION_COPY);
655                                                 
656         gtk_signal_connect (GTK_OBJECT (g->display), "drag_data_received",
657                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
658         
659 }
660         
661 void build_vtt_gui(vtt_class *vtt)
662 {
663         GtkWidget *tempbox;
664         GtkWidget *tempbox2;
665         GtkWidget *dummy;
666         char nice_name[FILENAME_BUTTON_MAX];
667         
668         vtt_gui *g;
669         
670         g=&vtt->gui;
671         vtt->have_gui=1;
672         g->par_menu=NULL;
673         g->ladspa_menu=NULL;
674
675         /* Building Audio Box */
676         g->audio_box=gtk_vbox_new(FALSE,2);
677         gtk_widget_show(g->audio_box);
678         
679         tempbox=gtk_hbox_new(FALSE,2);
680         gtk_widget_show(tempbox);
681         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox, WID_FIX);
682         
683         g->audio_label=gtk_label_new(vtt->name);
684         gtk_widget_show(g->audio_label);
685         gtk_box_pack_start(GTK_BOX(tempbox), g->audio_label, WID_DYN);
686
687         dummy=gtk_vseparator_new();
688         gtk_widget_show(dummy);
689         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
690
691         nicer_filename(nice_name, vtt->filename);
692         g->file = gtk_button_new_with_label(nice_name);
693         gtk_widget_show(g->file);
694         gui_set_tooltip(g->file, "Click here to load an audiofile into this turntable. As an alternative you may drop an audiofile over this button or the audio-data display.");
695         gtk_box_pack_start(GTK_BOX(tempbox), g->file, WID_DYN);
696
697         g->edit=tx_xpm_button_new(TX_ICON_EDIT, "Edit", 0);
698         gtk_widget_show(g->edit);
699         gui_set_tooltip(g->edit, "Click this button to run the soundfile editor for the audiofile loaded into this turntable. You can configure which soundfile editor to use in the Options dialog.");
700         gtk_box_pack_start(GTK_BOX(tempbox), g->edit, WID_FIX);
701         
702         g->reload=tx_xpm_button_new(TX_ICON_RELOAD, "Reload", 0);
703         gtk_widget_show(g->reload);
704         gui_set_tooltip(g->reload, "Click here to reload the audiofile loaded into this turntable.");
705         gtk_box_pack_start(GTK_BOX(tempbox), g->reload, WID_FIX);
706         
707         dummy=gtk_vseparator_new();
708         gtk_widget_show(dummy);
709         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
710
711         dummy=gtk_label_new("X:");
712         gtk_widget_show(dummy);
713         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
714
715         g->x_control=gtk_button_new_with_label(vtt->x_par->get_name());
716         gtk_widget_show(g->x_control);
717         gui_set_tooltip(g->x_control, "Select which parameter should be controlled for this turntable (in grab mode) by mouse motion (x-axis: left <-> right).");
718         gtk_box_pack_start(GTK_BOX(tempbox), g->x_control, WID_DYN);
719
720         dummy=gtk_label_new("Y:");
721         gtk_widget_show(dummy);
722         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
723         
724         g->y_control=gtk_button_new_with_label(vtt->y_par->get_name());
725         gtk_widget_show(g->y_control);
726         gui_set_tooltip(g->y_control, "Select which parameter should be controlled for this turntable (in grab mode) by mouse motion (x-axis: up <-> down).");
727
728         gtk_box_pack_start(GTK_BOX(tempbox), g->y_control, WID_DYN);
729
730         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
731         gtk_box_pack_start(GTK_BOX(g->audio_box), g->display, WID_DYN);
732         gtk_widget_show(g->display);    
733         
734         /* Building Control Box */
735         
736         g->control_box=gtk_vbox_new(FALSE,2);
737         gtk_widget_show(g->control_box);
738         
739         g->control_label=gtk_label_new(vtt->name);
740         gtk_widget_show(g->control_label);
741         gtk_box_pack_start(GTK_BOX(g->control_box), g->control_label, WID_FIX);
742         
743         g->scrolled_win=gtk_scrolled_window_new (NULL, NULL);
744         gtk_container_set_border_width (GTK_CONTAINER (g->scrolled_win), 0);
745         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (g->scrolled_win),
746                                     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
747         gtk_widget_show(g->scrolled_win);
748         gtk_box_pack_start(GTK_BOX(g->control_box), g->scrolled_win, WID_DYN);
749                                     
750         g->control_subbox=gtk_vbox_new(FALSE,0);
751         gtk_scrolled_window_add_with_viewport (
752                    GTK_SCROLLED_WINDOW (g->scrolled_win), g->control_subbox);
753         gtk_widget_show(g->control_subbox);
754                    
755
756         /* Main panel */
757         
758         tX_panel *p=new tX_panel("Main", g->control_subbox);
759         g->main_panel=p;
760                         
761         g->name = gtk_entry_new_with_max_length(256);   
762         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
763         p->add_client_widget(g->name);
764         gui_set_tooltip(g->name, "Enter the turntable's name here.");
765         gtk_widget_set_usize(g->name, 40, g->name->requisition.height);
766         
767         g->del=gtk_button_new_with_label("Delete");
768         gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too.");
769         p->add_client_widget(g->del);
770         
771 //      g->show_audio=gtk_toggle_button_new_with_label("Show Audio");
772 //      p->add_client_widget(g->show_audio);
773                 
774         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
775                                 
776         p=new tX_panel("Trigger", g->control_subbox);
777         g->trigger_panel=p;
778         
779         g->trigger=gtk_button_new_with_label("Trigger!");
780         gui_set_tooltip(g->trigger, "Click here to trigger this turntable right now. If the audio engine is disabled this turntable will be triggerd as soon as the engine is turned on.");
781         p->add_client_widget(g->trigger);
782         
783         g->stop=gtk_button_new_with_label("Stop.");
784         gui_set_tooltip(g->stop, "Stop this turntable's playback.");
785         p->add_client_widget(g->stop);
786         
787         g->autotrigger=gtk_check_button_new_with_label("Auto");
788         p->add_client_widget(g->autotrigger);
789         gui_set_tooltip(g->autotrigger, "If turned on, this turntable will be automagically triggered whenever the audio engine is turned on.");
790         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
791         
792         g->loop=gtk_check_button_new_with_label("Loop");
793         p->add_client_widget(g->loop);
794         gui_set_tooltip(g->loop, "Enable this option to make the turntable loop the audio data.");
795         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
796         
797         g->sync_master=gtk_check_button_new_with_label("Master");
798         p->add_client_widget(g->sync_master);
799         gui_set_tooltip(g->sync_master, "Click here to make this turntable the sync-master. All turntables marked as sync-clients will be (re-)triggered in relation to the sync-master. Note that only *one* turntable can be the sync-master.");
800         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
801         
802         g->sync_client=gtk_check_button_new_with_label("Client");
803         p->add_client_widget(g->sync_client);
804         gui_set_tooltip(g->sync_client, "If enabled this turntable will be (re-)triggerd in relation to the sync-master turntable.");
805         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
806         
807         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,1));
808         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
809         p->add_client_widget(dummy);
810         gui_set_tooltip(dummy, "Determines how often a sync-client turntable gets triggered. 0 -> this turntable will be triggered with every trigger of the sync-master table, 1 -> the table will be triggered every 2nd master trigger and so on.");
811
812         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
813
814         dummy=gtk_button_new_with_label("FX");
815         gtk_widget_show(dummy);
816         g->fx_button=dummy;
817         gui_set_tooltip(g->fx_button, "Click here to load a LADSPA plugin. You will get a menu from which you can choose which plugin to load.");
818         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
819         
820         /* Lowpass Panel */
821
822         p=new tX_panel("Lowpass", g->control_subbox);
823         g->lp_panel=p;
824                 
825         g->lp_enable=gtk_check_button_new_with_label("Enable");
826         gui_set_tooltip(g->lp_enable, "Click here to enable the built-in lowpass effect.");
827         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
828         p->add_client_widget(vg_create_fx_bar(vtt, vtt->lp_fx, 0));
829
830         p->add_client_widget(g->lp_enable);
831
832         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
833         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
834         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
835
836         g->lp_gaind=new tX_extdial("Input Gain", g->lp_gain);
837         p->add_client_widget(g->lp_gaind->get_widget());
838         gui_set_tooltip(g->lp_gaind->get_entry(), "Adjust the input gain. with this parameter you can either amplify or damp the input-signal for the lowpass effect.");
839
840         g->lp_freqd=new tX_extdial("Frequency", g->lp_freq);
841         p->add_client_widget(g->lp_freqd->get_widget());
842         gui_set_tooltip(g->lp_freqd->get_entry(), "Adjust the cutoff frequency of the lowpass filter. 0 is 0 Hz, 1 is 22.1 kHz.");
843
844         g->lp_resod=new tX_extdial("Resonance", g->lp_reso);
845         p->add_client_widget(g->lp_resod->get_widget());
846         gui_set_tooltip(g->lp_resod->get_entry(), "Adjust the resonance of the lowpass filter. This value determines how much the signal at the cutoff frequency will be amplified.");
847
848         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
849
850         /* Echo Panel */
851
852         p=new tX_panel("Echo", g->control_subbox);
853         g->ec_panel=p;
854
855         p->add_client_widget(vg_create_fx_bar(vtt, vtt->ec_fx, 0));
856         
857         g->ec_enable=gtk_check_button_new_with_label("Enable");
858         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
859         p->add_client_widget(g->ec_enable);
860         gui_set_tooltip(g->ec_enable, "Enable the built-in echo effect.");
861
862         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 1, 0.1, 0.01, 0.001));
863         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
864         g->ec_pan=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_pan, -1.0, 1, 0.1, 0.01, 0.001));
865         g->ec_volume=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_volume, 0.0, 3.0, 0.1, 0.01, 0.001));
866
867         g->ec_lengthd=new tX_extdial("Duration", g->ec_length);
868         p->add_client_widget(g->ec_lengthd->get_widget());
869         gui_set_tooltip(g->ec_lengthd->get_entry(), "Adjust the length of the echo buffer.");
870
871         g->ec_feedbackd=new tX_extdial("Feedback", g->ec_feedback);
872         p->add_client_widget(g->ec_feedbackd->get_widget());
873         gui_set_tooltip(g->ec_feedbackd->get_entry(), "Adjust the feedback of the echo effect. Note that a value of 1 will result in a constant signal.");
874
875         g->ec_volumed=new tX_extdial("Volume", g->ec_volume);
876         p->add_client_widget(g->ec_volumed->get_widget());
877         gui_set_tooltip(g->ec_volumed->get_entry(), "Adjust the volume of the echo effect.");
878
879         g->ec_pand=new tX_extdial("Pan", g->ec_pan);
880         p->add_client_widget(g->ec_pand->get_widget());
881         gui_set_tooltip(g->ec_pand->get_entry(), "Adjust the panning of the echo effect.");
882
883         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
884         
885         /* Output */
886         
887         tempbox=gtk_hbox_new(FALSE,2);
888         gtk_widget_show(tempbox);
889         gtk_box_pack_end(GTK_BOX(g->control_box), tempbox, WID_FIX);
890         
891         tempbox2=gtk_vbox_new(FALSE,0);
892         gtk_widget_show(tempbox2);
893         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
894         
895         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
896         g->pan=GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.1, 0.01, 0.001));
897
898         g->pitchd=new tX_extdial("Pitch", g->pitch);
899         gui_set_tooltip(g->pitchd->get_entry(), "Adjust this turntable's pitch.");
900
901         gtk_box_pack_start(GTK_BOX(tempbox2), g->pitchd->get_widget(), WID_FIX);
902
903         g->pand=new tX_extdial("Pan", g->pan);
904         gtk_box_pack_start(GTK_BOX(tempbox2), g->pand->get_widget(), WID_FIX);
905         gui_set_tooltip(g->pand->get_entry(), "Specifies the position of this turntable within the stereo spectrum: -1 -> left, 0-> center, 1->right.");
906
907        g->mute=gtk_check_button_new_with_label("Mute");
908        gtk_box_pack_start(GTK_BOX(tempbox2), g->mute, WID_FIX);
909        gtk_signal_connect(GTK_OBJECT(g->mute),"clicked", (GtkSignalFunc) mute_volume, vtt);
910        gtk_widget_show(g->mute);
911
912        g->solo=gtk_check_button_new_with_label("Solo");
913        gtk_box_pack_start(GTK_BOX(tempbox2), g->solo, WID_FIX);
914        gtk_signal_connect(GTK_OBJECT(g->solo),"clicked", (GtkSignalFunc) solo_vtt, vtt);
915        gtk_widget_show(g->solo);
916        
917
918         tempbox2=gtk_hbox_new(FALSE,0);
919         gtk_widget_show(tempbox2);
920         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
921         
922         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(2.0-vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
923         dummy=gtk_vscale_new(GTK_ADJUSTMENT(g->volume)); 
924         gtk_scale_set_draw_value(GTK_SCALE(dummy), False);
925         gui_set_tooltip(dummy, "Adjust this turntable's volume.");
926
927         gtk_box_pack_start(GTK_BOX(tempbox2), dummy, WID_FIX);
928         gtk_widget_show(dummy);
929
930         g->flash=gtk_tx_flash_new();
931         gtk_box_pack_start(GTK_BOX(tempbox2), g->flash, WID_FIX);
932         gtk_widget_show(g->flash);              
933
934         g->file_dialog=NULL;
935
936 //      gtk_notebook_set_page(GTK_NOTEBOOK(vtt->gui.notebook), g->current_gui);
937         
938         gui_connect_signals(vtt);
939 }
940
941 void fx_up(GtkWidget *wid, vtt_fx *effect)
942 {
943         vtt_class *vtt;
944         
945         vtt=(vtt_class*)effect->get_vtt();
946         vtt->effect_up(effect);
947 }
948
949 void fx_down(GtkWidget *wid, vtt_fx *effect)
950 {
951         vtt_class *vtt;
952         
953         vtt=(vtt_class*)effect->get_vtt();
954         vtt->effect_down(effect);
955 }
956
957
958 void fx_kill(GtkWidget *wid, vtt_fx_ladspa *effect)
959 {
960         vtt_class *vtt;
961         
962         vtt=(vtt_class*)effect->get_vtt();
963         vtt->effect_remove(effect);
964 }
965
966 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel)
967 {
968         GtkWidget *box;
969         GtkWidget *pixmap;
970         GtkWidget *button;
971         
972         box=gtk_hbox_new(FALSE,0);
973
974         if (showdel)
975         {
976                 button=gtk_button_new();
977                 pixmap=tx_pixmap_widget(TX_ICON_FX_CLOSE);
978                 gtk_container_add (GTK_CONTAINER (button), pixmap);     
979                 gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
980                 gtk_widget_show(pixmap);
981                 gtk_widget_show(button);
982                 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_kill, (void *) effect);
983         }
984
985         button=gtk_button_new();
986         pixmap=tx_pixmap_widget(TX_ICON_FX_DOWN);
987         gtk_container_add (GTK_CONTAINER (button), pixmap);     
988         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
989         gtk_widget_show(pixmap);
990         gtk_widget_show(button);
991         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_down, (void *) effect);
992
993         button=gtk_button_new();
994         pixmap=tx_pixmap_widget(TX_ICON_FX_UP);
995         gtk_container_add (GTK_CONTAINER (button), pixmap);     
996         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
997         gtk_widget_show(pixmap);
998         gtk_widget_show(button);
999         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_up, (void *) effect);
1000         
1001         gtk_widget_show(box);
1002         
1003         return box;
1004 }
1005
1006
1007 int gtk_box_get_widget_pos(GtkBox *box, GtkWidget *child)
1008 {
1009         int i=0;
1010         GList *list;
1011  
1012         list = box->children;
1013         while (list)
1014         {
1015                 GtkBoxChild *child_info;
1016                 child_info = (GtkBoxChild *) list->data;
1017                 if (child_info->widget == child)
1018                 break;
1019                 list = list->next; i++;
1020         }
1021         return i;
1022 }
1023
1024 void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt)
1025 {
1026         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1027         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos-1);
1028 }
1029
1030 void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt)
1031 {
1032         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1033         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos+1);
1034 }
1035
1036 void vg_show_fx_info(GtkWidget *wid, vtt_fx *effect)
1037 {
1038         tx_l_note(effect->get_info_string());
1039 }
1040
1041 void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin)
1042 {
1043         char buffer[1024];
1044         
1045         vtt_gui *g;
1046         g=&vtt->gui;    
1047         tX_panel *p;
1048         list <tX_seqpar_vttfx *> :: iterator sp;
1049         
1050         strcpy(buffer, plugin->getLabel());
1051         if (strlen(buffer) > 6)
1052         {
1053                 buffer[5]='.';
1054                 buffer[6]='.';
1055                 buffer[7]='.';
1056                 buffer[8]=0;
1057         }
1058
1059         p=new tX_panel(buffer, g->control_subbox);
1060         
1061         p->add_client_widget(vg_create_fx_bar(vtt, effect, 1));
1062         
1063         for (sp = effect->controls.begin(); sp != effect->controls.end(); sp++)
1064         {
1065                         p->add_client_widget((*sp)->get_widget());
1066         }
1067
1068         gtk_signal_connect(GTK_OBJECT(p->get_labelbutton()), "clicked", (GtkSignalFunc) vg_show_fx_info, (void *) effect);
1069         gui_set_tooltip(p->get_labelbutton(), "Click here to learn more about this plugin.");
1070         effect->set_panel_widget(p->get_widget());
1071         effect->set_panel(p);
1072
1073         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
1074 }
1075
1076 void gui_set_name(vtt_class *vtt, char *newname)
1077 {
1078         gtk_label_set_text(GTK_LABEL(vtt->gui.audio_label), newname);
1079         gtk_label_set_text(GTK_LABEL(vtt->gui.control_label), newname);
1080         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
1081 }
1082
1083 void gui_set_filename (vtt_class *vtt, char *newname)
1084 {
1085         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), newname);
1086 }
1087
1088 void gui_update_display(vtt_class *vtt)
1089 {
1090         nicer_filename(global_filename_buffer, vtt->filename);
1091         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
1092         gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
1093 }
1094
1095 void delete_gui(vtt_class *vtt)
1096 {
1097         delete vtt->gui.main_panel;
1098         delete vtt->gui.trigger_panel;
1099         
1100         delete vtt->gui.pitchd;
1101         delete vtt->gui.pand;
1102         
1103         delete vtt->gui.lp_gaind;
1104         delete vtt->gui.lp_resod;
1105         delete vtt->gui.lp_freqd;
1106         delete vtt->gui.lp_panel;
1107         
1108         delete vtt->gui.ec_lengthd;
1109         delete vtt->gui.ec_feedbackd;
1110         delete vtt->gui.ec_volumed;
1111         delete vtt->gui.ec_pand;
1112         delete vtt->gui.ec_panel;
1113         
1114         gtk_widget_destroy(vtt->gui.control_box);
1115         gtk_widget_destroy(vtt->gui.audio_box);
1116 }
1117
1118 /*
1119 void recreate_gui(vtt_class *vtt, GtkWidget *ctrl, GtkWidget *audio)
1120 {
1121         build_vtt_gui(vtt);
1122 //      gtk_notebook_set_page(GTK_NOTEBOOK(vtt->gui.notebook), g->current_gui);
1123         gtk_box_pack_start(GTK_BOX(daddy), vtt->gui.frame, TRUE, TRUE, 0);
1124         gtk_widget_show(vtt->gui.frame);
1125 }
1126
1127 void delete_gui(vtt_class *vtt)
1128 {
1129         gtk_widget_destroy(vtt->gui.frame);
1130 }*/
1131
1132 void update_all_vtts()
1133 {
1134         list <vtt_class *> :: iterator vtt;
1135         f_prec temp;
1136         
1137         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1138         {
1139                 if ((*vtt)->is_playing)
1140                 {
1141                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
1142 #ifdef USE_FLASH
1143                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1144                         (*vtt)->max_value=0;
1145                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp);
1146 #endif          
1147                 }
1148         }
1149 }
1150
1151 void cleanup_vtt(vtt_class *vtt)
1152 {
1153                 gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
1154 #ifdef USE_FLASH
1155                 gtk_tx_flash_set_level(vtt->gui.flash, 0.0);
1156                 gtk_tx_flash_clear(vtt->gui.flash);
1157 #endif          
1158 }
1159
1160 void cleanup_all_vtts()
1161 {
1162         list <vtt_class *> :: iterator vtt;
1163         
1164         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1165         {
1166                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
1167 #ifdef USE_FLASH
1168                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0);
1169                 gtk_tx_flash_clear((*vtt)->gui.flash);
1170 #endif          
1171         }
1172 }
1173
1174 void gui_clear_master_button(vtt_class *vtt)
1175 {
1176         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
1177 }
1178
1179 void gui_show_frame(vtt_class *vtt, int show)
1180 {
1181         gtk_tx_show_frame(GTK_TX(vtt->gui.display), show);
1182 }
1183
1184 void show_all_guis(int show)
1185 {
1186         list <vtt_class *> :: iterator vtt;
1187 /*      
1188         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1189         {
1190                 if (show)
1191                 {
1192                         gtk_widget_show((*vtt)->gui.notebook);
1193                 }
1194                 else
1195                 {
1196                         gtk_widget_hide((*vtt)->gui.notebook);          
1197                 }
1198         }
1199         */
1200 }
1201 /*
1202 void vg_update_sync(void *p)
1203 {
1204         vtt_class *vtt=(vtt_class*) p;
1205         
1206         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client), vtt->is_sync_client);
1207 //      gtk_adjustment_set_value(vtt->gui.cycles
1208 }
1209 */
1210 #define vgui (*vtt)->gui
1211 #define v (*vtt)
1212
1213 void vg_enable_critical_buttons(int enable)
1214 {
1215         list <vtt_class *> :: iterator vtt;
1216         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1217         {
1218                 gtk_widget_set_sensitive(vgui.del, enable);
1219                 gtk_widget_set_sensitive(vgui.sync_master, enable);
1220         }
1221 }
1222
1223
1224 int vg_get_current_page(vtt_class *vtt)
1225 {
1226         return (0);
1227 }
1228
1229 void vg_set_current_page(vtt_class *vtt, int page)
1230 {
1231         vtt->gui.current_gui=page;
1232 }
1233
1234 void vg_init_all_non_seqpars()
1235 {
1236         list <vtt_class *> :: iterator vtt;
1237         
1238         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1239         {
1240                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.autotrigger), (*vtt)->autotrigger);
1241                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.sync_master), (*vtt)->is_sync_master);
1242         }       
1243 }