Applied the ogg123 patch and some minor fixes. 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 *tempbox3;
666         GtkWidget *dummy;
667         char nice_name[FILENAME_BUTTON_MAX];
668         
669         vtt_gui *g;
670         
671         g=&vtt->gui;
672         vtt->have_gui=1;
673         g->par_menu=NULL;
674         g->ladspa_menu=NULL;
675
676         /* Building Audio Box */
677         g->audio_box=gtk_vbox_new(FALSE,2);
678         gtk_widget_show(g->audio_box);
679         
680         tempbox=gtk_hbox_new(FALSE,2);
681         gtk_widget_show(tempbox);
682         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox, WID_FIX);
683         
684         g->audio_label=gtk_label_new(vtt->name);
685         gtk_widget_show(g->audio_label);
686         gtk_box_pack_start(GTK_BOX(tempbox), g->audio_label, WID_DYN);
687
688         dummy=gtk_vseparator_new();
689         gtk_widget_show(dummy);
690         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
691
692         nicer_filename(nice_name, vtt->filename);
693         g->file = gtk_button_new_with_label(nice_name);
694         gtk_widget_show(g->file);
695         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.");
696         gtk_box_pack_start(GTK_BOX(tempbox), g->file, WID_DYN);
697
698         g->edit=tx_xpm_button_new(TX_ICON_EDIT, "Edit", 0);
699         gtk_widget_show(g->edit);
700         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.");
701         gtk_box_pack_start(GTK_BOX(tempbox), g->edit, WID_FIX);
702         
703         g->reload=tx_xpm_button_new(TX_ICON_RELOAD, "Reload", 0);
704         gtk_widget_show(g->reload);
705         gui_set_tooltip(g->reload, "Click here to reload the audiofile loaded into this turntable.");
706         gtk_box_pack_start(GTK_BOX(tempbox), g->reload, WID_FIX);
707         
708         dummy=gtk_vseparator_new();
709         gtk_widget_show(dummy);
710         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
711
712         dummy=gtk_label_new("X:");
713         gtk_widget_show(dummy);
714         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
715
716         g->x_control=gtk_button_new_with_label(vtt->x_par->get_name());
717         gtk_widget_show(g->x_control);
718         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).");
719         gtk_box_pack_start(GTK_BOX(tempbox), g->x_control, WID_DYN);
720
721         dummy=gtk_label_new("Y:");
722         gtk_widget_show(dummy);
723         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
724         
725         g->y_control=gtk_button_new_with_label(vtt->y_par->get_name());
726         gtk_widget_show(g->y_control);
727         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).");
728
729         gtk_box_pack_start(GTK_BOX(tempbox), g->y_control, WID_DYN);
730
731         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
732         gtk_box_pack_start(GTK_BOX(g->audio_box), g->display, WID_DYN);
733         gtk_widget_show(g->display);    
734         
735         /* Building Control Box */
736         
737         g->control_box=gtk_vbox_new(FALSE,2);
738         gtk_widget_show(g->control_box);
739         
740         g->control_label=gtk_label_new(vtt->name);
741         gtk_widget_show(g->control_label);
742         gtk_box_pack_start(GTK_BOX(g->control_box), g->control_label, WID_FIX);
743         
744         g->scrolled_win=gtk_scrolled_window_new (NULL, NULL);
745         gtk_container_set_border_width (GTK_CONTAINER (g->scrolled_win), 0);
746         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (g->scrolled_win),
747                                     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
748         gtk_widget_show(g->scrolled_win);
749         gtk_box_pack_start(GTK_BOX(g->control_box), g->scrolled_win, WID_DYN);
750                                     
751         g->control_subbox=gtk_vbox_new(FALSE,0);
752         gtk_scrolled_window_add_with_viewport (
753                    GTK_SCROLLED_WINDOW (g->scrolled_win), g->control_subbox);
754         gtk_widget_show(g->control_subbox);
755                    
756
757         /* Main panel */
758         
759         tX_panel *p=new tX_panel("Main", g->control_subbox);
760         g->main_panel=p;
761                         
762         g->name = gtk_entry_new_with_max_length(256);   
763         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
764         p->add_client_widget(g->name);
765         gui_set_tooltip(g->name, "Enter the turntable's name here.");
766         gtk_widget_set_usize(g->name, 40, g->name->requisition.height);
767         
768         g->del=gtk_button_new_with_label("Delete");
769         gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too.");
770         p->add_client_widget(g->del);
771         
772 //      g->show_audio=gtk_toggle_button_new_with_label("Show Audio");
773 //      p->add_client_widget(g->show_audio);
774                 
775         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
776                                 
777         p=new tX_panel("Trigger", g->control_subbox);
778         g->trigger_panel=p;
779         
780         g->trigger=gtk_button_new_with_label("Trigger!");
781         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.");
782         p->add_client_widget(g->trigger);
783         
784         g->stop=gtk_button_new_with_label("Stop.");
785         gui_set_tooltip(g->stop, "Stop this turntable's playback.");
786         p->add_client_widget(g->stop);
787         
788         g->autotrigger=gtk_check_button_new_with_label("Auto");
789         p->add_client_widget(g->autotrigger);
790         gui_set_tooltip(g->autotrigger, "If turned on, this turntable will be automagically triggered whenever the audio engine is turned on.");
791         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
792         
793         g->loop=gtk_check_button_new_with_label("Loop");
794         p->add_client_widget(g->loop);
795         gui_set_tooltip(g->loop, "Enable this option to make the turntable loop the audio data.");
796         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
797         
798         g->sync_master=gtk_check_button_new_with_label("Master");
799         p->add_client_widget(g->sync_master);
800         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.");
801         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
802         
803         g->sync_client=gtk_check_button_new_with_label("Client");
804         p->add_client_widget(g->sync_client);
805         gui_set_tooltip(g->sync_client, "If enabled this turntable will be (re-)triggerd in relation to the sync-master turntable.");
806         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
807         
808         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,1));
809         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
810         p->add_client_widget(dummy);
811         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.");
812
813         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
814
815         dummy=gtk_button_new_with_label("FX");
816         gtk_widget_show(dummy);
817         g->fx_button=dummy;
818         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.");
819         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
820         
821         /* Lowpass Panel */
822
823         p=new tX_panel("Lowpass", g->control_subbox);
824         g->lp_panel=p;
825                 
826         g->lp_enable=gtk_check_button_new_with_label("Enable");
827         gui_set_tooltip(g->lp_enable, "Click here to enable the built-in lowpass effect.");
828         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
829         p->add_client_widget(vg_create_fx_bar(vtt, vtt->lp_fx, 0));
830
831         p->add_client_widget(g->lp_enable);
832
833         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
834         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
835         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
836
837         g->lp_gaind=new tX_extdial("Input Gain", g->lp_gain);
838         p->add_client_widget(g->lp_gaind->get_widget());
839         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.");
840
841         g->lp_freqd=new tX_extdial("Frequency", g->lp_freq);
842         p->add_client_widget(g->lp_freqd->get_widget());
843         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.");
844
845         g->lp_resod=new tX_extdial("Resonance", g->lp_reso);
846         p->add_client_widget(g->lp_resod->get_widget());
847         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.");
848
849         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
850
851         /* Echo Panel */
852
853         p=new tX_panel("Echo", g->control_subbox);
854         g->ec_panel=p;
855
856         p->add_client_widget(vg_create_fx_bar(vtt, vtt->ec_fx, 0));
857         
858         g->ec_enable=gtk_check_button_new_with_label("Enable");
859         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
860         p->add_client_widget(g->ec_enable);
861         gui_set_tooltip(g->ec_enable, "Enable the built-in echo effect.");
862
863         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 1, 0.1, 0.01, 0.001));
864         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
865         g->ec_pan=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_pan, -1.0, 1, 0.1, 0.01, 0.001));
866         g->ec_volume=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_volume, 0.0, 3.0, 0.1, 0.01, 0.001));
867
868         g->ec_lengthd=new tX_extdial("Duration", g->ec_length);
869         p->add_client_widget(g->ec_lengthd->get_widget());
870         gui_set_tooltip(g->ec_lengthd->get_entry(), "Adjust the length of the echo buffer.");
871
872         g->ec_feedbackd=new tX_extdial("Feedback", g->ec_feedback);
873         p->add_client_widget(g->ec_feedbackd->get_widget());
874         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.");
875
876         g->ec_volumed=new tX_extdial("Volume", g->ec_volume);
877         p->add_client_widget(g->ec_volumed->get_widget());
878         gui_set_tooltip(g->ec_volumed->get_entry(), "Adjust the volume of the echo effect.");
879
880         g->ec_pand=new tX_extdial("Pan", g->ec_pan);
881         p->add_client_widget(g->ec_pand->get_widget());
882         gui_set_tooltip(g->ec_pand->get_entry(), "Adjust the panning of the echo effect.");
883
884         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
885         
886         /* Output */
887         
888         tempbox=gtk_hbox_new(FALSE,2);
889         gtk_widget_show(tempbox);
890         gtk_box_pack_end(GTK_BOX(g->control_box), tempbox, WID_FIX);
891         
892         tempbox2=gtk_vbox_new(FALSE,0);
893         gtk_widget_show(tempbox2);
894         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
895         
896         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
897         g->pan=GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.1, 0.01, 0.001));
898
899         g->pitchd=new tX_extdial("Pitch", g->pitch);
900         gui_set_tooltip(g->pitchd->get_entry(), "Adjust this turntable's pitch.");
901
902         gtk_box_pack_start(GTK_BOX(tempbox2), g->pitchd->get_widget(), WID_FIX);
903
904         g->pand=new tX_extdial("Pan", g->pan);
905         gtk_box_pack_start(GTK_BOX(tempbox2), g->pand->get_widget(), WID_FIX);
906         gui_set_tooltip(g->pand->get_entry(), "Specifies the position of this turntable within the stereo spectrum: -1 -> left, 0-> center, 1->right.");
907
908         tempbox3=gtk_hbox_new(FALSE,2);
909         gtk_widget_show(tempbox3);
910
911         g->mute=gtk_check_button_new_with_label("m");
912         gtk_box_pack_start(GTK_BOX(tempbox3), g->mute, WID_FIX);
913         gtk_signal_connect(GTK_OBJECT(g->mute),"clicked", (GtkSignalFunc) mute_volume, vtt);
914         gtk_widget_show(g->mute);
915
916         g->solo=gtk_check_button_new_with_label("s");
917         gtk_box_pack_start(GTK_BOX(tempbox3), g->solo, WID_FIX);
918         gtk_signal_connect(GTK_OBJECT(g->solo),"clicked", (GtkSignalFunc) solo_vtt, vtt);
919         gtk_widget_show(g->solo);
920
921         gtk_box_pack_start(GTK_BOX(tempbox2), tempbox3, WID_FIX);
922
923         tempbox2=gtk_hbox_new(FALSE,0);
924         gtk_widget_show(tempbox2);
925         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
926         
927         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(2.0-vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
928         dummy=gtk_vscale_new(GTK_ADJUSTMENT(g->volume)); 
929         gtk_scale_set_draw_value(GTK_SCALE(dummy), False);
930         gui_set_tooltip(dummy, "Adjust this turntable's volume.");
931
932         gtk_box_pack_start(GTK_BOX(tempbox2), dummy, WID_FIX);
933         gtk_widget_show(dummy);
934
935         g->flash=gtk_tx_flash_new();
936         gtk_box_pack_start(GTK_BOX(tempbox2), g->flash, WID_FIX);
937         gtk_widget_show(g->flash);              
938
939         g->file_dialog=NULL;
940
941 //      gtk_notebook_set_page(GTK_NOTEBOOK(vtt->gui.notebook), g->current_gui);
942         
943         gui_connect_signals(vtt);
944 }
945
946 void fx_up(GtkWidget *wid, vtt_fx *effect)
947 {
948         vtt_class *vtt;
949         
950         vtt=(vtt_class*)effect->get_vtt();
951         vtt->effect_up(effect);
952 }
953
954 void fx_down(GtkWidget *wid, vtt_fx *effect)
955 {
956         vtt_class *vtt;
957         
958         vtt=(vtt_class*)effect->get_vtt();
959         vtt->effect_down(effect);
960 }
961
962
963 void fx_kill(GtkWidget *wid, vtt_fx_ladspa *effect)
964 {
965         vtt_class *vtt;
966         
967         vtt=(vtt_class*)effect->get_vtt();
968         vtt->effect_remove(effect);
969 }
970
971 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel)
972 {
973         GtkWidget *box;
974         GtkWidget *pixmap;
975         GtkWidget *button;
976         
977         box=gtk_hbox_new(FALSE,0);
978
979         if (showdel)
980         {
981                 button=gtk_button_new();
982                 pixmap=tx_pixmap_widget(TX_ICON_FX_CLOSE);
983                 gtk_container_add (GTK_CONTAINER (button), pixmap);     
984                 gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
985                 gtk_widget_show(pixmap);
986                 gtk_widget_show(button);
987                 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_kill, (void *) effect);
988         }
989
990         button=gtk_button_new();
991         pixmap=tx_pixmap_widget(TX_ICON_FX_DOWN);
992         gtk_container_add (GTK_CONTAINER (button), pixmap);     
993         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
994         gtk_widget_show(pixmap);
995         gtk_widget_show(button);
996         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_down, (void *) effect);
997
998         button=gtk_button_new();
999         pixmap=tx_pixmap_widget(TX_ICON_FX_UP);
1000         gtk_container_add (GTK_CONTAINER (button), pixmap);     
1001         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
1002         gtk_widget_show(pixmap);
1003         gtk_widget_show(button);
1004         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_up, (void *) effect);
1005         
1006         gtk_widget_show(box);
1007         
1008         return box;
1009 }
1010
1011
1012 int gtk_box_get_widget_pos(GtkBox *box, GtkWidget *child)
1013 {
1014         int i=0;
1015         GList *list;
1016  
1017         list = box->children;
1018         while (list)
1019         {
1020                 GtkBoxChild *child_info;
1021                 child_info = (GtkBoxChild *) list->data;
1022                 if (child_info->widget == child)
1023                 break;
1024                 list = list->next; i++;
1025         }
1026         return i;
1027 }
1028
1029 void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt)
1030 {
1031         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1032         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos-1);
1033 }
1034
1035 void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt)
1036 {
1037         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1038         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos+1);
1039 }
1040
1041 void vg_show_fx_info(GtkWidget *wid, vtt_fx *effect)
1042 {
1043         tx_l_note(effect->get_info_string());
1044 }
1045
1046 void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin)
1047 {
1048         char buffer[1024];
1049         
1050         vtt_gui *g;
1051         g=&vtt->gui;    
1052         tX_panel *p;
1053         list <tX_seqpar_vttfx *> :: iterator sp;
1054         
1055         strcpy(buffer, plugin->getLabel());
1056         if (strlen(buffer) > 6)
1057         {
1058                 buffer[5]='.';
1059                 buffer[6]='.';
1060                 buffer[7]='.';
1061                 buffer[8]=0;
1062         }
1063
1064         p=new tX_panel(buffer, g->control_subbox);
1065         
1066         p->add_client_widget(vg_create_fx_bar(vtt, effect, 1));
1067         
1068         for (sp = effect->controls.begin(); sp != effect->controls.end(); sp++)
1069         {
1070                         p->add_client_widget((*sp)->get_widget());
1071         }
1072
1073         gtk_signal_connect(GTK_OBJECT(p->get_labelbutton()), "clicked", (GtkSignalFunc) vg_show_fx_info, (void *) effect);
1074         gui_set_tooltip(p->get_labelbutton(), "Click here to learn more about this plugin.");
1075         effect->set_panel_widget(p->get_widget());
1076         effect->set_panel(p);
1077
1078         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
1079 }
1080
1081 void gui_set_name(vtt_class *vtt, char *newname)
1082 {
1083         gtk_label_set_text(GTK_LABEL(vtt->gui.audio_label), newname);
1084         gtk_label_set_text(GTK_LABEL(vtt->gui.control_label), newname);
1085         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
1086 }
1087
1088 void gui_set_filename (vtt_class *vtt, char *newname)
1089 {
1090         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), newname);
1091 }
1092
1093 void gui_update_display(vtt_class *vtt)
1094 {
1095         nicer_filename(global_filename_buffer, vtt->filename);
1096         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
1097         gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
1098 }
1099
1100 void delete_gui(vtt_class *vtt)
1101 {
1102         delete vtt->gui.main_panel;
1103         delete vtt->gui.trigger_panel;
1104         
1105         delete vtt->gui.pitchd;
1106         delete vtt->gui.pand;
1107         
1108         delete vtt->gui.lp_gaind;
1109         delete vtt->gui.lp_resod;
1110         delete vtt->gui.lp_freqd;
1111         delete vtt->gui.lp_panel;
1112         
1113         delete vtt->gui.ec_lengthd;
1114         delete vtt->gui.ec_feedbackd;
1115         delete vtt->gui.ec_volumed;
1116         delete vtt->gui.ec_pand;
1117         delete vtt->gui.ec_panel;
1118         
1119         gtk_widget_destroy(vtt->gui.control_box);
1120         gtk_widget_destroy(vtt->gui.audio_box);
1121 }
1122
1123 /*
1124 void recreate_gui(vtt_class *vtt, GtkWidget *ctrl, GtkWidget *audio)
1125 {
1126         build_vtt_gui(vtt);
1127 //      gtk_notebook_set_page(GTK_NOTEBOOK(vtt->gui.notebook), g->current_gui);
1128         gtk_box_pack_start(GTK_BOX(daddy), vtt->gui.frame, TRUE, TRUE, 0);
1129         gtk_widget_show(vtt->gui.frame);
1130 }
1131
1132 void delete_gui(vtt_class *vtt)
1133 {
1134         gtk_widget_destroy(vtt->gui.frame);
1135 }*/
1136
1137 void update_all_vtts()
1138 {
1139         list <vtt_class *> :: iterator vtt;
1140         f_prec temp;
1141         
1142         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1143         {
1144                 if ((*vtt)->is_playing)
1145                 {
1146                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
1147 #ifdef USE_FLASH
1148                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1149                         (*vtt)->max_value=0;
1150                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp);
1151 #endif          
1152                 }
1153         }
1154 }
1155
1156 void cleanup_vtt(vtt_class *vtt)
1157 {
1158                 gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
1159 #ifdef USE_FLASH
1160                 gtk_tx_flash_set_level(vtt->gui.flash, 0.0);
1161                 gtk_tx_flash_clear(vtt->gui.flash);
1162 #endif          
1163 }
1164
1165 void cleanup_all_vtts()
1166 {
1167         list <vtt_class *> :: iterator vtt;
1168         
1169         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1170         {
1171                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
1172 #ifdef USE_FLASH
1173                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0);
1174                 gtk_tx_flash_clear((*vtt)->gui.flash);
1175 #endif          
1176         }
1177 }
1178
1179 void gui_clear_master_button(vtt_class *vtt)
1180 {
1181         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
1182 }
1183
1184 void gui_show_frame(vtt_class *vtt, int show)
1185 {
1186         gtk_tx_show_frame(GTK_TX(vtt->gui.display), show);
1187 }
1188
1189 void show_all_guis(int show)
1190 {
1191         list <vtt_class *> :: iterator vtt;
1192 /*      
1193         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1194         {
1195                 if (show)
1196                 {
1197                         gtk_widget_show((*vtt)->gui.notebook);
1198                 }
1199                 else
1200                 {
1201                         gtk_widget_hide((*vtt)->gui.notebook);          
1202                 }
1203         }
1204         */
1205 }
1206 /*
1207 void vg_update_sync(void *p)
1208 {
1209         vtt_class *vtt=(vtt_class*) p;
1210         
1211         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client), vtt->is_sync_client);
1212 //      gtk_adjustment_set_value(vtt->gui.cycles
1213 }
1214 */
1215 #define vgui (*vtt)->gui
1216 #define v (*vtt)
1217
1218 void vg_enable_critical_buttons(int enable)
1219 {
1220         list <vtt_class *> :: iterator vtt;
1221         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1222         {
1223                 gtk_widget_set_sensitive(vgui.del, enable);
1224                 gtk_widget_set_sensitive(vgui.sync_master, enable);
1225         }
1226 }
1227
1228
1229 int vg_get_current_page(vtt_class *vtt)
1230 {
1231         return (0);
1232 }
1233
1234 void vg_set_current_page(vtt_class *vtt, int page)
1235 {
1236         vtt->gui.current_gui=page;
1237 }
1238
1239 void vg_init_all_non_seqpars()
1240 {
1241         list <vtt_class *> :: iterator vtt;
1242         
1243         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1244         {
1245                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.autotrigger), (*vtt)->autotrigger);
1246                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.sync_master), (*vtt)->is_sync_master);
1247         }       
1248 }