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"
34 typedef enum { DECOMP, RECON } wavetype;
36 class DenoiseLevel : public BC_FPot
39 DenoiseLevel(DenoiseEffect *plugin, int x, int y);
41 DenoiseEffect *plugin;
44 class DenoiseWindow : public PluginClientWindow
47 DenoiseWindow(DenoiseEffect *plugin);
48 void create_objects();
51 DenoiseEffect *plugin;
59 void copy_from(DenoiseConfig &that);
60 int equivalent(DenoiseConfig &that);
61 void interpolate(DenoiseConfig &prev,
65 int64_t current_frame);
72 Tree(int input_length, int levels);
83 WaveletCoeffs(double alpha, double beta);
93 WaveletFilters(WaveletCoeffs *wave_coeffs, wavetype transform);
100 class DenoiseEffect : public PluginAClient
103 DenoiseEffect(PluginServer *server);
107 void read_data(KeyFrame *keyframe);
108 void save_data(KeyFrame *keyframe);
109 int process_realtime(int64_t size, Samples *input_ptr, Samples *output_ptr);
118 void process_window();
119 double dot_product(double *data, double *filter, char filtlen);
120 int convolve_dec_2(double *input_sequence,
124 double *output_sequence);
125 int64_t decompose_branches(double *in_data,
127 WaveletFilters *decomp_filter,
130 int wavelet_decomposition(double *in_data,
133 int tree_copy(double **output,
137 int threshold(int window_size, double gammas, int levels);
138 double dot_product_even(double *data, double *filter, int filtlen);
139 double dot_product_odd(double *data, double *filter, int filtlen);
140 int convolve_int_2(double *input_sequence,
145 double *output_sequence);
146 int64_t reconstruct_branches(double *in_low,
149 WaveletFilters *recon_filter,
151 int wavelet_reconstruction(double **in_data,
156 PLUGIN_CLASS_MEMBERS(DenoiseConfig)
158 // buffer for storing fragments until a complete window size is armed
159 double *input_buffer;
161 int64_t input_allocation;
162 // buffer for storing fragments until a fragment is ready to be read
163 double *output_buffer;
165 int64_t output_allocation;
168 // buffer for capturing output of a single iteration
169 double *dsp_iteration;
170 Tree *ex_coeff_d, *ex_coeff_r, *ex_coeff_rn;
171 WaveletCoeffs *wave_coeff_d, *wave_coeff_r;
172 WaveletFilters *decomp_filter, *recon_filter;
173 // scaling factor for transferring from input_buffer
175 // power converted to scaling factor
178 // depends on the type of music
180 // higher number reduces aliasing due to a high noise_level
181 // also increases high end
188 // higher number kills more noise at the expense of more aliasing