Ardour  9.0-pre0-582-g084a23a80d
fft_graph.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2011 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2009 David Robillard <d@drobilla.net>
4  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __ardour_fft_graph_h
22 #define __ardour_fft_graph_h
23 
24 #include "ardour/types.h"
25 #include <fftw3.h>
26 
27 #include <gtkmm/drawingarea.h>
28 #include <gtkmm/treemodel.h>
29 #include <gdkmm/color.h>
30 
31 #include <glibmm/refptr.h>
32 
33 #include <string>
34 
35 #include "fft_result.h"
36 
37 class AnalysisWindow;
38 
39 class FFTGraph : public Gtk::DrawingArea
40 {
41 public:
42 
45 
47 
48  int windowSize () const { return _windowSize; }
50 
51  void redraw ();
55  bool on_button_press_event (GdkEventButton*) { return true; }
56 
57  void on_size_request (Gtk::Requisition* requisition);
59  FFTResult *prepareResult (Gdk::Color color, std::string trackname);
60 
61  void set_show_minmax (bool v) { _show_minmax = v; redraw (); }
62  void set_show_normalized (bool v) { _show_normalized = v; redraw (); }
64 
65 private:
66 
67  void update_size ();
68 
70 
71  int draw_scales (cairo_t*);
72 
73  static const int minScaleWidth = 512;
74  static const int minScaleHeight = 420;
75 
76  static const int hl_margin = 40; // this should scale with font (dBFS labels)
77  static const int hr_margin = 12;
78  static const int v_margin = 12;
79 
81 
82  int width;
83  int height;
84 
85  int _yoff;
86  int _ann_x;
87  int _ann_y;
88  cairo_rectangle_t _ann_area;
89 
90  unsigned int _windowSize;
91  unsigned int _dataSize;
92 
93  Glib::RefPtr<Pango::Layout> layout;
94  cairo_surface_t* _surface;
95 
97 
98  fftwf_plan _plan;
99 
100  float* _out;
101  float* _in;
102  float* _hanning;
103  int* _logScale;
104 
108 
109  float _fft_start;
110  float _fft_end;
112 
113  friend class FFTResult;
114 };
115 
116 #endif /* __ardour_fft_graph_h */
void update_size()
bool on_button_press_event(GdkEventButton *)
This is a default handler for the signal signal_button_press_event().
Definition: fft_graph.h:55
void setWindowSize(int windowSize)
float _fft_start
Definition: fft_graph.h:109
FFTGraph(int windowSize)
cairo_rectangle_t _ann_area
Definition: fft_graph.h:88
int _ann_x
Definition: fft_graph.h:86
bool on_expose_event(GdkEventExpose *event)
This is a default handler for the signal signal_expose_event().
bool _show_proportional
Definition: fft_graph.h:107
void set_show_minmax(bool v)
Definition: fft_graph.h:61
float _fft_log_base
Definition: fft_graph.h:111
fftwf_plan _plan
Definition: fft_graph.h:98
void set_show_normalized(bool v)
Definition: fft_graph.h:62
int windowSize() const
Definition: fft_graph.h:48
static const int hr_margin
Definition: fft_graph.h:77
int draw_scales(cairo_t *)
Glib::RefPtr< Pango::Layout > layout
Definition: fft_graph.h:93
FFTResult * prepareResult(Gdk::Color color, std::string trackname)
int * _logScale
Definition: fft_graph.h:103
int _yoff
Definition: fft_graph.h:85
void on_size_request(Gtk::Requisition *requisition)
This is a default handler for the signal signal_size_request().
int currentScaleWidth
Definition: fft_graph.h:80
void set_analysis_window(AnalysisWindow *a_window)
static const int hl_margin
Definition: fft_graph.h:76
unsigned int _dataSize
Definition: fft_graph.h:91
static const int v_margin
Definition: fft_graph.h:78
void set_show_proportioanl(bool v)
Definition: fft_graph.h:63
unsigned int _windowSize
Definition: fft_graph.h:90
bool on_leave_notify_event(GdkEventCrossing *)
This is a default handler for the signal signal_leave_notify_event().
bool on_motion_notify_event(GdkEventMotion *)
This is a default handler for the signal signal_motion_notify_event().
bool _show_minmax
Definition: fft_graph.h:105
void setWindowSize_internal(int windowSize)
float * _hanning
Definition: fft_graph.h:102
bool _show_normalized
Definition: fft_graph.h:106
void redraw()
static const int minScaleWidth
Definition: fft_graph.h:73
float * _out
Definition: fft_graph.h:100
float _fft_end
Definition: fft_graph.h:110
void on_size_allocate(Gtk::Allocation &alloc)
This is a default handler for the signal signal_size_allocate().
static const int minScaleHeight
Definition: fft_graph.h:74
int _ann_y
Definition: fft_graph.h:87
int height
Definition: fft_graph.h:83
float * _in
Definition: fft_graph.h:101
AnalysisWindow * _a_window
Definition: fft_graph.h:96
cairo_surface_t * _surface
Definition: fft_graph.h:94
int width
Definition: fft_graph.h:82
bool event(GdkEvent *event)
PBD::PropertyDescriptor< uint32_t > color