r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / plugins / compressor / compressor.h
bloba20158ba556cc7511b8e01df97b8df43ff4339b8
1 #ifndef COMPRESSOR_H
2 #define COMPRESSOR_H
6 #include "defaults.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 CompressorPreview : public BC_TextBox
41 public:
42 CompressorPreview(CompressorEffect *plugin, int x, int y);
43 int handle_event();
44 CompressorEffect *plugin;
47 class CompressorReaction : public BC_TextBox
49 public:
50 CompressorReaction(CompressorEffect *plugin, int x, int y);
51 int handle_event();
52 CompressorEffect *plugin;
55 class CompressorClear : public BC_GenericButton
57 public:
58 CompressorClear(CompressorEffect *plugin, int x, int y);
59 int handle_event();
60 CompressorEffect *plugin;
63 class CompressorX : public BC_TextBox
65 public:
66 CompressorX(CompressorEffect *plugin, int x, int y);
67 int handle_event();
68 CompressorEffect *plugin;
71 class CompressorY : public BC_TextBox
73 public:
74 CompressorY(CompressorEffect *plugin, int x, int y);
75 int handle_event();
76 CompressorEffect *plugin;
79 class CompressorTrigger : public BC_TextBox
81 public:
82 CompressorTrigger(CompressorEffect *plugin, int x, int y);
83 int handle_event();
84 CompressorEffect *plugin;
91 class CompressorWindow : public BC_Window
93 public:
94 CompressorWindow(CompressorEffect *plugin, int x, int y);
95 void create_objects();
96 void update();
97 void update_textboxes();
98 void update_canvas();
99 int close_event();
100 void draw_scales();
103 CompressorCanvas *canvas;
104 CompressorPreview *preview;
105 CompressorReaction *reaction;
106 CompressorClear *clear;
107 CompressorX *x_text;
108 CompressorY *y_text;
109 CompressorTrigger *trigger;
110 CompressorEffect *plugin;
113 PLUGIN_THREAD_HEADER(CompressorEffect, CompressorThread, CompressorWindow)
116 typedef struct
118 // DB from min_db - 0
119 double x, y;
120 } compressor_point_t;
122 class CompressorConfig
124 public:
125 CompressorConfig();
127 void copy_from(CompressorConfig &that);
128 int equivalent(CompressorConfig &that);
129 void interpolate(CompressorConfig &prev,
130 CompressorConfig &next,
131 int64_t prev_frame,
132 int64_t next_frame,
133 int64_t current_frame);
135 int total_points();
136 void remove_point(int number);
137 void optimize();
138 // Return values of a specific point
139 double get_y(int number);
140 double get_x(int number);
141 // Returns db output given linear input
142 double calculate_db(double x);
143 int set_point(double x, double y);
144 void dump();
146 int trigger;
147 double min_db;
148 double preview_len;
149 double reaction_len;
150 double min_x, min_y;
151 double max_x, max_y;
152 ArrayList<compressor_point_t> levels;
155 class CompressorEffect : public PluginAClient
157 public:
158 CompressorEffect(PluginServer *server);
159 ~CompressorEffect();
161 int is_multichannel();
162 int is_realtime();
163 void read_data(KeyFrame *keyframe);
164 void save_data(KeyFrame *keyframe);
165 int process_realtime(int64_t size, double **input_ptr, double **output_ptr);
170 int load_defaults();
171 int save_defaults();
172 void reset();
173 void update_gui();
174 void delete_dsp();
176 PLUGIN_CLASS_MEMBERS(CompressorConfig, CompressorThread)
178 double **input_buffer;
179 int64_t input_size;
180 int64_t input_allocated;
181 double *reaction_buffer;
182 int64_t reaction_allocated;
183 int64_t reaction_position;
184 double current_coef;
185 double previous_slope;
186 double previous_intercept;
187 double previous_max;
188 double previous_coef;
189 int max_counter;
190 int total_samples;
192 // Same coefs are applied to all channels
193 double *coefs;
194 int64_t coefs_allocated;
195 int64_t last_peak_age;
196 double last_peak;
200 #endif