Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / compressor / compressor.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008-2019 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef COMPRESSOR_H
23 #define COMPRESSOR_H
24
25
26
27 #include "bchash.inc"
28 #include "compressortools.h"
29 #include "guicast.h"
30 #include "mutex.h"
31 #include "pluginaclient.h"
32 #include "samples.inc"
33 #include "vframe.inc"
34
35 class CompressorEffect;
36 class CompressorWindow;
37
38
39 class CompressorCanvas : public CompressorCanvasBase
40 {
41 public:
42         CompressorCanvas(CompressorEffect *plugin, CompressorWindow *window,
43                         int x, int y, int w, int h);
44         void update_window();
45 };
46
47
48 class CompressorLookAhead : public BC_TumbleTextBox
49 {
50 public:
51         CompressorLookAhead(CompressorEffect *plugin, CompressorWindow *window,
52                         int x, int y);
53         int handle_event();
54         CompressorEffect *plugin;
55 };
56
57 class CompressorAttack : public BC_TumbleTextBox
58 {
59 public:
60         CompressorAttack(CompressorEffect *plugin, CompressorWindow *window,
61                         int x, int y);
62         int handle_event();
63         CompressorEffect *plugin;
64 };
65
66 class CompressorRelease : public BC_TumbleTextBox
67 {
68 public:
69         CompressorRelease(CompressorEffect *plugin, CompressorWindow *window,
70                         int x, int y);
71         int handle_event();
72         CompressorEffect *plugin;
73 };
74
75
76 class CompressorClear : public BC_GenericButton
77 {
78 public:
79         CompressorClear(CompressorEffect *plugin, CompressorWindow *window,
80                         int x, int y);
81         int handle_event();
82         CompressorEffect *plugin;
83         CompressorWindow *window;
84 };
85
86 class CompressorReset : public BC_GenericButton
87 {
88 public:
89         CompressorReset(CompressorEffect *plugin,
90                         CompressorWindow *window, int x, int y);
91         int handle_event();
92         CompressorEffect *plugin;
93         CompressorWindow *window;
94 };
95
96 class CompressorMkupGain : public BC_FPot
97 {
98 public:
99         CompressorMkupGain(CompressorEffect *plugin, CompressorWindow *window,
100                         int x, int y, double *output, double min, double max);
101         int handle_event();
102         CompressorWindow *window;
103         CompressorEffect *plugin;
104         double *output;
105 };
106
107 class CompressorX : public BC_TumbleTextBox
108 {
109 public:
110         CompressorX(CompressorEffect *plugin, CompressorWindow *window,
111                         int x, int y);
112         int handle_event();
113         CompressorEffect *plugin;
114         CompressorWindow *window;
115 };
116
117 class CompressorY : public BC_TumbleTextBox
118 {
119 public:
120         CompressorY(CompressorEffect *plugin, CompressorWindow *window,
121                         int x, int y);
122         int handle_event();
123         CompressorEffect *plugin;
124         CompressorWindow *window;
125 };
126
127 class CompressorTrigger : public BC_TumbleTextBox
128 {
129 public:
130         CompressorTrigger(CompressorEffect *plugin, CompressorWindow *window,
131                         int x, int y);
132         int handle_event();
133         CompressorEffect *plugin;
134 };
135
136 class CompressorSmooth : public BC_CheckBox
137 {
138 public:
139         CompressorSmooth(CompressorEffect *plugin, int x, int y);
140         int handle_event();
141         CompressorEffect *plugin;
142 };
143
144 class CompressorInput : public BC_PopupMenu
145 {
146 public:
147         CompressorInput(CompressorEffect *plugin, int x, int y);
148         void create_objects();
149         int handle_event();
150         static const char* value_to_text(int value);
151         static int text_to_value(char *text);
152         CompressorEffect *plugin;
153 };
154
155
156
157 class CompressorWindow : public PluginClientWindow
158 {
159 public:
160         CompressorWindow(CompressorEffect *plugin);
161         ~CompressorWindow();
162
163         void create_objects();
164         void update();
165         void update_textboxes();
166         void draw_scales();
167         void update_meter(CompressorGainFrame *gain_frame);
168         int resize_event(int w, int h);
169
170         CompressorCanvas *canvas;
171         CompressorLookAhead *readahead;
172         CompressorAttack *attack;
173         CompressorClear *clear;
174         CompressorReset *reset;
175         CompressorMkupGain *mkup_gain;
176         CompressorX *x_text;
177         CompressorY *y_text;
178         CompressorTrigger *trigger;
179         CompressorRelease *release;
180         CompressorSmooth *smooth;
181         CompressorInput *input;
182         BC_Meter *in;
183         BC_Meter *gain_change;
184         CompressorEffect *plugin;
185 };
186
187
188
189 class CompressorConfig : public CompressorConfigBase
190 {
191 public:
192         CompressorConfig();
193
194         void copy_from(CompressorConfig &that);
195         int equivalent(CompressorConfig &that);
196         void interpolate(CompressorConfig &prev, CompressorConfig &next,
197                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
198 };
199
200
201 class CompressorEffect : public PluginAClient
202 {
203 public:
204         CompressorEffect(PluginServer *server);
205         ~CompressorEffect();
206
207         int is_multichannel();
208         int is_realtime();
209         void read_data(KeyFrame *keyframe);
210         void save_data(KeyFrame *keyframe);
211         int process_buffer(int64_t size, Samples **buffer,
212                         int64_t start_position, int sample_rate);
213         void allocate_input(int size);
214
215
216         void update_gui();
217         void render_stop();
218
219         PLUGIN_CLASS_MEMBERS(CompressorConfig)
220
221 // Input data + read ahead for each channel
222         Samples **input_buffer;
223
224 // Number of samples in the input buffer
225         int64_t input_size;
226 // Number of samples allocated in the input buffer
227         int64_t input_allocated;
228 // Starting sample of input buffer relative to project in requested rate.
229         int64_t input_start;
230         int64_t last_position;
231         int need_reconfigure;
232
233
234         CompressorEngine *engine;
235
236 // Temporaries for linear transfer
237         ArrayList<compressor_point_t> levels;
238 //      double min_x, min_y;
239 //      double max_x, max_y;
240 };
241
242
243 #endif