4 * Copyright (C) 2008-2019 Adam Williams <broadcast at earthling dot net>
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.
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.
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
28 #include "compressortools.h"
31 #include "pluginaclient.h"
32 #include "samples.inc"
35 class CompressorEffect;
36 class CompressorWindow;
39 class CompressorCanvas : public CompressorCanvasBase
42 CompressorCanvas(CompressorEffect *plugin, CompressorWindow *window,
43 int x, int y, int w, int h);
48 class CompressorLookAhead : public BC_TumbleTextBox
51 CompressorLookAhead(CompressorEffect *plugin, CompressorWindow *window,
54 CompressorEffect *plugin;
57 class CompressorAttack : public BC_TumbleTextBox
60 CompressorAttack(CompressorEffect *plugin, CompressorWindow *window,
63 CompressorEffect *plugin;
66 class CompressorRelease : public BC_TumbleTextBox
69 CompressorRelease(CompressorEffect *plugin, CompressorWindow *window,
72 CompressorEffect *plugin;
76 class CompressorClear : public BC_GenericButton
79 CompressorClear(CompressorEffect *plugin, CompressorWindow *window,
82 CompressorEffect *plugin;
83 CompressorWindow *window;
86 class CompressorReset : public BC_GenericButton
89 CompressorReset(CompressorEffect *plugin,
90 CompressorWindow *window, int x, int y);
92 CompressorEffect *plugin;
93 CompressorWindow *window;
96 class CompressorMkupGain : public BC_FPot
99 CompressorMkupGain(CompressorEffect *plugin, CompressorWindow *window,
100 int x, int y, double *output, double min, double max);
102 CompressorWindow *window;
103 CompressorEffect *plugin;
107 class CompressorX : public BC_TumbleTextBox
110 CompressorX(CompressorEffect *plugin, CompressorWindow *window,
113 CompressorEffect *plugin;
114 CompressorWindow *window;
117 class CompressorY : public BC_TumbleTextBox
120 CompressorY(CompressorEffect *plugin, CompressorWindow *window,
123 CompressorEffect *plugin;
124 CompressorWindow *window;
127 class CompressorTrigger : public BC_TumbleTextBox
130 CompressorTrigger(CompressorEffect *plugin, CompressorWindow *window,
133 CompressorEffect *plugin;
136 class CompressorSmooth : public BC_CheckBox
139 CompressorSmooth(CompressorEffect *plugin, int x, int y);
141 CompressorEffect *plugin;
144 class CompressorInput : public BC_PopupMenu
147 CompressorInput(CompressorEffect *plugin, int x, int y);
148 void create_objects();
150 static const char* value_to_text(int value);
151 static int text_to_value(char *text);
152 CompressorEffect *plugin;
157 class CompressorWindow : public PluginClientWindow
160 CompressorWindow(CompressorEffect *plugin);
163 void create_objects();
165 void update_textboxes();
167 void update_meter(CompressorGainFrame *gain_frame);
168 int resize_event(int w, int h);
170 CompressorCanvas *canvas;
171 CompressorLookAhead *readahead;
172 CompressorAttack *attack;
173 CompressorClear *clear;
174 CompressorReset *reset;
175 CompressorMkupGain *mkup_gain;
178 CompressorTrigger *trigger;
179 CompressorRelease *release;
180 CompressorSmooth *smooth;
181 CompressorInput *input;
183 BC_Meter *gain_change;
184 CompressorEffect *plugin;
189 class CompressorConfig : public CompressorConfigBase
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);
201 class CompressorEffect : public PluginAClient
204 CompressorEffect(PluginServer *server);
207 int is_multichannel();
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);
219 PLUGIN_CLASS_MEMBERS(CompressorConfig)
221 // Input data + read ahead for each channel
222 Samples **input_buffer;
224 // Number of samples in the input buffer
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.
230 int64_t last_position;
231 int need_reconfigure;
234 CompressorEngine *engine;
236 // Temporaries for linear transfer
237 ArrayList<compressor_point_t> levels;
238 // double min_x, min_y;
239 // double max_x, max_y;