/**************************************
		SV_realFFT.h
***************************************/

#include "SV_common_include.h"

//#define FFTLOGLEN 9
//#define FFTLEN (1<<FFTLOGLEN)       // 512
//#define FFTOVERLAP (FFTLEN*3/8)     // 192

//typedef struct{
//    int re, im;
//}ComplexInt;


// FFT 1 channel
typedef struct{
    int winbuf_0[FFTLEN];
    int winbuf_1[FFTLEN];
    int *pa, *pb;
//    short* win_coeffs;
}SV_realFFT_1ch_T;

// Processing 1ch
extern void SV_realFFT_1ch_Exe(ComplexInt* out, int* in, int n, SV_realFFT_1ch_T* p_struct);
// out - spectrum
// in - input PCM data
// n - number of samples (must be 1<<loglen - see Init() below)
// p_struct - pointer to the module structure

// Init 1ch
extern void SV_realFFT_1ch_Init(SV_realFFT_1ch_T* p_struct);
// loglen - logarithm of fft length
// p_struct - pointer to the module structure (to be initialized)


// FFT 2 channel
typedef struct{
    int winbuf_ch1_0[FFTLEN];
    int winbuf_ch1_1[FFTLEN];
    int winbuf_ch2_0[FFTLEN];
    int winbuf_ch2_1[FFTLEN];
    int *pa, *pb, *pc, *pd;
//    short* win_coeffs;
}SV_realFFT_2ch_T;

// Processing 1ch
extern void SV_realFFT_2ch_Exe(ComplexInt* out0, ComplexInt* out1, int* in0, int* in1, int n, SV_realFFT_2ch_T* p_struct);
// out0, out1 - output spectrums
// in0, in1 - input PCM data
// n - number of samples (must be 1<<loglen - see Init() below)
// p_struct - pointer to the module structure

// Init 1ch
extern void SV_realFFT_2ch_Init(SV_realFFT_2ch_T* p_struct);
// loglen - logarithm of fft length
// p_struct - pointer to the module structure (to be initialized)


// IFFT 1 channel

// Processing 1ch
extern void SV_realIFFT_1ch_Exe(int* out, ComplexInt* in, int n, SV_realFFT_1ch_T* p_struct);
// in - PCM data
// out - input spectrum
// n - number of samples (must be 1<<loglen - see Init() below)
// p_struct - pointer to the module structure

// Init 1ch
extern void SV_realIFFT_1ch_Init(SV_realFFT_1ch_T* p_struct);
// loglen - logarithm of fft length
// p_struct - pointer to the module structure (to be initialized)

