6 #include "defaults.inc"
9 #include "pluginaclient.h"
13 typedef enum { DECOMP
, RECON
} wavetype
;
15 class DenoiseLevel
: public BC_FPot
18 DenoiseLevel(DenoiseEffect
*plugin
, int x
, int y
);
20 DenoiseEffect
*plugin
;
23 class DenoiseWindow
: public BC_Window
26 DenoiseWindow(DenoiseEffect
*plugin
, int x
, int y
);
27 void create_objects();
31 DenoiseEffect
*plugin
;
34 PLUGIN_THREAD_HEADER(DenoiseEffect
, DenoiseThread
, DenoiseWindow
)
40 void copy_from(DenoiseConfig
&that
);
41 int equivalent(DenoiseConfig
&that
);
42 void interpolate(DenoiseConfig
&prev
,
46 int64_t current_frame
);
53 Tree(int input_length
, int levels
);
64 WaveletCoeffs(double alpha
, double beta
);
74 WaveletFilters(WaveletCoeffs
*wave_coeffs
, wavetype transform
);
81 class DenoiseEffect
: public PluginAClient
84 DenoiseEffect(PluginServer
*server
);
88 void read_data(KeyFrame
*keyframe
);
89 void save_data(KeyFrame
*keyframe
);
90 int process_realtime(int64_t size
, double *input_ptr
, double *output_ptr
);
101 void process_window();
102 double dot_product(double *data
, double *filter
, char filtlen
);
103 int convolve_dec_2(double *input_sequence
,
107 double *output_sequence
);
108 int64_t decompose_branches(double *in_data
,
110 WaveletFilters
*decomp_filter
,
113 int wavelet_decomposition(double *in_data
,
116 int tree_copy(double **output
,
120 int threshold(int window_size
, double gammas
, int levels
);
121 double dot_product_even(double *data
, double *filter
, int filtlen
);
122 double dot_product_odd(double *data
, double *filter
, int filtlen
);
123 int convolve_int_2(double *input_sequence
,
128 double *output_sequence
);
129 int64_t reconstruct_branches(double *in_low
,
132 WaveletFilters
*recon_filter
,
134 int wavelet_reconstruction(double **in_data
,
139 PLUGIN_CLASS_MEMBERS(DenoiseConfig
, DenoiseThread
)
141 // buffer for storing fragments until a complete window size is armed
142 double *input_buffer
;
144 int64_t input_allocation
;
145 // buffer for storing fragments until a fragment is ready to be read
146 double *output_buffer
;
148 int64_t output_allocation
;
151 // buffer for capturing output of a single iteration
152 double *dsp_iteration
;
153 Tree
*ex_coeff_d
, *ex_coeff_r
, *ex_coeff_rn
;
154 WaveletCoeffs
*wave_coeff_d
, *wave_coeff_r
;
155 WaveletFilters
*decomp_filter
, *recon_filter
;
156 // scaling factor for transferring from input_buffer
158 // power converted to scaling factor
161 // depends on the type of music
163 // higher number reduces aliasing due to a high noise_level
164 // also increases high end
171 // higher number kills more noise at the expense of more aliasing