13
0

/float*/std::vector/ in fft_result.

This commit is contained in:
Gon Solo 2022-11-26 12:25:26 +01:00
parent a63e1add6d
commit b7aa98ee0c
2 changed files with 29 additions and 48 deletions

View File

@ -26,35 +26,24 @@
using namespace std; using namespace std;
FFTResult::FFTResult(FFTGraph *graph, Gdk::Color color, string trackname) FFTResult::FFTResult(FFTGraph *graph, Gdk::Color color, string trackname) :
{ _graph(graph),
_graph = graph; _windowSize(_graph->windowSize()),
_dataSize(_windowSize / 2),
_windowSize = _graph->windowSize(); _averages(0),
_dataSize = _windowSize / 2; _min_flat(0.0),
_averages = 0; _max_flat(0.0),
_min_flat = _max_flat = 0.0; _min_prop(0.0),
_min_prop = _max_prop = 0.0; _max_prop(0.0),
_data_flat_avg(_dataSize, 0),
_data_flat_avg = (float *) malloc (sizeof(float) * _dataSize); _data_flat_max(_dataSize, FLT_MIN),
_data_flat_min = (float *) malloc (sizeof(float) * _dataSize); _data_flat_min(_dataSize, FLT_MAX),
_data_flat_max = (float *) malloc (sizeof(float) * _dataSize); _data_prop_avg(_dataSize, 0),
_data_prop_avg = (float *) malloc (sizeof(float) * _dataSize); _data_prop_max(_dataSize, FLT_MIN),
_data_prop_min = (float *) malloc (sizeof(float) * _dataSize); _data_prop_min(_dataSize, FLT_MAX),
_data_prop_max = (float *) malloc (sizeof(float) * _dataSize); _color(color),
_trackname(trackname)
for (unsigned int i = 0; i < _dataSize; i++) { {}
_data_flat_min[i] = FLT_MAX;
_data_flat_max[i] = FLT_MIN;
_data_flat_avg[i] = 0;
_data_prop_min[i] = FLT_MAX;
_data_prop_max[i] = FLT_MIN;
_data_prop_avg[i] = 0;
}
_color = color;
_trackname = trackname;
}
void void
FFTResult::analyzeWindow(float *window) FFTResult::analyzeWindow(float *window)
@ -133,12 +122,3 @@ FFTResult::finalize()
_averages = 0; _averages = 0;
} }
FFTResult::~FFTResult()
{
free(_data_flat_avg);
free(_data_flat_min);
free(_data_flat_max);
free(_data_prop_avg);
free(_data_prop_min);
free(_data_prop_max);
}

View File

@ -26,6 +26,7 @@
#include <gdkmm/color.h> #include <gdkmm/color.h>
#include <string> #include <string>
#include <vector>
class FFTGraph; class FFTGraph;
@ -33,7 +34,7 @@ class FFTResult
{ {
public: public:
~FFTResult (); ~FFTResult () = default;
void analyzeWindow (float *window); void analyzeWindow (float *window);
void finalize (); void finalize ();
@ -58,24 +59,24 @@ private:
FFTResult (FFTGraph *graph, Gdk::Color color, std::string trackname); FFTResult (FFTGraph *graph, Gdk::Color color, std::string trackname);
friend class FFTGraph; friend class FFTGraph;
int _averages; FFTGraph *_graph;
float* _data_flat_avg;
float* _data_flat_max;
float* _data_flat_min;
float* _data_prop_avg;
float* _data_prop_max;
float* _data_prop_min;
unsigned int _windowSize; unsigned int _windowSize;
unsigned int _dataSize; unsigned int _dataSize;
int _averages;
float _min_flat; float _min_flat;
float _max_flat; float _max_flat;
float _min_prop; float _min_prop;
float _max_prop; float _max_prop;
FFTGraph *_graph; std::vector<float> _data_flat_avg;
std::vector<float> _data_flat_max;
std::vector<float> _data_flat_min;
std::vector<float> _data_prop_avg;
std::vector<float> _data_prop_max;
std::vector<float> _data_prop_min;
Gdk::Color _color; Gdk::Color _color;
std::string _trackname; std::string _trackname;