/*
* CINELERRA
* Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
- *
+ *
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ *
*/
#include "bcdisplayinfo.h"
point->freq = that.points.get(i)->freq;
point->value = that.points.get(i)->value;
}
-
+
window_size = that.window_size;
}
-void GraphicConfig::interpolate(GraphicConfig &prev,
- GraphicConfig &next,
- int64_t prev_frame,
- int64_t next_frame,
+void GraphicConfig::interpolate(GraphicConfig &prev,
+ GraphicConfig &next,
+ int64_t prev_frame,
+ int64_t next_frame,
int64_t current_frame)
{
double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
// Get current set of points from previous configuration
copy_from(prev);
-
+
// Interpolate between current set of points and next set
for(int i = 0; i < MIN(next.points.size(), points.size()); i++)
-GraphicCanvas::GraphicCanvas(GraphicEQ *plugin,
+GraphicCanvas::GraphicCanvas(GraphicEQ *plugin,
GraphicGUI *gui,
- int x,
- int y,
- int w,
+ int x,
+ int y,
+ int w,
int h)
: BC_SubWindow(x,
y,
process(1, 0, 0);
if(state == GraphicCanvas::DRAG_POINT)
return 1;
- else
+ else
return 0;
}
double magnitude_db = DB::todb(magnitude);
if(magnitude_db < -MAXMAGNITUDE) magnitude_db = -MAXMAGNITUDE;
int y = (int)(center_y - magnitude_db * center_y / MAXMAGNITUDE);
-//printf("GraphicCanvas::freq_to_y magnitude=%f magnitude_db=%f y=%d\n",
+//printf("GraphicCanvas::freq_to_y magnitude=%f magnitude_db=%f y=%d\n",
//magnitude, magnitude_db, y);
return y;
}
*point = *plugin->config.points.get(i);
temp_points.append(point);
}
-
+
plugin->calculate_envelope(&temp_points, temp_envelope);
}
int index = (int64_t)freq * (int64_t)frame->window_size / 2 / niquist;
if(index < frame->window_size / 2)
{
- double magnitude = frame->data[index] /
- frame->freq_max *
+ double magnitude = frame->data[index] /
+ frame->freq_max *
frame->time_max;
- y2 = (int)(get_h() -
+ y2 = (int)(get_h() -
(DB::todb(magnitude) - INFINITYGAIN) *
- get_h() /
+ get_h() /
-INFINITYGAIN);
CLAMP(y2, 0, get_h() - 1);
if(i > 0)
int point_y = get_cursor_y() + y_diff;
CLAMP(point_x, 0, get_w());
CLAMP(point_y, 0, get_h());
-
+
int frequency = Freq::tofreq(point_x * TOTALFREQS / get_w());
double magnitude_db = (double)(center_y - point_y) * MAXMAGNITUDE / center_y;
int minfreq = Freq::tofreq(0);
{
y1 = y;
// Draw point under cursor if out of order
- if(i == plugin->active_point && out_of_order)
+ if(i == plugin->active_point && out_of_order)
y1 = get_cursor_y() + y_diff;
if(i == plugin->active_point)
draw_rectangle(x - BOX_SIZE / 2, y1 - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
}
- if(motion &&
+ if(motion &&
state == GraphicCanvas::NONE &&
- is_event_win() &&
+ is_event_win() &&
cursor_inside())
{
if(get_cursor_x() >= x - BOX_SIZE / 2 &&
new_cursor = UPRIGHT_ARROW_CURSOR;
}
}
-
+
if(buttonpress &&
state == GraphicCanvas::NONE &&
- is_event_win() &&
+ is_event_win() &&
cursor_inside() &&
!got_button)
{
set_line_width(2);
for(int i = 0; i < get_w(); i++)
{
- int y = freq_to_y(Freq::tofreq(i * TOTALFREQS / get_w()),
- points,
+ int y = freq_to_y(Freq::tofreq(i * TOTALFREQS / get_w()),
+ points,
envelope);
if(draw)
if(is_event_win() && cursor_inside())
{
GraphicPoint *new_point = new GraphicPoint;
- new_point->freq = Freq::tofreq(get_cursor_x() *
- TOTALFREQS /
+ new_point->freq = Freq::tofreq(get_cursor_x() *
+ TOTALFREQS /
get_w());
- new_point->value = (double)(center_y - get_cursor_y()) *
- MAXMAGNITUDE /
+ new_point->value = (double)(center_y - get_cursor_y()) *
+ MAXMAGNITUDE /
center_y;
state = GraphicCanvas::DRAG_POINT;
new_temps();
}
- if(draw)
+ if(draw)
{
flash();
}
-//
-//
+//
+//
// GraphicWetness::GraphicWetness(GraphicGUI *window, GraphicEQ *plugin, int x, int y)
// : BC_FPot(x, y, plugin->config.wetness, INFINITYGAIN, 0)
// {
// this->plugin = plugin;
// this->window = window;
// }
-//
+//
// int GraphicWetness::handle_event()
// {
// plugin->config.wetness = get_value();
// window->update_canvas();
// return 1;
// }
-//
-//
-//
+//
+//
+//
GraphicGUI::GraphicGUI(GraphicEQ *plugin)
- : PluginClientWindow(plugin,
- plugin->w,
- plugin->h,
- 320,
+ : PluginClientWindow(plugin,
+ plugin->w,
+ plugin->h,
+ 320,
200,
1)
{
add_subwindow(canvas = new GraphicCanvas(plugin,
this,
- x,
- y,
- get_w() - x - margin,
- get_h() -
-// BC_Pot::calculate_h() -
+ x,
+ y,
+ get_w() - x - margin,
+ get_h() -
+// BC_Pot::calculate_h() -
BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) -
- margin * 3 -
- y -
+ margin * 3 -
+ y -
freq_h));
y += canvas->get_h() + freq_h + margin;
add_subwindow(reset = new GraphicReset(plugin, this, x, y));
x += reset->get_w() + margin;
-
+
// x = x1;
// y += value_text->get_h() + margin;
// add_subwindow(title = new BC_Title(x, y, "Wetness:"));
// x += title->get_w() + margin;
-// add_subwindow(wetness = new GraphicWetness(this, plugin,
-// x,
+// add_subwindow(wetness = new GraphicWetness(this, plugin,
+// x,
// y));
draw_ticks();
int difference = h - get_h();
int canvas_xdiff = get_w() - canvas->get_w();
int canvas_ydiff = get_h() - canvas->get_h();
-
+
canvas->reposition_window(canvas->get_x(),
canvas->get_y(),
w - canvas_xdiff,
break;
}
}
-
+
if(point_number >= 0)
{
plugin->config.delete_point(point_number);
int y2 = canvas->get_y() + canvas->get_h() + LINE_W2 - 1;
int y3 = canvas->get_y() + canvas->get_h() + LINE_W3 - 1;
int y4 = canvas->get_y() + canvas->get_h() + get_text_height(SMALLFONT) + LINE_W4 - 1;
-
+
set_color(BLACK);
draw_text(x2 + 1, y4 + 1, string);
draw_line(x1 + 1, y3 + 1, x1 + 1, y1 + 1);
-
+
set_color(RED);
draw_text(x2, y4, string);
draw_line(x1, y3, x1, y1);
-
+
if(i < MAJOR_DIVISIONS)
{
for(int j = 0; j < MINOR_DIVISIONS; j++)
GraphicEQ::GraphicEQ(PluginServer *server)
: PluginAClient(server)
{
- last_frame = 0;
+ last_frame = 0;
fft = 0;
need_reconfigure = 1;
active_point = -1;
GraphicEQ::~GraphicEQ()
{
-
+
delete last_frame;
if(fft) delete fft;
}
int GraphicEQ::is_realtime() { return 1; }
-const char* GraphicEQ::plugin_title() { return _("EQ Graphic"); }
+const char* GraphicEQ::plugin_title() { return N_("EQ Graphic"); }
NEW_WINDOW_MACRO(GraphicEQ, GraphicGUI)
output.append_tag();
output.append_newline();
}
-
+
output.terminate_string();
}
void GraphicEQ::update_gui()
{
- if(thread)
- {
- if(load_configuration() &&
- ((GraphicGUI*)thread->window)->canvas->state != GraphicCanvas::DRAG_POINT)
- {
- ((GraphicGUI*)thread->window)->lock_window("GraphicEQ::update_gui");
- ((GraphicGUI*)thread->window)->update_canvas();
- ((GraphicGUI*)thread->window)->update_textboxes();
- ((GraphicGUI*)thread->window)->unlock_window();
- }
- else
- {
- int total_frames = get_gui_update_frames();
+ if( !thread ) return;
+ GraphicGUI *window = (GraphicGUI *)thread->window;
+//lock here for points, needed by window cursor_motion callback
+// deleted in load_configuration by read_data
+ window->lock_window("GraphicEQ::update_gui");
+ if( load_configuration() &&
+ window->canvas->state != GraphicCanvas::DRAG_POINT ) {
+ window->update_canvas();
+ window->update_textboxes();
+ }
+ else {
+ int total_frames = get_gui_update_frames();
//printf("ParametricEQ::update_gui %d %d\n", __LINE__, total_frames);
- if(total_frames)
- {
- ((GraphicGUI*)thread->window)->lock_window("GraphicEQ::update_gui");
- ((GraphicGUI*)thread->window)->update_canvas();
- ((GraphicGUI*)thread->window)->unlock_window();
- }
- }
+ if( total_frames )
+ window->update_canvas();
}
+ window->unlock_window();
}
void GraphicEQ::reconfigure()
delete fft;
fft = 0;
}
-
+
if(!fft)
{
fft = new GraphicFFT(this);
}
calculate_envelope(&config.points, envelope);
-
+
for(int i = 0; i < config.window_size / 2; i++)
{
if(envelope[i] < 0) envelope[i] = 0;
need_reconfigure = 0;
}
-int GraphicEQ::process_buffer(int64_t size,
- Samples *buffer,
+int GraphicEQ::process_buffer(int64_t size,
+ Samples *buffer,
int64_t start_position,
int sample_rate)
{
need_reconfigure |= load_configuration();
if(need_reconfigure) reconfigure();
-
+
fft->process_buffer(start_position, size, buffer, get_direction());
for(int i = 0; i < temp_points.size(); i++)
{
GraphicPoint *point = temp_points.get(i);
- if(i == active_point)
+ if(i == active_point)
{
GraphicPoint *prev_point = 0;
GraphicPoint *next_point = 0;
break;
}
}
-
+
if(point2->freq != point1->freq)
{
int freqslot1 = Freq::fromfreq(point1->freq);
int freqslot2 = Freq::fromfreq(point2->freq);
int freqslot = Freq::fromfreq(freq);
-
+
envelope[i] = (double)(freqslot - freqslot1) *
- (point2->value - point1->value) /
+ (point2->value - point1->value) /
(freqslot2 - freqslot1) +
point1->value;
}
}
- if(envelope[i] < MIN_DB + 0.01)
+ if(envelope[i] < MIN_DB + 0.01)
envelope[i] = 0;
else
envelope[i] = DB::fromdb(envelope[i]);
int GraphicFFT::signal_process()
{
// Create new frame for updating GUI
- frame = new GraphicGUIFrame(window_size,
+ frame = new GraphicGUIFrame(window_size,
plugin->PluginAClient::project_sample_rate);
plugin->add_gui_frame(frame);
-int GraphicFFT::read_samples(int64_t output_sample,
- int samples,
+int GraphicFFT::read_samples(int64_t output_sample,
+ int samples,
Samples *buffer)
{
return plugin->read_samples(buffer,