00001 #ifndef COMPRESSOR_H
00002 #define COMPRESSOR_H
00003
00004
00005
00006 #include "bchash.inc"
00007 #include "guicast.h"
00008 #include "mutex.h"
00009 #include "pluginaclient.h"
00010 #include "vframe.inc"
00011
00012 class CompressorEffect;
00013
00014
00015
00016
00017
00018 class CompressorCanvas : public BC_SubWindow
00019 {
00020 public:
00021 CompressorCanvas(CompressorEffect *plugin, int x, int y, int w, int h);
00022 int button_press_event();
00023 int button_release_event();
00024 int cursor_motion_event();
00025
00026
00027 enum
00028 {
00029 NONE,
00030 DRAG
00031 };
00032
00033 int current_point;
00034 int current_operation;
00035 CompressorEffect *plugin;
00036 };
00037
00038
00039 class CompressorReaction : public BC_TextBox
00040 {
00041 public:
00042 CompressorReaction(CompressorEffect *plugin, int x, int y);
00043 int handle_event();
00044 int button_press_event();
00045 CompressorEffect *plugin;
00046 };
00047
00048 class CompressorClear : public BC_GenericButton
00049 {
00050 public:
00051 CompressorClear(CompressorEffect *plugin, int x, int y);
00052 int handle_event();
00053 CompressorEffect *plugin;
00054 };
00055
00056 class CompressorX : public BC_TextBox
00057 {
00058 public:
00059 CompressorX(CompressorEffect *plugin, int x, int y);
00060 int handle_event();
00061 CompressorEffect *plugin;
00062 };
00063
00064 class CompressorY : public BC_TextBox
00065 {
00066 public:
00067 CompressorY(CompressorEffect *plugin, int x, int y);
00068 int handle_event();
00069 CompressorEffect *plugin;
00070 };
00071
00072 class CompressorTrigger : public BC_TextBox
00073 {
00074 public:
00075 CompressorTrigger(CompressorEffect *plugin, int x, int y);
00076 int handle_event();
00077 int button_press_event();
00078 CompressorEffect *plugin;
00079 };
00080
00081 class CompressorDecay : public BC_TextBox
00082 {
00083 public:
00084 CompressorDecay(CompressorEffect *plugin, int x, int y);
00085 int handle_event();
00086 int button_press_event();
00087 CompressorEffect *plugin;
00088 };
00089
00090 class CompressorSmooth : public BC_CheckBox
00091 {
00092 public:
00093 CompressorSmooth(CompressorEffect *plugin, int x, int y);
00094 int handle_event();
00095 CompressorEffect *plugin;
00096 };
00097
00098 class CompressorInput : public BC_PopupMenu
00099 {
00100 public:
00101 CompressorInput(CompressorEffect *plugin, int x, int y);
00102 void create_objects();
00103 int handle_event();
00104 static char* value_to_text(int value);
00105 static int text_to_value(char *text);
00106 CompressorEffect *plugin;
00107 };
00108
00109
00110
00111 class CompressorWindow : public BC_Window
00112 {
00113 public:
00114 CompressorWindow(CompressorEffect *plugin, int x, int y);
00115 void create_objects();
00116 void update();
00117 void update_textboxes();
00118 void update_canvas();
00119 int close_event();
00120 void draw_scales();
00121
00122
00123 CompressorCanvas *canvas;
00124 CompressorReaction *reaction;
00125 CompressorClear *clear;
00126 CompressorX *x_text;
00127 CompressorY *y_text;
00128 CompressorTrigger *trigger;
00129 CompressorDecay *decay;
00130 CompressorSmooth *smooth;
00131 CompressorInput *input;
00132 CompressorEffect *plugin;
00133 };
00134
00135 PLUGIN_THREAD_HEADER(CompressorEffect, CompressorThread, CompressorWindow)
00136
00137
00138 typedef struct
00139 {
00140
00141 double x, y;
00142 } compressor_point_t;
00143
00144 class CompressorConfig
00145 {
00146 public:
00147 CompressorConfig();
00148
00149 void copy_from(CompressorConfig &that);
00150 int equivalent(CompressorConfig &that);
00151 void interpolate(CompressorConfig &prev,
00152 CompressorConfig &next,
00153 int64_t prev_frame,
00154 int64_t next_frame,
00155 int64_t current_frame);
00156
00157 int total_points();
00158 void remove_point(int number);
00159 void optimize();
00160
00161 double get_y(int number);
00162 double get_x(int number);
00163
00164 double calculate_db(double x);
00165 int set_point(double x, double y);
00166 void dump();
00167
00168 int trigger;
00169 int input;
00170 enum
00171 {
00172 TRIGGER,
00173 MAX,
00174 SUM
00175 };
00176 double min_db;
00177 double reaction_len;
00178 double decay_len;
00179 double min_x, min_y;
00180 double max_x, max_y;
00181 int smoothing_only;
00182 ArrayList<compressor_point_t> levels;
00183 };
00184
00185 class CompressorEffect : public PluginAClient
00186 {
00187 public:
00188 CompressorEffect(PluginServer *server);
00189 ~CompressorEffect();
00190
00191 int is_multichannel();
00192 int is_realtime();
00193 void read_data(KeyFrame *keyframe);
00194 void save_data(KeyFrame *keyframe);
00195 int process_buffer(int64_t size,
00196 double **buffer,
00197 int64_t start_position,
00198 int sample_rate);
00199 double calculate_gain(double input);
00200
00201
00202 double calculate_output(double x);
00203
00204
00205 int load_defaults();
00206 int save_defaults();
00207 void reset();
00208 void update_gui();
00209 void delete_dsp();
00210
00211 PLUGIN_CLASS_MEMBERS(CompressorConfig, CompressorThread)
00212
00213
00214 double **input_buffer;
00215
00216 int64_t input_size;
00217
00218 int64_t input_allocated;
00219
00220 int64_t input_start;
00221
00222
00223 double next_target;
00224
00225 double previous_target;
00226
00227 int target_samples;
00228
00229 int target_current_sample;
00230
00231 double current_value;
00232
00233 ArrayList<compressor_point_t> levels;
00234 double min_x, min_y;
00235 double max_x, max_y;
00236 };
00237
00238
00239 #endif