new/reworked audio plugins ported from hv72 compressor/multi/reverb, glyph workaround...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / fourier.h
index 482c6fb04bb01f197be96560e167c5218b8d3a8d..9b83153ab071c44d82aad55c0b734378b0f40f6a 100644 (file)
@@ -33,16 +33,16 @@ class FFT
        static uint8_t rev_bytes[256];
        static unsigned int reverse_bits(unsigned int index, unsigned int bits);
        static void bit_reverse(unsigned int samples,
-               double *real_in, double *imag_in,
-               double *real_out, double *imag_out);
+                       double *real_in, double *imag_in,
+                       double *real_out, double *imag_out);
 public:
        FFT();
        virtual ~FFT();
        // can be in place, but imag_out must exist, imag_in optional
        int do_fft(int samples, // must be a power of 2
                int inverse,             // 0 = forward FFT, 1 = inverse
-               double *real_in, double *imag_in,       // complex input
-               double *real_out, double *imag_out);    // complex output
+                       double *real_in, double *imag_in,       // complex input
+                       double *real_out, double *imag_out);    // complex output
        int do_fft(int samples, int inverse, double *real, double *imag) {
                return do_fft(samples, inverse, real, imag, real, imag);
        }
@@ -58,8 +58,8 @@ public:
        virtual ~CrossfadeFFT();
 
        int reset();
-       int initialize(int window_size);
-       long get_delay();     // Number of samples fifo is delayed
+       int initialize(int window_size, int bands = 1);
+       long get_delay();        // Number of samples fifo is delayed
        int reconfigure();
        int fix_window_size();
        int delete_fft();
@@ -69,28 +69,33 @@ public:
 // output_sample - tells it if we've seeked and the output overflow is invalid.
 // return - 0 on success 1 on failure
 // output_sample - start of samples if forward.  End of samples if reverse.
-//               It's always contiguous.
+//                        It's always contiguous.
 // output_ptr - if nonzero, output is put here
 // direction - PLAY_FORWARD or PLAY_REVERSE
        int process_buffer(int64_t output_sample,
-               long size,
-               Samples *output_ptr,
-               int direction);
+               long size, Samples *output_ptr, int direction);
+// multiband processing
+       int process_buffer(int64_t output_sample,
+               long size, Samples **output_ptr, int direction);
 
 // Called by process_buffer to read samples from input.
 // Returns 1 on error or 0 on success.
        virtual int read_samples(int64_t output_sample,
-               int samples,
-               Samples *buffer);
+               int samples, Samples *buffer);
 
 // Process a window in the frequency domain
        virtual int signal_process();
 // Process a window in the time domain after the frequency domain
        virtual int post_process();
+// Multiband versions
+       virtual int signal_process(int band);
+       virtual int post_process(int band);
 
 // Size of a window.  Automatically fixed to a power of 2
        long window_size;
 
+// Time domane input of complete windows
+       Samples *input_buffer;
 // Frequency domain output of FFT
        double *freq_real;
        double *freq_imag;
@@ -99,13 +104,16 @@ public:
        double *output_imag;
 
 private:
+       void allocate_output(int new_allocation);
 
-// input for complete windows
-       Samples *input_buffer;
-// output for crossfaded windows with overflow
-       double *output_buffer;
+// output of crossfaded windows with overflow.  1 buffer for each band
+       double **output_buffer;
+
+// backup frequency domain for multiband
+       double *freq_real2;
+       double *freq_imag2;
 
-// samples in input_buffer
+// samples in input_buffer including the tail
        long input_size;
 // window_size
        long input_allocation;
@@ -119,6 +127,7 @@ private:
        int64_t input_sample;
 // Don't crossfade the first window
        int first_window;
+       int bands;
 };
 
 #endif