Make EQ Gui optional and seize updating the graph when the analysis is not visible...
[ardour.git] / gtk2_ardour / plugin_eq_gui.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sampo Savolainen
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 */
20
21 #ifndef __ardour_plugin_eq_gui_h
22 #define __ardour_plugin_eq_gui_h
23
24 #include <ardour/buffer_set.h>
25 #include <ardour/plugin_insert.h>
26 #include <ardour/plugin.h>
27
28 #include <gtkmm/table.h>
29 #include <gtkmm/drawingarea.h>
30 #include <gtkmm/combobox.h>
31 #include <gtkmm/liststore.h>
32
33 class FFT;
34
35 class PluginEqGui : public Gtk::Table
36 {
37         public:
38                 PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert>);
39                 ~PluginEqGui();
40                 
41         
42
43         private:
44                 // Setup
45                 void set_buffer_size(uint32_t);
46                 void change_dB_scale();
47
48                 // Analysis
49                 void run_analysis();
50
51                 // Drawing
52                 virtual void on_hide();
53                 virtual void on_show();
54
55                 void stop_updating();
56                 void start_updating();
57
58                 void resize_analysis_area(Gtk::Allocation&);
59                 void redraw_analysis_area();
60
61                 void draw_analysis_scales(cairo_t *);
62                 bool expose_analysis_area(GdkEventExpose *);
63
64                 void draw_scales_power(Gtk::Widget *, cairo_t *);
65                 void plot_amplitude(Gtk::Widget *,cairo_t *);
66
67                 void draw_scales_phase(Gtk::Widget *,cairo_t *);
68                 void plot_phase(Gtk::Widget *,cairo_t *);
69
70                 // Helpers
71                 bool timeout_callback();
72                 void redraw_scales();
73
74
75                 // Fields:
76
77                 // analysis parameters
78                 float _samplerate;
79
80                 float _min_dB;
81                 float _max_dB;
82                 float _step_dB;
83
84
85                 float _log_coeff;
86                 float _log_max;
87
88                 nframes_t _buffer_size;
89
90                 // buffers              
91                 ARDOUR::BufferSet _bufferset;
92
93
94                 // dimensions
95                 float _analysis_width;
96                 float _analysis_height;
97
98                 // My objects
99                 FFT *_impulse_fft;
100                 boost::shared_ptr<ARDOUR::Plugin> _plugin;
101
102                 // gui objects
103                 Gtk::DrawingArea *_analysis_area;
104                 cairo_surface_t *_analysis_scale_surface;
105
106
107                 // dB scale selection:
108                 class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord
109                 {
110                   public:
111                         dBSelectionColumns()
112                                 { add(dBMin); add(dBMax); add(dBStep); add(name); }
113
114                         Gtk::TreeModelColumn<float> dBMin;
115                         Gtk::TreeModelColumn<float> dBMax;
116                         Gtk::TreeModelColumn<float> dBStep;
117                         Gtk::TreeModelColumn<Glib::ustring> name;
118                 };
119
120                 dBSelectionColumns dBColumns;
121
122                 Gtk::ComboBox *dBScaleCombo;
123                 Glib::RefPtr<Gtk::ListStore> dBScaleModel;
124
125                 Gtk::CheckButton *_phase_button;
126
127                 // signals and connections
128                 sigc::connection _update_connection;
129                 sigc::connection _window_unmap_connection;
130                 sigc::connection _window_map_connection;
131 };
132
133 #endif
134