00001 #ifndef PARAMETRIC_H
00002 #define PARAMETRIC_H
00003
00004
00005 #include "bchash.inc"
00006 #include "fourier.h"
00007 #include "guicast.h"
00008 #include "mutex.h"
00009 #include "pluginaclient.h"
00010 #include "vframe.inc"
00011
00012
00013
00014
00015
00016
00017 #define BANDS 3
00018 #define WINDOW_SIZE 16384
00019 #define MAXMAGNITUDE 15
00020
00021
00022
00023 class ParametricConfig;
00024 class ParametricThread;
00025 class ParametricFreq;
00026 class ParametricQuality;
00027 class ParametricMagnitude;
00028 class ParametricBandGUI;
00029 class ParametricWindow;
00030 class ParametricFFT;
00031 class ParametricEQ;
00032
00033
00034
00035
00036 class ParametricBand
00037 {
00038 public:
00039 ParametricBand();
00040
00041 int equivalent(ParametricBand &that);
00042 void copy_from(ParametricBand &that);
00043 void interpolate(ParametricBand &prev,
00044 ParametricBand &next,
00045 double prev_scale,
00046 double next_scale);
00047
00048 enum
00049 {
00050 NONE,
00051 LOWPASS,
00052 HIGHPASS,
00053 BANDPASS
00054 };
00055
00056 int freq;
00057 float quality;
00058 float magnitude;
00059 int mode;
00060 };
00061
00062
00063 class ParametricConfig
00064 {
00065 public:
00066 ParametricConfig();
00067
00068 int equivalent(ParametricConfig &that);
00069 void copy_from(ParametricConfig &that);
00070 void interpolate(ParametricConfig &prev,
00071 ParametricConfig &next,
00072 int64_t prev_frame,
00073 int64_t next_frame,
00074 int64_t current_frame);
00075
00076 ParametricBand band[BANDS];
00077 float wetness;
00078 };
00079
00080
00081
00082
00083 PLUGIN_THREAD_HEADER(ParametricEQ, ParametricThread, ParametricWindow)
00084
00085
00086 class ParametricFreq : public BC_QPot
00087 {
00088 public:
00089 ParametricFreq(ParametricEQ *plugin, int x, int y, int band);
00090
00091 int handle_event();
00092
00093 int band;
00094 ParametricEQ *plugin;
00095 };
00096
00097
00098 class ParametricQuality : public BC_FPot
00099 {
00100 public:
00101 ParametricQuality(ParametricEQ *plugin, int x, int y, int band);
00102
00103 int handle_event();
00104
00105 int band;
00106 ParametricEQ *plugin;
00107 };
00108
00109
00110 class ParametricMagnitude : public BC_FPot
00111 {
00112 public:
00113 ParametricMagnitude(ParametricEQ *plugin, int x, int y, int band);
00114
00115 int handle_event();
00116
00117 int band;
00118 ParametricEQ *plugin;
00119 };
00120
00121
00122
00123
00124 class ParametricMode : public BC_PopupMenu
00125 {
00126 public:
00127 ParametricMode(ParametricEQ *plugin, int x, int y, int band);
00128
00129 void create_objects();
00130 int handle_event();
00131 static int text_to_mode(char *text);
00132 static char* mode_to_text(int mode);
00133
00134 int band;
00135 ParametricEQ *plugin;
00136 };
00137
00138
00139
00140
00141
00142 class ParametricBandGUI
00143 {
00144 public:
00145 ParametricBandGUI(ParametricEQ *plugin,
00146 ParametricWindow *window,
00147 int x,
00148 int y,
00149 int band);
00150 ~ParametricBandGUI();
00151
00152 void create_objects();
00153 void update_gui();
00154
00155 int band;
00156 int x, y;
00157 ParametricEQ *plugin;
00158 ParametricWindow *window;
00159 ParametricFreq *freq;
00160 ParametricQuality *quality;
00161 ParametricMagnitude *magnitude;
00162 ParametricMode *mode;
00163 };
00164
00165
00166
00167 class ParametricWetness : public BC_FPot
00168 {
00169 public:
00170 ParametricWetness(ParametricEQ *plugin, int x, int y);
00171 int handle_event();
00172 ParametricEQ *plugin;
00173 };
00174
00175
00176 class ParametricWindow : public BC_Window
00177 {
00178 public:
00179 ParametricWindow(ParametricEQ *plugin, int x, int y);
00180 ~ParametricWindow();
00181
00182 void create_objects();
00183 int close_event();
00184 void update_gui();
00185 void update_canvas();
00186
00187 BC_SubWindow *canvas;
00188 ParametricEQ *plugin;
00189 ParametricBandGUI* bands[BANDS];
00190 ParametricWetness *wetness;
00191 };
00192
00193 class ParametricFFT : public CrossfadeFFT
00194 {
00195 public:
00196 ParametricFFT(ParametricEQ *plugin);
00197 ~ParametricFFT();
00198
00199 int signal_process();
00200 int read_samples(int64_t output_sample,
00201 int samples,
00202 double *buffer);
00203
00204 ParametricEQ *plugin;
00205 };
00206
00207
00208 class ParametricEQ : public PluginAClient
00209 {
00210 public:
00211 ParametricEQ(PluginServer *server);
00212 ~ParametricEQ();
00213
00214 int is_realtime();
00215 void read_data(KeyFrame *keyframe);
00216 void save_data(KeyFrame *keyframe);
00217 int process_buffer(int64_t size,
00218 double *buffer,
00219 int64_t start_position,
00220 int sample_rate);
00221
00222 int load_defaults();
00223 int save_defaults();
00224 void reset();
00225 void reconfigure();
00226 void update_gui();
00227
00228 double calculate_envelope();
00229 double gauss(double sigma, double a, double x);
00230
00231 double envelope[WINDOW_SIZE / 2];
00232 int need_reconfigure;
00233 PLUGIN_CLASS_MEMBERS(ParametricConfig, ParametricThread)
00234 ParametricFFT *fft;
00235 };
00236
00237
00238
00239 #endif