/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/

#ifndef __GDAM_FFT_H_
#define __GDAM_FFT_H_

#include <glib.h>

/* If forward is true, rfft replaces 2*N real data points in x with
   N complex values representing the positive frequency half of their
   Fourier spectrum, with x[1] replaced with the real part of the Nyquist
   frequency value.  If forward is false, rfft expects x to contain a
   positive frequency spectrum arranged as before, and replaces it with
   2*N real values.  N MUST be a power of 2. */
void gdam_real_fft                            (gdouble     *x,
                                               int          N,
					       gboolean     forward);
void gdam_real_fft_f                          (gfloat      *x,
                                               int          N,
					       gboolean     forward);

/*
 * cfft replaces double array x containing NC complex values (2*NC double
 * values alternating real, imagininary, etc.) by its Fourier transform if
 * forward is true, or by its inverse Fourier transform if forward is false,
 * using a recursive Fast Fourier transform method due to Danielson and
 * Lanczos.  NC MUST be a power of 2. 
 */
void gdam_complex_fft                        (gdouble      *x,
                                              int           NC,
					      gboolean      forward);
void gdam_complex_fft_f                      (gfloat       *x,
                                              int           NC,
					      gboolean      forward);

/* for back compatbility .. use gdam_fft_get_window instead. */
const gdouble* gdam_fft_get_hamming_window  (int            window_size);
const gfloat*  gdam_fft_get_hamming_window_f(int            window_size);
const gdouble* gdam_fft_get_hanning_window  (int            window_size);
const gfloat*  gdam_fft_get_hanning_window_f(int            window_size);

typedef enum _GdamWindowType {
  GDAM_WINDOW_HAMMING,
  GDAM_WINDOW_HANNING
} GdamWindowType;

const gdouble* gdam_fft_get_window         (GdamWindowType window_type,
                                            int            window_size);
const gfloat*  gdam_fft_get_window_f       (GdamWindowType window_type,
                                            int            window_size);

/*
 * bitreverse places double array x containing N/2 complex values into
 * bit-reversed order 
 */
void           gdam_fft_bitreverse         (gdouble       *x,
                                            int            N);
void           gdam_fft_bitreverse_f       (gfloat        *x,
                                            int            N);

#endif
