update drobilla's fascistic dir-locals.el to force emacs users into whitespace submis...
[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 namespace GTKArdour {
34         class FFT;
35 }
36
37 class PluginEqGui : public Gtk::Table
38 {
39 public:
40         PluginEqGui (boost::shared_ptr<ARDOUR::PluginInsert>);
41         ~PluginEqGui ();
42
43 private:
44         // Setup
45         void set_buffer_size (uint32_t, uint32_t);
46         void change_dB_scale ();
47
48         // Analysis
49         void run_impulse_analysis ();
50         void signal_collect_callback (ARDOUR::BufferSet *, ARDOUR::BufferSet *);
51         float _signal_analysis_running;
52
53         // Drawing
54         virtual void on_hide ();
55         virtual void on_show ();
56
57         void stop_updating ();
58         void start_updating ();
59
60         void resize_analysis_area (Gtk::Allocation&);
61         void redraw_analysis_area ();
62
63         void draw_analysis_scales (cairo_t *);
64         bool expose_analysis_area (GdkEventExpose *);
65
66         void draw_scales_power (Gtk::Widget *, cairo_t *);
67         void plot_impulse_amplitude (Gtk::Widget *,cairo_t *);
68
69         void draw_scales_phase (Gtk::Widget *,cairo_t *);
70         void plot_impulse_phase (Gtk::Widget *,cairo_t *);
71
72         void plot_signal_amplitude_difference (Gtk::Widget *,cairo_t *);
73
74         // Helpers
75         bool timeout_callback ();
76         void redraw_scales ();
77
78         // Fields:
79         
80         // analysis parameters
81         float _samplerate;
82         
83         float _min_dB;
84         float _max_dB;
85         float _step_dB;
86         
87         float _log_coeff;
88         float _log_max;
89         
90         ARDOUR::framecnt_t _buffer_size;
91         ARDOUR::framecnt_t _signal_buffer_size;
92         
93         // buffers
94         ARDOUR::BufferSet _bufferset;
95         ARDOUR::BufferSet _collect_bufferset;
96         
97         
98         // dimensions
99         float _analysis_width;
100         float _analysis_height;
101         
102         // My objects
103         GTKArdour::FFT *_impulse_fft;
104         GTKArdour::FFT *_signal_input_fft;
105         GTKArdour::FFT *_signal_output_fft;
106         boost::shared_ptr<ARDOUR::Plugin> _plugin;
107         boost::shared_ptr<ARDOUR::PluginInsert> _plugin_insert;
108         
109         // gui objects
110         Gtk::DrawingArea *_analysis_area;
111         cairo_surface_t *_analysis_scale_surface;
112         
113         // dB scale selection:
114         class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord
115         {
116         public:
117                 dBSelectionColumns()
118                 { add(dBMin); add(dBMax); add(dBStep); add(name); }
119                 
120                 Gtk::TreeModelColumn<float> dBMin;
121                 Gtk::TreeModelColumn<float> dBMax;
122                 Gtk::TreeModelColumn<float> dBStep;
123                 Gtk::TreeModelColumn<std::string> name;
124         };
125         
126         dBSelectionColumns dBColumns;
127         
128         Gtk::ComboBox *dBScaleCombo;
129         Glib::RefPtr<Gtk::ListStore> dBScaleModel;
130         
131         Gtk::CheckButton *_phase_button;
132         
133         // signals and connections
134         sigc::connection _update_connection;
135         sigc::connection _window_unmap_connection;
136         sigc::connection _window_map_connection;
137         
138         PBD::ScopedConnection analysis_connection;
139 };
140
141 #endif
142