*/
+#ifdef COMPILER_MSVC
+#include <algorithm>
+using std::min; using std::max;
+#endif
+
#include <iostream>
#include <glibmm.h>
FFTGraph::setWindowSize(int windowSize)
{
if (_a_window) {
- Glib::Mutex::Lock lm (_a_window->track_list_lock);
+ Glib::Threads::Mutex::Lock lm (_a_window->track_list_lock);
setWindowSize_internal(windowSize);
} else {
setWindowSize_internal(windowSize);
void
FFTGraph::redraw()
{
- Glib::Mutex::Lock lm (_a_window->track_list_lock);
+ Glib::Threads::Mutex::Lock lm (_a_window->track_list_lock);
draw_scales(get_window());
// Find "session wide" min & max
- float min = 1000000000000.0;
- float max = -1000000000000.0;
+ float minf = 1000000000000.0;
+ float maxf = -1000000000000.0;
TreeNodeChildren track_rows = _a_window->track_list.get_model()->children();
continue;
}
- if ( res->minimum() < min) {
- min = res->minimum();
+ if ( res->minimum() < minf) {
+ minf = res->minimum();
}
- if ( res->maximum() > max) {
- max = res->maximum();
+ if ( res->maximum() > maxf) {
+ maxf = res->maximum();
}
}
if (!_show_normalized) {
- min = -150.0f;
- max = 0.0f;
+ minf = -150.0f;
+ maxf = 0.0f;
}
//int graph_height = height - 2 * h_margin;
float fft_pane_size_w = (float)(width - 2*v_margin) - 1.0;
float fft_pane_size_h = (float)(height - 2*h_margin);
- double pixels_per_db = (double)fft_pane_size_h / (double)(max - min);
+ double pixels_per_db = (double)fft_pane_size_h / (double)(maxf - minf);
cairo_rectangle(cr, 0.0, 0.0, fft_pane_size_w, fft_pane_size_h);
cairo_clip(cr);
mpp = -1000000.0;
cairo_set_source_rgba(cr, res->get_color().get_red_p(), res->get_color().get_green_p(), res->get_color().get_blue_p(), 0.30);
- cairo_move_to(cr, 0.5f + (float)_logScale[0], 0.5f + (float)( fft_pane_size_h - (int)floor( (res->maxAt(0) - min) * pixels_per_db) ));
+ cairo_move_to(cr, 0.5f + (float)_logScale[0], 0.5f + (float)( fft_pane_size_h - (int)floor( (res->maxAt(0) - minf) * pixels_per_db) ));
// Draw the line of maximum values
for (int x = 1; x < res->length(); x++) {
if (res->maxAt(x) > mpp)
mpp = res->maxAt(x);
- mpp = fmax(mpp, min);
- mpp = fmin(mpp, max);
+ mpp = fmax(mpp, minf);
+ mpp = fmin(mpp, maxf);
// If the next point on the log scale is at the same location,
// don't draw yet
}
float X = 0.5f + (float)_logScale[x];
- float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - min) * pixels_per_db) );
+ float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - minf) * pixels_per_db) );
cairo_line_to(cr, X, Y);
for (int x = res->length()-1; x >= 0; x--) {
if (res->minAt(x) < mpp)
mpp = res->minAt(x);
- mpp = fmax(mpp, min);
- mpp = fmin(mpp, max);
+ mpp = fmax(mpp, minf);
+ mpp = fmin(mpp, maxf);
// If the next point on the log scale is at the same location,
// don't draw yet
}
float X = 0.5f + (float)_logScale[x];
- float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - min) * pixels_per_db) );
+ float Y = 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - minf) * pixels_per_db) );
cairo_line_to(cr, X, Y );
if (res->avgAt(x) > mpp)
mpp = res->avgAt(x);
- mpp = fmax(mpp, min);
- mpp = fmin(mpp, max);
+ mpp = fmax(mpp, minf);
+ mpp = fmin(mpp, maxf);
// If the next point on the log scale is at the same location,
// don't draw yet
continue;
}
- cairo_line_to(cr, 0.5f + (float)_logScale[x], 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - min) * pixels_per_db) ));
+ cairo_line_to(cr, 0.5f + (float)_logScale[x], 0.5f + (float)( fft_pane_size_h - (int)floor( (mpp - minf) * pixels_per_db) ));
mpp = -1000000.0;
}