/*
* CINELERRA
- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2008-2019 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
#include "bchash.inc"
+#include "compressortools.h"
#include "guicast.h"
#include "mutex.h"
#include "pluginaclient.h"
#include "vframe.inc"
class CompressorEffect;
+class CompressorWindow;
+class CompressorCanvas : public CompressorCanvasBase
+{
+public:
+ CompressorCanvas(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y, int w, int h);
+ void update_window();
+};
-
-class CompressorCanvas : public BC_SubWindow
+class CompressorLookAhead : public BC_TumbleTextBox
{
public:
- CompressorCanvas(CompressorEffect *plugin, int x, int y, int w, int h);
- int button_press_event();
- int button_release_event();
- int cursor_motion_event();
-
+ CompressorLookAhead(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
+ int handle_event();
+ CompressorEffect *plugin;
+};
- enum
- {
- NONE,
- DRAG
- };
+class CompressorAttack : public BC_TumbleTextBox
+{
+public:
+ CompressorAttack(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
+ int handle_event();
+ CompressorEffect *plugin;
+};
- int current_point;
- int current_operation;
+class CompressorRelease : public BC_TumbleTextBox
+{
+public:
+ CompressorRelease(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
+ int handle_event();
CompressorEffect *plugin;
};
-class CompressorReaction : public BC_TextBox
+class CompressorClear : public BC_GenericButton
{
public:
- CompressorReaction(CompressorEffect *plugin, int x, int y);
+ CompressorClear(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
int handle_event();
- int button_press_event();
CompressorEffect *plugin;
+ CompressorWindow *window;
};
-class CompressorClear : public BC_GenericButton
+class CompressorReset : public BC_GenericButton
{
public:
- CompressorClear(CompressorEffect *plugin, int x, int y);
+ CompressorReset(CompressorEffect *plugin,
+ CompressorWindow *window, int x, int y);
int handle_event();
CompressorEffect *plugin;
+ CompressorWindow *window;
};
-class CompressorX : public BC_TextBox
+class CompressorMkupGain : public BC_FPot
{
public:
- CompressorX(CompressorEffect *plugin, int x, int y);
+ CompressorMkupGain(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y, double *output, double min, double max);
int handle_event();
+ CompressorWindow *window;
CompressorEffect *plugin;
+ double *output;
};
-class CompressorY : public BC_TextBox
+class CompressorX : public BC_TumbleTextBox
{
public:
- CompressorY(CompressorEffect *plugin, int x, int y);
+ CompressorX(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
int handle_event();
CompressorEffect *plugin;
+ CompressorWindow *window;
};
-class CompressorTrigger : public BC_TextBox
+class CompressorY : public BC_TumbleTextBox
{
public:
- CompressorTrigger(CompressorEffect *plugin, int x, int y);
+ CompressorY(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
int handle_event();
- int button_press_event();
CompressorEffect *plugin;
+ CompressorWindow *window;
};
-class CompressorDecay : public BC_TextBox
+class CompressorTrigger : public BC_TumbleTextBox
{
public:
- CompressorDecay(CompressorEffect *plugin, int x, int y);
+ CompressorTrigger(CompressorEffect *plugin, CompressorWindow *window,
+ int x, int y);
int handle_event();
- int button_press_event();
CompressorEffect *plugin;
};
{
public:
CompressorWindow(CompressorEffect *plugin);
+ ~CompressorWindow();
+
void create_objects();
void update();
void update_textboxes();
- void update_canvas();
void draw_scales();
+ void update_meter(CompressorGainFrame *gain_frame);
int resize_event(int w, int h);
CompressorCanvas *canvas;
- CompressorReaction *reaction;
+ CompressorLookAhead *readahead;
+ CompressorAttack *attack;
CompressorClear *clear;
+ CompressorReset *reset;
+ CompressorMkupGain *mkup_gain;
CompressorX *x_text;
CompressorY *y_text;
CompressorTrigger *trigger;
- CompressorDecay *decay;
+ CompressorRelease *release;
CompressorSmooth *smooth;
CompressorInput *input;
+ BC_Meter *in;
+ BC_Meter *gain_change;
CompressorEffect *plugin;
};
-typedef struct
-{
-// DB from min_db - 0
- double x, y;
-} compressor_point_t;
-
-class CompressorConfig
+class CompressorConfig : public CompressorConfigBase
{
public:
CompressorConfig();
void copy_from(CompressorConfig &that);
int equivalent(CompressorConfig &that);
- void interpolate(CompressorConfig &prev,
- CompressorConfig &next,
- int64_t prev_frame,
- int64_t next_frame,
- int64_t current_frame);
-
- int total_points();
- void remove_point(int number);
- void optimize();
-// Return values of a specific point
- double get_y(int number);
- double get_x(int number);
-// Returns db output from db input
- double calculate_db(double x);
- int set_point(double x, double y);
- void dump();
-
- int trigger;
- int input;
- enum
- {
- TRIGGER,
- MAX,
- SUM
- };
- double min_db;
- double reaction_len;
- double decay_len;
- double min_x, min_y;
- double max_x, max_y;
- int smoothing_only;
- ArrayList<compressor_point_t> levels;
+ void interpolate(CompressorConfig &prev, CompressorConfig &next,
+ int64_t prev_frame, int64_t next_frame, int64_t current_frame);
};
+
class CompressorEffect : public PluginAClient
{
public:
int is_realtime();
void read_data(KeyFrame *keyframe);
void save_data(KeyFrame *keyframe);
- int process_buffer(int64_t size,
- Samples **buffer,
- int64_t start_position,
- int sample_rate);
- double calculate_gain(double input);
-
-// Calculate linear output from linear input
- double calculate_output(double x);
+ int process_buffer(int64_t size, Samples **buffer,
+ int64_t start_position, int sample_rate);
+ void allocate_input(int size);
- void reset();
void update_gui();
- void delete_dsp();
+ void render_stop();
PLUGIN_CLASS_MEMBERS(CompressorConfig)
-// The raw input data for each channel with readahead
+// Input data + read ahead for each channel
Samples **input_buffer;
+
// Number of samples in the input buffer
int64_t input_size;
// Number of samples allocated in the input buffer
int64_t input_allocated;
// Starting sample of input buffer relative to project in requested rate.
int64_t input_start;
+ int64_t last_position;
+ int need_reconfigure;
+
+
+ CompressorEngine *engine;
-// ending input value of smoothed input
- double next_target;
-// starting input value of smoothed input
- double previous_target;
-// samples between previous and next target value for readahead
- int target_samples;
-// current sample from 0 to target_samples
- int target_current_sample;
-// current smoothed input value
- double current_value;
// Temporaries for linear transfer
ArrayList<compressor_point_t> levels;
- double min_x, min_y;
- double max_x, max_y;
+// double min_x, min_y;
+// double max_x, max_y;
};