4 * Copyright (C) 2008 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
30 #include "pluginaclient.h"
31 #include "samples.inc"
34 class CompressorEffect;
40 class CompressorCanvas : public BC_SubWindow
43 CompressorCanvas(CompressorEffect *plugin, int x, int y, int w, int h);
44 int button_press_event();
45 int button_release_event();
46 int cursor_motion_event();
56 int current_operation;
57 CompressorEffect *plugin;
61 class CompressorReaction : public BC_TextBox
64 CompressorReaction(CompressorEffect *plugin, int x, int y);
66 int button_press_event();
67 CompressorEffect *plugin;
70 class CompressorClear : public BC_GenericButton
73 CompressorClear(CompressorEffect *plugin, int x, int y);
75 CompressorEffect *plugin;
78 class CompressorX : public BC_TextBox
81 CompressorX(CompressorEffect *plugin, int x, int y);
83 CompressorEffect *plugin;
86 class CompressorY : public BC_TextBox
89 CompressorY(CompressorEffect *plugin, int x, int y);
91 CompressorEffect *plugin;
94 class CompressorTrigger : public BC_TextBox
97 CompressorTrigger(CompressorEffect *plugin, int x, int y);
99 int button_press_event();
100 CompressorEffect *plugin;
103 class CompressorDecay : public BC_TextBox
106 CompressorDecay(CompressorEffect *plugin, int x, int y);
108 int button_press_event();
109 CompressorEffect *plugin;
112 class CompressorSmooth : public BC_CheckBox
115 CompressorSmooth(CompressorEffect *plugin, int x, int y);
117 CompressorEffect *plugin;
120 class CompressorInput : public BC_PopupMenu
123 CompressorInput(CompressorEffect *plugin, int x, int y);
124 void create_objects();
126 static const char* value_to_text(int value);
127 static int text_to_value(char *text);
128 CompressorEffect *plugin;
133 class CompressorWindow : public PluginClientWindow
136 CompressorWindow(CompressorEffect *plugin);
137 void create_objects();
139 void update_textboxes();
140 void update_canvas();
142 int resize_event(int w, int h);
144 CompressorCanvas *canvas;
145 CompressorReaction *reaction;
146 CompressorClear *clear;
149 CompressorTrigger *trigger;
150 CompressorDecay *decay;
151 CompressorSmooth *smooth;
152 CompressorInput *input;
153 CompressorEffect *plugin;
160 // DB from min_db - 0
162 } compressor_point_t;
164 class CompressorConfig
169 void copy_from(CompressorConfig &that);
170 int equivalent(CompressorConfig &that);
171 void interpolate(CompressorConfig &prev,
172 CompressorConfig &next,
175 int64_t current_frame);
178 void remove_point(int number);
180 // Return values of a specific point
181 double get_y(int number);
182 double get_x(int number);
183 // Returns db output from db input
184 double calculate_db(double x);
185 int set_point(double x, double y);
202 ArrayList<compressor_point_t> levels;
205 class CompressorEffect : public PluginAClient
208 CompressorEffect(PluginServer *server);
211 int is_multichannel();
213 void read_data(KeyFrame *keyframe);
214 void save_data(KeyFrame *keyframe);
215 int process_buffer(int64_t size,
217 int64_t start_position,
219 double calculate_gain(double input);
221 // Calculate linear output from linear input
222 double calculate_output(double x);
229 PLUGIN_CLASS_MEMBERS(CompressorConfig)
231 // The raw input data for each channel with readahead
232 Samples **input_buffer;
233 // Number of samples in the input buffer
235 // Number of samples allocated in the input buffer
236 int64_t input_allocated;
237 // Starting sample of input buffer relative to project in requested rate.
240 // ending input value of smoothed input
242 // starting input value of smoothed input
243 double previous_target;
244 // samples between previous and next target value for readahead
246 // current sample from 0 to target_samples
247 int target_current_sample;
248 // current smoothed input value
249 double current_value;
250 // Temporaries for linear transfer
251 ArrayList<compressor_point_t> levels;