new/reworked audio plugins ported from hv72 compressor/multi/reverb, glyph workaround...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / compressor / compressor.h
index 412b8db93b845f3d3b62bf0c133ac4a121bea711..dc9c54adbde762f4b28fc519eec69a1574169313 100644 (file)
@@ -1,7 +1,7 @@
 
 /*
  * 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
@@ -25,6 +25,7 @@
 
 
 #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 BC_SubWindow
+class CompressorCanvas : public CompressorCanvasBase
 {
 public:
-       CompressorCanvas(CompressorEffect *plugin, int x, int y, int w, int h);
-       int button_press_event();
-       int button_release_event();
-       int cursor_motion_event();
-
+       CompressorCanvas(CompressorEffect *plugin, CompressorWindow *window,
+                       int x, int y, int w, int h);
+       void update_window();
+};
 
-       enum
-       {
-               NONE,
-               DRAG
-       };
 
-       int current_point;
-       int current_operation;
+class CompressorLookAhead : public BC_TumbleTextBox
+{
+public:
+       CompressorLookAhead(CompressorEffect *plugin, CompressorWindow *window,
+                       int x, int y);
+       int handle_event();
        CompressorEffect *plugin;
 };
 
-
-class CompressorReaction : public BC_TextBox
+class CompressorAttack : public BC_TumbleTextBox
 {
 public:
-       CompressorReaction(CompressorEffect *plugin, int x, int y);
+       CompressorAttack(CompressorEffect *plugin, CompressorWindow *window,
+                       int x, int y);
        int handle_event();
-       int button_press_event();
        CompressorEffect *plugin;
 };
 
-class CompressorClear : public BC_GenericButton
+class CompressorRelease : public BC_TumbleTextBox
 {
 public:
-       CompressorClear(CompressorEffect *plugin, int x, int y);
+       CompressorRelease(CompressorEffect *plugin, CompressorWindow *window,
+                       int x, int y);
        int handle_event();
        CompressorEffect *plugin;
 };
 
-class CompressorX : public BC_TextBox
+
+class CompressorClear : public BC_GenericButton
 {
 public:
-       CompressorX(CompressorEffect *plugin, int x, int y);
+       CompressorClear(CompressorEffect *plugin, int x, int y);
        int handle_event();
        CompressorEffect *plugin;
 };
 
-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;
 };
 
-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;
 };
 
-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;
 };
 
@@ -134,74 +133,44 @@ class CompressorWindow : public PluginClientWindow
 {
 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;
        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:
@@ -212,45 +181,35 @@ 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;
 };