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, int x, int y);
81 CompressorEffect *plugin;
84 class CompressorX : public BC_TumbleTextBox
87 CompressorX(CompressorEffect *plugin, CompressorWindow *window,
90 CompressorEffect *plugin;
93 class CompressorY : public BC_TumbleTextBox
96 CompressorY(CompressorEffect *plugin, CompressorWindow *window,
99 CompressorEffect *plugin;
102 class CompressorTrigger : public BC_TumbleTextBox
105 CompressorTrigger(CompressorEffect *plugin, CompressorWindow *window,
108 CompressorEffect *plugin;
111 class CompressorSmooth : public BC_CheckBox
114 CompressorSmooth(CompressorEffect *plugin, int x, int y);
116 CompressorEffect *plugin;
119 class CompressorInput : public BC_PopupMenu
122 CompressorInput(CompressorEffect *plugin, int x, int y);
123 void create_objects();
125 static const char* value_to_text(int value);
126 static int text_to_value(char *text);
127 CompressorEffect *plugin;
132 class CompressorWindow : public PluginClientWindow
135 CompressorWindow(CompressorEffect *plugin);
138 void create_objects();
140 void update_textboxes();
142 void update_meter(CompressorGainFrame *gain_frame);
143 int resize_event(int w, int h);
145 CompressorCanvas *canvas;
146 CompressorLookAhead *readahead;
147 CompressorAttack *attack;
148 CompressorClear *clear;
151 CompressorTrigger *trigger;
152 CompressorRelease *release;
153 CompressorSmooth *smooth;
154 CompressorInput *input;
156 BC_Meter *gain_change;
157 CompressorEffect *plugin;
162 class CompressorConfig : public CompressorConfigBase
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);
174 class CompressorEffect : public PluginAClient
177 CompressorEffect(PluginServer *server);
180 int is_multichannel();
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);
192 PLUGIN_CLASS_MEMBERS(CompressorConfig)
194 // Input data + read ahead for each channel
195 Samples **input_buffer;
197 // Number of samples in the input buffer
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.
203 int64_t last_position;
204 int need_reconfigure;
207 CompressorEngine *engine;
209 // Temporaries for linear transfer
210 ArrayList<compressor_point_t> levels;
211 // double min_x, min_y;
212 // double max_x, max_y;