Strip trailing whitespace and fix other whitespace errors (e.g. space/tab mixing...
[ardour.git] / gtk2_ardour / fft_graph.h
1 /*
2     Copyright (C) 2006 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_fft_graph_h
21 #define __ardour_fft_graph_h
22
23 #include "ardour/types.h"
24 #include <fftw3.h>
25
26 #include <gtkmm/drawingarea.h>
27 #include <gtkmm/treemodel.h>
28 #include <gdkmm/color.h>
29
30 #include <glibmm/refptr.h>
31
32 #include <string>
33
34 #include "fft_result.h"
35
36 class AnalysisWindow;
37
38 class FFTGraph : public Gtk::DrawingArea
39 {
40         public:
41
42                 FFTGraph(int windowSize);
43                 ~FFTGraph();
44
45                 void set_analysis_window(AnalysisWindow *a_window);
46
47                 int windowSize() const { return _windowSize; }
48                 void setWindowSize(int windowSize);
49
50                 void redraw();
51                 bool on_expose_event (GdkEventExpose* event);
52
53                 void on_size_request(Gtk::Requisition* requisition);
54                 void on_size_allocate(Gtk::Allocation & alloc);
55                 FFTResult *prepareResult(Gdk::Color color, std::string trackname);
56
57                 void set_show_minmax     (bool v) { _show_minmax     = v; redraw(); }
58                 void set_show_normalized (bool v) { _show_normalized = v; redraw(); }
59
60         private:
61
62                 void update_size();
63
64                 void setWindowSize_internal(int windowSize);
65
66                 void draw_scales(Glib::RefPtr<Gdk::Window> window);
67
68                 static const int minScaleWidth = 512;
69                 static const int minScaleHeight = 420;
70
71                 int currentScaleWidth;
72                 int currentScaleHeight;
73
74                 static const int h_margin = 20;
75                 static const int v_margin = 20;
76                 Glib::RefPtr<Gdk::GC> graph_gc;
77
78                 int width;
79                 int height;
80
81                 int _windowSize;
82                 int _dataSize;
83
84                 Glib::RefPtr<Pango::Layout> layout;
85                 AnalysisWindow *_a_window;
86
87                 fftwf_plan _plan;
88
89                 float *_out;
90                 float *_in;
91                 float *_hanning;
92                 int *_logScale;
93
94                 bool _show_minmax;
95                 bool _show_normalized;
96
97         friend class FFTResult;
98 };
99
100 #endif /* __ardour_fft_graph_h */