#ifndef WAVELIB_H_
#define WAVELIB_H_

#ifdef __cplusplus
extern "C" {
#endif

#if defined(_MSC_VER)
#pragma warning(disable : 4200)
#pragma warning(disable : 4996)
#endif

#ifndef fft_type
#define fft_type float
#endif

#ifndef cplx_type
#define cplx_type float
#endif

typedef struct Filter{
	uint Len;
	float C0;
	float C1;
	float C2;
	float C3;
}Filter;

typedef struct
{
		 float x1;
		 float x2;
		 float x3;
		 float x4;
		 float x5;
		 float x6;
		 float x7;
		 float y1;
		 float y2;
		 float y3;
		 float y4;
		 float y5;
		 float y6;
		 float y7;		
		
}hilbert_para;	//�˲���ϵ��

typedef struct wave_set* wave_object;

wave_object wave_init(const char* wname);

struct wave_set{
	char wname[50];
	int filtlength;// When all filters are of the same length. [Matlab uses zero-padding to make all filters of the same length]
	int lpd_len;// Default filtlength = lpd_len = lpr_len = hpd_len = hpr_len
	int hpd_len;
	int lpr_len;
	int hpr_len;
	float *lpd;
	float *hpd;
	float *lpr;
	float *hpr;
	float params[0];
};

typedef struct fft_t {
  fft_type re;
  fft_type im;
} fft_data;

typedef struct fft_set* fft_object;

fft_object fft_init(int N, int sgn);

struct fft_set{
	int N;
	int sgn;
	int factors[64];
	int lf;
	int lt;
	fft_data twiddle[1];
};

typedef struct fft_real_set* fft_real_object;

fft_real_object fft_real_init(int N, int sgn);

struct fft_real_set{
	fft_object cobj;
	fft_data twiddle2[1];
};

typedef struct conv_set* conv_object;

conv_object conv_init(int N, int L);

struct conv_set{
	fft_real_object fobj;
	fft_real_object iobj;
	int ilen1;
	int ilen2;
	int clen;
};

typedef struct wt_set* wt_object;

wt_object wt_init(wave_object wave,const char* method, int siglength, int J);

struct wt_set{
	wave_object wave;
	conv_object cobj;
	char method[10];
	int siglength;// Length of the original signal.
	int modwtsiglength; // Modified signal length for MODWT
	int outlength;// Length of the output DWT vector
	int lenlength;// Length of the Output Dimension Vector "length"
	int J; // Number of decomposition Levels
	int MaxIter;// Maximum Iterations J <= MaxIter
	int even;// even = 1 if signal is of even length. even = 0 otherwise
	char ext[10];// Type of Extension used - "per" or "sym"
	char cmethod[10]; // Convolution Method - "direct" or "FFT"

	int N; //
	int cfftset;
	int zpad;
	int length[102];
	float *output;
	float params[0];
};

void filter_Init(void);
float hilbert_filter(float *channel1, float *channel2, int len);
void DWT_Matrix_Transform(float *srcData, s16 *resData, int srcLen);

void modwt(wt_object wt, const float *inp);

void imodwt(wt_object wt, float *dwtop);

float* getMODWTmra(wt_object wt, float *wavecoeffs);

void wave_free(wave_object object);

void wt_free(wt_object object);

extern struct file *g_fpuo,*g_fpio;

#ifdef __cplusplus
}
#endif


#endif /* WAVELIB_H_ */
