new/reworked audio plugins ported from hv72 compressor/multi/reverb, glyph workaround...
[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, int x, int y);
80         int handle_event();
81         CompressorEffect *plugin;
82 };
83
84 class CompressorX : public BC_TumbleTextBox
85 {
86 public:
87         CompressorX(CompressorEffect *plugin, CompressorWindow *window,
88                         int x, int y);
89         int handle_event();
90         CompressorEffect *plugin;
91 };
92
93 class CompressorY : public BC_TumbleTextBox
94 {
95 public:
96         CompressorY(CompressorEffect *plugin, CompressorWindow *window,
97                         int x, int y);
98         int handle_event();
99         CompressorEffect *plugin;
100 };
101
102 class CompressorTrigger : public BC_TumbleTextBox
103 {
104 public:
105         CompressorTrigger(CompressorEffect *plugin, CompressorWindow *window,
106                         int x, int y);
107         int handle_event();
108         CompressorEffect *plugin;
109 };
110
111 class CompressorSmooth : public BC_CheckBox
112 {
113 public:
114         CompressorSmooth(CompressorEffect *plugin, int x, int y);
115         int handle_event();
116         CompressorEffect *plugin;
117 };
118
119 class CompressorInput : public BC_PopupMenu
120 {
121 public:
122         CompressorInput(CompressorEffect *plugin, int x, int y);
123         void create_objects();
124         int handle_event();
125         static const char* value_to_text(int value);
126         static int text_to_value(char *text);
127         CompressorEffect *plugin;
128 };
129
130
131
132 class CompressorWindow : public PluginClientWindow
133 {
134 public:
135         CompressorWindow(CompressorEffect *plugin);
136         ~CompressorWindow();
137
138         void create_objects();
139         void update();
140         void update_textboxes();
141         void draw_scales();
142         void update_meter(CompressorGainFrame *gain_frame);
143         int resize_event(int w, int h);
144
145         CompressorCanvas *canvas;
146         CompressorLookAhead *readahead;
147         CompressorAttack *attack;
148         CompressorClear *clear;
149         CompressorX *x_text;
150         CompressorY *y_text;
151         CompressorTrigger *trigger;
152         CompressorRelease *release;
153         CompressorSmooth *smooth;
154         CompressorInput *input;
155         BC_Meter *in;
156         BC_Meter *gain_change;
157         CompressorEffect *plugin;
158 };
159
160
161
162 class CompressorConfig : public CompressorConfigBase
163 {
164 public:
165         CompressorConfig();
166
167         void copy_from(CompressorConfig &that);
168         int equivalent(CompressorConfig &that);
169         void interpolate(CompressorConfig &prev, CompressorConfig &next,
170                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
171 };
172
173
174 class CompressorEffect : public PluginAClient
175 {
176 public:
177         CompressorEffect(PluginServer *server);
178         ~CompressorEffect();
179
180         int is_multichannel();
181         int is_realtime();
182         void read_data(KeyFrame *keyframe);
183         void save_data(KeyFrame *keyframe);
184         int process_buffer(int64_t size, Samples **buffer,
185                         int64_t start_position, int sample_rate);
186         void allocate_input(int size);
187
188
189         void update_gui();
190         void render_stop();
191
192         PLUGIN_CLASS_MEMBERS(CompressorConfig)
193
194 // Input data + read ahead for each channel
195         Samples **input_buffer;
196
197 // Number of samples in the input buffer
198         int64_t input_size;
199 // Number of samples allocated in the input buffer
200         int64_t input_allocated;
201 // Starting sample of input buffer relative to project in requested rate.
202         int64_t input_start;
203         int64_t last_position;
204         int need_reconfigure;
205
206
207         CompressorEngine *engine;
208
209 // Temporaries for linear transfer
210         ArrayList<compressor_point_t> levels;
211 //      double min_x, min_y;
212 //      double max_x, max_y;
213 };
214
215
216 #endif