ParametricMode::ParametricMode(ParametricEQ *plugin, int x, int y, int band)
: BC_PopupMenu(x,
y,
- 150,
+ xS(150),
mode_to_text(plugin->config.band[band].mode))
{
//printf("ParametricMode::ParametricMode %d %d\n", band, plugin->config.band[band].mode);
}
-#define X1 10
-#define X2 60
-#define X3 110
-#define X4 160
+#define X1 xS(10)
+#define X2 xS(60)
+#define X3 xS(110)
+#define X4 xS(160)
void ParametricBandGUI::create_objects()
ParametricSize::ParametricSize(ParametricWindow *window, ParametricEQ *plugin, int x, int y)
- : BC_PopupMenu(x, y, 100, "4096", 1)
+ : BC_PopupMenu(x, y, xS(120), "4096", 1)
{
this->plugin = plugin;
this->window = window;
ParametricWindow::ParametricWindow(ParametricEQ *plugin)
: PluginClientWindow(plugin,
- 350,
- 400,
- 350,
- 400,
+ xS(350),
+ yS(400),
+ xS(350),
+ yS(400),
0)
{
this->plugin = plugin;
void ParametricWindow::create_objects()
{
- int y = 35;
+ int y = yS(35);
SET_TRACE
add_subwindow(new BC_Title(X1, 10, _("Freq")));
add_subwindow(new BC_Title(X4, 10, _("Mode")));
for(int i = 0; i < BANDS; i++)
{
- bands[i] = new ParametricBandGUI(plugin, this, 10, y, i);
+ bands[i] = new ParametricBandGUI(plugin, this, xS(10), y, i);
bands[i]->create_objects();
- y += 50;
+ y += yS(50);
}
SET_TRACE
BC_Title *title;
int x = plugin->get_theme()->widget_border;
- add_subwindow(title = new BC_Title(x, y + 10, _("Wetness:")));
+ add_subwindow(title = new BC_Title(x, y + yS(10), _("Wetness:")));
x += title->get_w() + plugin->get_theme()->widget_border;
add_subwindow(wetness = new ParametricWetness(plugin,
x,
y));
x += wetness->get_w() + plugin->get_theme()->widget_border;
- add_subwindow(title = new BC_Title(x, y + 10, _("Window:")));
+ add_subwindow(title = new BC_Title(x, y + yS(10), _("Window:")));
x += title->get_w() + plugin->get_theme()->widget_border;
add_subwindow(size = new ParametricSize(this,
plugin,
x,
- y + 10));
+ y + yS(10)));
size->create_objects();
size->update(plugin->config.window_size);
- y += 50;
- int canvas_x = 30;
+ y += yS(50);
+ int canvas_x = xS(30);
int canvas_y = y;
- int canvas_w = get_w() - canvas_x - 10;
- int canvas_h = get_h() - canvas_y - 30;
+ int canvas_w = get_w() - canvas_x - xS(10);
+ int canvas_h = get_h() - canvas_y - yS(30);
add_subwindow(canvas = new BC_SubWindow(canvas_x,
canvas_y,
canvas_w,
for(int i = 0; i <= MAJOR_DIVISIONS; i++)
{
int y1 = canvas_y + canvas_h - i * (canvas_h / MAJOR_DIVISIONS) - 2;
- int y2 = y1 + 3;
- int x1 = canvas_x - 25;
- int x2 = canvas_x - 10;
- int x3 = canvas_x - 2;
+ int y2 = y1 + yS(3);
+ int x1 = canvas_x - xS(25);
+ int x2 = canvas_x - xS(10);
+ int x3 = canvas_x - xS(2);
char string[BCTEXTLEN];
if(i == 0)
for(int j = 1; j < MINOR_DIVISIONS; j++)
{
int y3 = y1 - j * (canvas_h / MAJOR_DIVISIONS) / MINOR_DIVISIONS;
- int x4 = x3 - 5;
+ int x4 = x3 - xS(5);
set_color(BLACK);
draw_line(x4 + 1, y3 + 1, x3 + 1, y3 + 1);
set_color(RED);
{
int freq = Freq::tofreq(i * TOTALFREQS / MAJOR_DIVISIONS);
int x1 = canvas_x + i * canvas_w / MAJOR_DIVISIONS;
- int y1 = canvas_y + canvas_h + 20;
+ int y1 = canvas_y + canvas_h + yS(20);
char string[BCTEXTLEN];
sprintf(string, "%d", freq);
int x2 = x1 - get_text_width(SMALLFONT, string);
- int y2 = y1 - 10;
- int y3 = y2 - 5;
+ int y2 = y1 - yS(10);
+ int y3 = y2 - yS(5);
int y4 = canvas_y + canvas_h;
set_color(BLACK);
exp(-(double)j * 0.7) *
(canvas_w / MAJOR_DIVISIONS));
set_color(BLACK);
- draw_line(x3 + 1, y4 + 1, x3 + 1, y3 + 1);
+ draw_line(x3+1, y4+1, x3+1, y3+1);
set_color(RED);
draw_line(x3, y4, x3, y3);
}
canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
-
-
// Draw spectrogram
- int total_frames = plugin->get_gui_update_frames();
- ParametricGUIFrame *frame = (ParametricGUIFrame*)plugin->get_gui_frame();
-
- if(frame)
- {
- delete plugin->last_frame;
- plugin->last_frame = frame;
- }
- else
- {
- frame = plugin->last_frame;
- }
-
+ double tracking_position = plugin->get_tracking_position();
+ ParametricGUIFrame *frame = (ParametricGUIFrame *)
+ plugin->get_gui_frame(tracking_position, 1);
// Draw most recent frame
- if(frame)
- {
+ if( frame ) {
+ int y1 = 0, y2 = 0;
canvas->set_color(MEGREY);
- int y1 = 0;
- int y2 = 0;
- for(int i = 0; i < canvas->get_w(); i++)
- {
+
+ for(int i = 0; i < canvas->get_w(); i++) {
int freq = Freq::tofreq(i * TOTALFREQS / canvas->get_w());
int index = (int64_t)freq * (int64_t)frame->window_size / 2 / niquist;
- if(index < frame->window_size / 2)
- {
+ if(index < frame->window_size / 2) {
double magnitude = frame->data[index] /
- frame->freq_max *
- frame->time_max;
+ frame->freq_max * frame->time_max;
y2 = (int)(canvas->get_h() -
(DB::todb(magnitude) - INFINITYGAIN) *
- canvas->get_h() /
- -INFINITYGAIN);
+ canvas->get_h() / -INFINITYGAIN);
CLAMP(y2, 0, canvas->get_h() - 1);
if(i > 0)
- {
canvas->draw_line(i - 1, y1, i, y2);
- }
y1 = y2;
}
}
-
- total_frames--;
+ delete frame;
}
-
-
-
-
-
-// Delete remaining frames
- while(total_frames > 0)
- {
- PluginClientFrame *frame = plugin->get_gui_frame();
-
- if(frame) delete frame;
- total_frames--;
- }
-
-
-
-
-
// canvas->set_color(GREEN);
// canvas->draw_line(0, wetness, canvas->get_w(), wetness);
// canvas->draw_line(0,
}
-
-
-
-
-
ParametricGUIFrame::ParametricGUIFrame(int window_size, int sample_rate)
- : PluginClientFrame(window_size / 2, window_size / 2, sample_rate)
+ : PluginClientFrame()
{
this->window_size = window_size;
- data = new double[window_size / 2];
+ data_size = window_size / 2;
+ data = new double[data_size];
freq_max = 0;
time_max = 0;
}
}
-
-
-
-
-
-
-
-
ParametricFFT::ParametricFFT(ParametricEQ *plugin)
: CrossfadeFFT()
{
return 0;
}
-
-
-
-
-
-
-
-
-
-
void ParametricEQ::reset()
{
need_reconfigure = 1;
void ParametricEQ::update_gui()
{
- if(thread)
- {
- if(load_configuration())
- {
- ((ParametricWindow*)thread->window)->lock_window("ParametricEQ::update_gui");
- calculate_envelope();
- ((ParametricWindow*)thread->window)->update_gui();
- ((ParametricWindow*)thread->window)->unlock_window();
- }
- else
- {
- int total_frames = get_gui_update_frames();
-//printf("ParametricEQ::update_gui %d %d\n", __LINE__, total_frames);
- if(total_frames)
- {
- ((ParametricWindow*)thread->window)->lock_window("ParametricEQ::update_gui");
- ((ParametricWindow*)thread->window)->update_canvas();
- ((ParametricWindow*)thread->window)->unlock_window();
- }
- }
+ if( !thread ) return;
+ ParametricWindow *window = (ParametricWindow*)thread->window;
+ window->lock_window("ParametricEQ::update_gui");
+ if( load_configuration() ) {
+ calculate_envelope();
+ window->update_gui();
}
+ else if( pending_gui_frame() ) {
+ window->update_canvas();
+ }
+ window->unlock_window();
}
-
-