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
25 #include "compressortools.h"
28 #include "pluginaclient.h"
29 #include "samples.inc"
32 class ComprMultiEffect;
35 //#define LOG_CROSSOVER
36 #define DRAW_AFTER_BANDPASS
40 class ComprMultiConfig : public CompressorConfigBase
45 void copy_from(ComprMultiConfig &that);
46 int equivalent(ComprMultiConfig &that);
47 void interpolate(ComprMultiConfig &prev, ComprMultiConfig &next,
48 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
53 class ComprMultiFFT :public CrossfadeFFT
56 ComprMultiFFT(ComprMultiEffect *plugin, int channel);
59 int signal_process(int band);
60 int post_process(int band);
61 int read_samples(int64_t output_sample, int samples, Samples *buffer);
63 ComprMultiEffect *plugin;
65 CompressorFreqFrame *frame;
68 // processing state of a single band
72 BandState(ComprMultiEffect *plugin, int band);
78 // calculate the envelope for only this band
79 void calculate_envelope();
80 // void process_readbehind(int size,
81 // int reaction_samples, int decay_samples, int trigger);
82 // void process_readahead(int size, int preview_samples,
83 // int reaction_samples, int decay_samples, int trigger);
84 void allocate_filtered(int new_size);
86 // bandpass filter for this band
88 int envelope_allocated;
89 // The input for all channels with filtering by this band
90 Samples **filtered_buffer;
91 // ending input value of smoothed input
93 // starting input value of smoothed input
94 double previous_target;
95 // samples between previous and next target value for readahead
97 // current sample from 0 to target_samples
98 int target_current_sample;
99 // current smoothed input value
100 double current_value;
101 // Temporaries for linear transfer
102 ArrayList<compressor_point_t> levels;
103 ComprMultiEffect *plugin;
105 CompressorEngine *engine;
108 class ComprMultiEffect : public PluginAClient
111 ComprMultiEffect(PluginServer *server);
114 int is_multichannel();
116 void read_data(KeyFrame *keyframe);
117 void save_data(KeyFrame *keyframe);
118 int process_buffer(int64_t size, Samples **buffer,
119 int64_t start_position, int sample_rate);
121 // calculate envelopes of all the bands
122 void calculate_envelope();
124 void allocate_input(int new_size);
132 PLUGIN_CLASS_MEMBERS(ComprMultiConfig)
134 #ifndef DRAW_AFTER_BANDPASS
135 // The out of band data for each channel with readahead
136 Samples **input_buffer;
137 // Number of samples in the unfiltered input buffers
139 // input buffer size being calculated by the FFT readers
140 int64_t new_input_size;
141 #endif // !DRAW_AFTER_BANDPASS
142 // Starting sample of the input buffer relative to project in the requested rate.
144 // Number of samples in the filtered input buffers
145 int64_t filtered_size;
148 int64_t last_position;
150 // count spectrogram frames for each band
151 int new_spectrogram_frames[TOTAL_BANDS];
153 BandState *band_states[TOTAL_BANDS];
154 // The big FFT with multiple channels & multiple bands extracted per channel.
157 int need_reconfigure;