Fix formatting samplecnt_t (aka int64_t aka long long int)
[ardour.git] / gtk2_ardour / plugin_eq_gui.h
1 /*
2  * Copyright (C) 2008-2009 Sampo Savolainen <v2@iki.fi>
3  * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
4  * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2010 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2018-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __ardour_plugin_eq_gui_h
24 #define __ardour_plugin_eq_gui_h
25
26 #include "pbd/signals.h"
27
28 #include "ardour/buffer_set.h"
29
30 #include <gtkmm/table.h>
31 #include <gtkmm/drawingarea.h>
32 #include <gtkmm/combobox.h>
33 #include <gtkmm/comboboxtext.h>
34 #include <gtkmm/liststore.h>
35
36 namespace ARDOUR {
37         class Plugin;
38         class PluginInsert;
39 }
40
41 namespace GTKArdour {
42         class FFT;
43 }
44
45 class PluginEqGui : public Gtk::Table
46 {
47 public:
48         PluginEqGui (boost::shared_ptr<ARDOUR::PluginInsert>);
49         ~PluginEqGui ();
50
51         void start_listening ();
52         void stop_listening ();
53
54 private:
55         // Setup
56         void set_buffer_size (uint32_t, uint32_t);
57         void change_dB_scale ();
58
59         // Analysis
60         void run_impulse_analysis ();
61         void signal_collect_callback (ARDOUR::BufferSet *, ARDOUR::BufferSet *);
62         float _signal_analysis_running;
63
64         // Drawing
65         virtual void on_hide ();
66         virtual void on_show ();
67
68         void stop_updating ();
69         void start_updating ();
70
71         void resize_analysis_area (Gtk::Allocation&);
72         void redraw_analysis_area ();
73
74         void draw_analysis_scales (cairo_t *);
75         bool expose_analysis_area (GdkEventExpose *);
76
77         void draw_scales_power (Gtk::Widget *, cairo_t *);
78         void plot_impulse_amplitude (Gtk::Widget *,cairo_t *);
79
80         void draw_scales_phase (Gtk::Widget *,cairo_t *);
81         void plot_impulse_phase (Gtk::Widget *,cairo_t *);
82
83         void plot_signal_amplitude_difference (Gtk::Widget *,cairo_t *);
84
85         void update_pointer_info(float);
86         bool analysis_area_mouseover(GdkEventMotion *);
87         bool analysis_area_mouseexit(GdkEventCrossing *);
88
89         // Helpers
90         bool timeout_callback ();
91         void redraw_scales ();
92
93         // Fields:
94
95         // analysis parameters
96         float _samplerate;
97
98         float _min_dB;
99         float _max_dB;
100         float _step_dB;
101
102         float _log_coeff;
103         float _log_max;
104
105         ARDOUR::samplecnt_t _block_size;
106         ARDOUR::samplecnt_t _buffer_size;
107         ARDOUR::samplecnt_t _signal_buffer_size;
108
109         // buffers
110         ARDOUR::BufferSet _bufferset;
111         ARDOUR::BufferSet _collect_bufferset;
112
113         // dimensions
114         float _analysis_width;
115         float _analysis_height;
116
117         // My objects
118         GTKArdour::FFT *_impulse_fft;
119         GTKArdour::FFT *_signal_input_fft;
120         GTKArdour::FFT *_signal_output_fft;
121         boost::shared_ptr<ARDOUR::Plugin> _plugin;
122         boost::shared_ptr<ARDOUR::PluginInsert> _plugin_insert;
123
124         // gui objects
125         Gtk::DrawingArea *_analysis_area;
126         cairo_surface_t *_analysis_scale_surface;
127         Gtk::Label *_pointer_info;
128         int _pointer_in_area_xpos;
129         int _pointer_in_area_freq;
130
131         // dB scale selection:
132         class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord
133         {
134         public:
135                 dBSelectionColumns()
136                 { add(dBMin); add(dBMax); add(dBStep); add(name); }
137
138                 Gtk::TreeModelColumn<float> dBMin;
139                 Gtk::TreeModelColumn<float> dBMax;
140                 Gtk::TreeModelColumn<float> dBStep;
141                 Gtk::TreeModelColumn<std::string> name;
142         };
143
144         dBSelectionColumns dBColumns;
145
146         Gtk::ComboBox *dBScaleCombo;
147         Glib::RefPtr<Gtk::ListStore> dBScaleModel;
148
149         Gtk::ComboBoxText* _live_signal_combo;
150
151         Gtk::CheckButton *_phase_button;
152
153         // signals and connections
154         sigc::connection _update_connection;
155         sigc::connection _window_unmap_connection;
156         sigc::connection _window_map_connection;
157
158         PBD::ScopedConnection analysis_connection;
159 };
160
161 #endif