2006-03-12 16:58:52 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2008-2011 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2016 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2006-03-12 16:58:52 -05:00
|
|
|
|
|
|
|
#ifndef __ardour_fft_graph_h
|
|
|
|
#define __ardour_fft_graph_h
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/types.h"
|
2006-03-12 16:58:52 -05:00
|
|
|
#include <fftw3.h>
|
|
|
|
|
|
|
|
#include <gtkmm/drawingarea.h>
|
|
|
|
#include <gtkmm/treemodel.h>
|
|
|
|
#include <gdkmm/color.h>
|
|
|
|
|
|
|
|
#include <glibmm/refptr.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "fft_result.h"
|
|
|
|
|
|
|
|
class AnalysisWindow;
|
|
|
|
|
|
|
|
class FFTGraph : public Gtk::DrawingArea
|
|
|
|
{
|
2016-05-22 13:29:08 -04:00
|
|
|
public:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
FFTGraph (int windowSize);
|
|
|
|
~FFTGraph ();
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
void set_analysis_window (AnalysisWindow *a_window);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
int windowSize () const { return _windowSize; }
|
|
|
|
void setWindowSize (int windowSize);
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
void redraw ();
|
|
|
|
bool on_expose_event (GdkEventExpose* event);
|
2016-07-24 06:59:52 -04:00
|
|
|
bool on_motion_notify_event (GdkEventMotion*);
|
|
|
|
bool on_leave_notify_event (GdkEventCrossing*);
|
|
|
|
bool on_button_press_event (GdkEventButton*) { return true; }
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
void on_size_request (Gtk::Requisition* requisition);
|
|
|
|
void on_size_allocate (Gtk::Allocation & alloc);
|
|
|
|
FFTResult *prepareResult (Gdk::Color color, std::string trackname);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
void set_show_minmax (bool v) { _show_minmax = v; redraw (); }
|
|
|
|
void set_show_normalized (bool v) { _show_normalized = v; redraw (); }
|
|
|
|
void set_show_proportioanl(bool v) { _show_proportional = v; redraw (); }
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
private:
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
void update_size ();
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
void setWindowSize_internal (int windowSize);
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-07-24 06:59:52 -04:00
|
|
|
int draw_scales (cairo_t*);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
static const int minScaleWidth = 512;
|
|
|
|
static const int minScaleHeight = 420;
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
static const int hl_margin = 40; // this should scale with font (dBFS labels)
|
|
|
|
static const int hr_margin = 12;
|
|
|
|
static const int v_margin = 12;
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
int currentScaleWidth;
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
int width;
|
|
|
|
int height;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-07-24 06:59:52 -04:00
|
|
|
int _yoff;
|
|
|
|
int _ann_x;
|
|
|
|
int _ann_y;
|
|
|
|
cairo_rectangle_t _ann_area;
|
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
unsigned int _windowSize;
|
|
|
|
unsigned int _dataSize;
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
Glib::RefPtr<Pango::Layout> layout;
|
2016-07-24 06:59:52 -04:00
|
|
|
cairo_surface_t* _surface;
|
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
AnalysisWindow *_a_window;
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
fftwf_plan _plan;
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
float* _out;
|
|
|
|
float* _in;
|
|
|
|
float* _hanning;
|
|
|
|
int* _logScale;
|
2006-03-12 16:58:52 -05:00
|
|
|
|
2016-05-22 13:29:08 -04:00
|
|
|
bool _show_minmax;
|
|
|
|
bool _show_normalized;
|
|
|
|
bool _show_proportional;
|
|
|
|
|
|
|
|
float _fft_start;
|
|
|
|
float _fft_end;
|
|
|
|
float _fft_log_base;
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2006-03-12 16:58:52 -05:00
|
|
|
friend class FFTResult;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __ardour_fft_graph_h */
|