summaryrefslogtreecommitdiff
path: root/gtk2_ardour/eq_gui.h
blob: ef503ffb4eb2b63684e44fa473fbeb7544d40186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
    Copyright (C) 2008 Paul Davis
    Author: Sampo Savolainen

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __ardour_eq_gui_h
#define __ardour_eq_gui_h

#include <ardour/buffer_set.h>
#include <ardour/plugin_insert.h>
#include <ardour/plugin.h>

#include <gtkmm/table.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/combobox.h>
#include <gtkmm/liststore.h>

class Plugin;
class FFT;

class PluginEqGui : public Gtk::Table
{
	public:
		PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert>);
		~PluginEqGui();
		
	

	private:
		// Setup
		void setBufferSize(uint32_t);
		void dBScaleChanged();

		// Analysis
		void runAnalysis();

		// Drawing
		virtual void on_hide();
		virtual void on_show();

		void resizeAnalysisArea(Gtk::Allocation&);

		void redrawAnalysisArea();
		void generateAnalysisScale(cairo_t *);
		bool exposeAnalysisArea(GdkEventExpose *);

		void drawPowerScale(Gtk::Widget *, cairo_t *);
		void drawPower(Gtk::Widget *,cairo_t *);

		void drawPhaseScale(Gtk::Widget *,cairo_t *);
		void drawPhase(Gtk::Widget *,cairo_t *);

		// Helpers
		bool timeoutCallback();
		void redrawScales();


		// Fields:

		// analysis parameters
		float _samplerate;

		float _mindB;
		float _maxdB;
		float _dBStep;


		float _logCoeff;
		float _logMax;

		nframes_t _bufferSize;

		// buffers		
		ARDOUR::BufferSet _bufferset;


		// dimensions
		float _analysisWidth;
		float _analysisHeight;

		// My objects
		FFT *_impulseFft;
		boost::shared_ptr<ARDOUR::Plugin> _plugin;

		// gui objects
		Gtk::DrawingArea *_analysisArea;
		cairo_surface_t *_analysisScaleSurface;


		// dB scale selection:
		class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord
		{
		  public:
			dBSelectionColumns()
				{ add(dBMin); add(dBMax); add(dBStep); add(name); }

			Gtk::TreeModelColumn<float> dBMin;
			Gtk::TreeModelColumn<float> dBMax;
			Gtk::TreeModelColumn<float> dBStep;
			Gtk::TreeModelColumn<Glib::ustring> name;
		};

		dBSelectionColumns dBColumns;

		Gtk::ComboBox *dBScaleCombo;
		Glib::RefPtr<Gtk::ListStore> dBScaleModel;

		Gtk::CheckButton *phaseSelect;

		// signals and connections
		sigc::connection _updateConn;
};

#endif