1 /* Calf Analyzer FFT Library
2 * Copyright (C) 2007-2013 Krzysztof Foltman, Markus Schmidt,
3 * Christian Holschuh and others
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
21 #ifndef CALF_ANALYZER_H
22 #define CALF_ANALYZER_H
33 #include "plugin_tools.h"
36 #define MATH_E 2.718281828
38 namespace calf_plugins
{
40 class analyzer
: public frequency_response_line_graph
43 mutable int _accuracy
;
50 mutable int _windowing
;
54 mutable float _resolution
;
55 mutable float _offset
;
56 mutable bool _falling
;
57 mutable int _draw_upper
;
63 void process(float L
, float R
);
64 void set_sample_rate(uint32_t sr
);
65 bool set_mode(int mode
);
67 void set_params(float resolution
, float offset
, int accuracy
, int hold
, int smoothing
, int mode
, int scale
, int post
, int speed
, int windowing
, int view
, int freeze
);
69 bool do_fft(int subindex
, int points
) const;
70 void draw(int subindex
, float *data
, int points
, bool fftdone
) const;
71 bool get_graph(int subindex
, int phase
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
72 bool get_moving(int subindex
, int &direction
, float *data
, int x
, int y
, int &offset
, uint32_t &color
) const;
73 bool get_gridline(int subindex
, int phase
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
74 bool get_layers(int generation
, unsigned int &layers
) const;
80 mutable bool sanitize
, recreate_plan
;
81 static const int MAX_FFT_ORDER
= 15;
82 dsp::fft
<float, MAX_FFT_ORDER
> fft
;
83 mutable dsp::fft
<float, MAX_FFT_ORDER
>::complex fft_temp
[1 << MAX_FFT_ORDER
];
84 static const int max_fft_cache_size
= 32768;
85 static const int max_fft_buffer_size
= max_fft_cache_size
* 2;
86 float *fft_inL
, *fft_outL
;
87 float *fft_inR
, *fft_outR
;
88 float *fft_smoothL
, *fft_smoothR
;
89 float *fft_deltaL
, *fft_deltaR
;
90 float *fft_holdL
, *fft_holdR
;
91 float *fft_freezeL
, *fft_freezeR
;
93 mutable int analyzer_phase_drawn
;