r864: Merge 2.1:
[cinelerra_cv.git] / plugins / compressor / compressor.h
blob6b51f2da0de8728ec76c08104cde5b98c9297b11
1 #ifndef COMPRESSOR_H
2 #define COMPRESSOR_H
6 #include "bchash.inc"
7 #include "guicast.h"
8 #include "mutex.h"
9 #include "pluginaclient.h"
10 #include "vframe.inc"
12 class CompressorEffect;
18 class CompressorCanvas : public BC_SubWindow
20 public:
21 CompressorCanvas(CompressorEffect *plugin, int x, int y, int w, int h);
22 int button_press_event();
23 int button_release_event();
24 int cursor_motion_event();
27 enum
29 NONE,
30 DRAG
33 int current_point;
34 int current_operation;
35 CompressorEffect *plugin;
39 class CompressorReaction : public BC_TextBox
41 public:
42 CompressorReaction(CompressorEffect *plugin, int x, int y);
43 int handle_event();
44 int button_press_event();
45 CompressorEffect *plugin;
48 class CompressorClear : public BC_GenericButton
50 public:
51 CompressorClear(CompressorEffect *plugin, int x, int y);
52 int handle_event();
53 CompressorEffect *plugin;
56 class CompressorX : public BC_TextBox
58 public:
59 CompressorX(CompressorEffect *plugin, int x, int y);
60 int handle_event();
61 CompressorEffect *plugin;
64 class CompressorY : public BC_TextBox
66 public:
67 CompressorY(CompressorEffect *plugin, int x, int y);
68 int handle_event();
69 CompressorEffect *plugin;
72 class CompressorTrigger : public BC_TextBox
74 public:
75 CompressorTrigger(CompressorEffect *plugin, int x, int y);
76 int handle_event();
77 int button_press_event();
78 CompressorEffect *plugin;
81 class CompressorDecay : public BC_TextBox
83 public:
84 CompressorDecay(CompressorEffect *plugin, int x, int y);
85 int handle_event();
86 int button_press_event();
87 CompressorEffect *plugin;
90 class CompressorSmooth : public BC_CheckBox
92 public:
93 CompressorSmooth(CompressorEffect *plugin, int x, int y);
94 int handle_event();
95 CompressorEffect *plugin;
98 class CompressorInput : public BC_PopupMenu
100 public:
101 CompressorInput(CompressorEffect *plugin, int x, int y);
102 void create_objects();
103 int handle_event();
104 static char* value_to_text(int value);
105 static int text_to_value(char *text);
106 CompressorEffect *plugin;
111 class CompressorWindow : public BC_Window
113 public:
114 CompressorWindow(CompressorEffect *plugin, int x, int y);
115 void create_objects();
116 void update();
117 void update_textboxes();
118 void update_canvas();
119 int close_event();
120 void draw_scales();
123 CompressorCanvas *canvas;
124 CompressorReaction *reaction;
125 CompressorClear *clear;
126 CompressorX *x_text;
127 CompressorY *y_text;
128 CompressorTrigger *trigger;
129 CompressorDecay *decay;
130 CompressorSmooth *smooth;
131 CompressorInput *input;
132 CompressorEffect *plugin;
135 PLUGIN_THREAD_HEADER(CompressorEffect, CompressorThread, CompressorWindow)
138 typedef struct
140 // DB from min_db - 0
141 double x, y;
142 } compressor_point_t;
144 class CompressorConfig
146 public:
147 CompressorConfig();
149 void copy_from(CompressorConfig &that);
150 int equivalent(CompressorConfig &that);
151 void interpolate(CompressorConfig &prev,
152 CompressorConfig &next,
153 int64_t prev_frame,
154 int64_t next_frame,
155 int64_t current_frame);
157 int total_points();
158 void remove_point(int number);
159 void optimize();
160 // Return values of a specific point
161 double get_y(int number);
162 double get_x(int number);
163 // Returns db output from db input
164 double calculate_db(double x);
165 int set_point(double x, double y);
166 void dump();
168 int trigger;
169 int input;
170 enum
172 TRIGGER,
173 MAX,
176 double min_db;
177 double reaction_len;
178 double decay_len;
179 double min_x, min_y;
180 double max_x, max_y;
181 int smoothing_only;
182 ArrayList<compressor_point_t> levels;
185 class CompressorEffect : public PluginAClient
187 public:
188 CompressorEffect(PluginServer *server);
189 ~CompressorEffect();
191 int is_multichannel();
192 int is_realtime();
193 void read_data(KeyFrame *keyframe);
194 void save_data(KeyFrame *keyframe);
195 int process_buffer(int64_t size,
196 double **buffer,
197 int64_t start_position,
198 int sample_rate);
199 double calculate_gain(double input);
201 // Calculate linear output from linear input
202 double calculate_output(double x);
205 int load_defaults();
206 int save_defaults();
207 void reset();
208 void update_gui();
209 void delete_dsp();
211 PLUGIN_CLASS_MEMBERS(CompressorConfig, CompressorThread)
213 // The raw input data for each channel with readahead
214 double **input_buffer;
215 // Number of samples in the input buffer
216 int64_t input_size;
217 // Number of samples allocated in the input buffer
218 int64_t input_allocated;
219 // Starting sample of input buffer relative to project in requested rate.
220 int64_t input_start;
222 // ending input value of smoothed input
223 double next_target;
224 // starting input value of smoothed input
225 double previous_target;
226 // samples between previous and next target value for readahead
227 int target_samples;
228 // current sample from 0 to target_samples
229 int target_current_sample;
230 // current smoothed input value
231 double current_value;
232 // Temporaries for linear transfer
233 ArrayList<compressor_point_t> levels;
234 double min_x, min_y;
235 double max_x, max_y;
239 #endif