⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initial.h

📁 一个具有很强通用性的在C6713上运行的源程序。
💻 H
字号:
#define BUFFSIZE 1024
#define DM_FRAMELENGTH 1024
//Nullforming 算法数据结构及函数声明
#define INT_DELAY 1

typedef struct {
	
	int FrameLength;
	float CrossCorrelation;
	float AutoCorrelation;
	float W;

	short * X; // FrameLength
	short * Y; // FrameLength
	short LastFore[INT_DELAY];
	short LastBack[INT_DELAY];
	
} DSBD_Buffer;

int DualMicNullForming(//int FrameLength,
					   short * restrict Fore,short * restrict Back,
					   short * restrict output,
					   short * restrict back_cardiod,			 // backward cardiod output	
                       DSBD_Buffer * restrict DB);
                   
int Init_DSBDB( DSBD_Buffer *DB, int Frame );

void Destroy_DSBDB( DSBD_Buffer *DB );

// 噪声估计算法数据结构及函数声明
#define X_INT    short     // use X_LONG when used as temporal index
#define X_LONG   int
#define X_FLOAT  float

#ifndef PI
#define PI       3.1415926
#endif

typedef struct IMCRA_Params {
	// Parameters and Thresholds
	X_INT init_flag;    // Initialize when it's set

	X_INT spec_size;    // spectral resolution, one half of frame_len
	
	X_FLOAT Omega;     // spectral smoothing factor, 1
	X_FLOAT AlphaS; // 0.9
	X_INT U; // 8
	X_INT V; // 15
	X_INT D; // 120
	X_FLOAT Bmin; // 1.66
	X_FLOAT Gamma0; // 4.6
	X_FLOAT Gamma1; // 3
	X_FLOAT Zeta0; // 1.67
	X_FLOAT Alpha; // 0.92
	X_FLOAT AlphaD; // 0.85
	X_FLOAT Beta; // 1.47
	X_FLOAT NS_RSB_MIN;  // 0.08
	X_INT j;    // a counter for frames within a sub-window
	X_INT update_pos; // indicate the position to update a minimum in long-term store
	
	// Buffers
	X_FLOAT *  restrict LambdaD; // save last frame, this is output
	X_FLOAT * restrict Gamma_prev; // a posteriori SNR of previous frame, save last frame
	X_FLOAT * restrict S; // save last frame
	X_FLOAT * restrict S_tilde; // save last frame
	X_FLOAT * restrict GH1;// save last frame, try again
	X_FLOAT * restrict Smin; // save last frame
	X_FLOAT * restrict Smin_tilde; // save last frame
	X_FLOAT * restrict Smin_sw; // save last frame
	X_FLOAT * restrict Smin_sw_tilde; // save last frame
	X_FLOAT * restrict Smin_store; // U * spec_size
	X_FLOAT * restrict Smin_sw_tilde_store; // U * spec_size

	X_FLOAT * restrict I_float;   // float version of I

	X_FLOAT * restrict hanning; // 3

	X_FLOAT * restrict Xi; // used too often, used by Vf.
	X_FLOAT * I_smo; // share mem with float_buffer
	X_FLOAT * IY_smo; // share mem with Sf

	X_FLOAT * Y2;   // input spectrogram, pointer to input parameter input2.
	X_FLOAT * float_buffer; // pointer to I_smo
	X_FLOAT * Sf;  // pointer to IY_smo
	
}IMCRA_Params;

X_INT Init_IMCRA_Params( IMCRA_Params * pIMPar, X_INT spec_size );

void Delete_IMCRA_Params( IMCRA_Params * pIMPar );

void IMCRA_Estimate( X_FLOAT * restrict input, X_FLOAT * input2, X_FLOAT * restrict output, IMCRA_Params * IM );

void Reset_IMCRA_Params( IMCRA_Params * pIMPar );

void win_smooth( X_FLOAT * restrict input, X_FLOAT * output, X_FLOAT * win, X_INT spec_size, X_INT win_len );
void win_smooth1( X_FLOAT * restrict input, X_FLOAT * restrict output, X_FLOAT * restrict win, X_INT spec_size) ;
void win_smooth2( X_FLOAT * restrict input, X_FLOAT * restrict output, X_FLOAT * restrict win, X_INT spec_size) ;

X_FLOAT safe_div( X_FLOAT y, X_FLOAT x, X_FLOAT protector );


//后滤波算法数据结构及函数声明

typedef struct Prob_Params {
	X_INT init_flag;    // Initialize when it's set
	X_INT spec_size;	// spectral resolution, one half of frame_len
	X_INT k0, k1, k_len;	// for computing Psi_tilde, 9, 200, 192
	X_INT half_len;		// half length of smoothing window, 2

	X_FLOAT alpha_s;	// temporal recursive smoothing, 0.8f
	X_FLOAT Psi_tilde;		// global, 0
	X_FLOAT Lambda0; // 1.54f
	X_FLOAT Psi0; // 0.25f
	X_FLOAT gamma0; // 4.6f
	X_FLOAT Omega_low; // 1
	X_FLOAT Omega_high; // 3
	// Enhancing
	X_FLOAT alpha; // 0.92f
	X_FLOAT alpha_d; // 0.85f
	X_FLOAT alpha_T; // 0.7f
	X_FLOAT Gmin; // thresh
	
	X_FLOAT * Y2;
	X_FLOAT * U2;

	X_FLOAT * tmpy;		// temporary buffer for PRIMARY channel
	X_FLOAT * tmpu;		// temporary buffer for REFERENCE channel
	X_FLOAT * restrict SY;		// frequency-smoothed Y, save last frame
	X_FLOAT * restrict SU;		// frequency-smoothed U, save last frame
	X_FLOAT * restrict MY;		// noise estimation of Y
	X_FLOAT * restrict MU;		// noise estimation of U
	
	X_FLOAT * restrict gamma_prev; // save last frame
	X_FLOAT * restrict GH1; // save last frame
	X_FLOAT * restrict G; // save last frame
	X_FLOAT * restrict lambda_d; // save last frame

	// Frequency smoothing of spectrogram
	X_FLOAT * restrict b;		// smoothing window, 5


	IMCRA_Params IMCRA_Y;	// noise estimation parameters for PRIMARY channel
	IMCRA_Params IMCRA_U;	// noise estimation parameters for REFERENCE channel


	/*
	 * Pointers to save memory
	 */
	X_FLOAT * restrict Y;	 // input buffers, pointer to input parameter pri.
	X_FLOAT * restrict U; // input buffers, pointer to input parameter ref.
	X_FLOAT * restrict X;	 //Estimated clean signal, pointer to result 	
	// For computing LNS
	X_FLOAT * Lambda_Y; // pointer to tmpy.
	X_FLOAT * Lambda_U; // pointer to tmpu.
	X_FLOAT * G_cur; // pointer to tmpy.

	X_FLOAT * q_hat;		// signal absence probability, pointer to tmpu.

	X_FLOAT * Psi; // point to U2.
	
}Prob_Params;

X_INT Init_Prob_Params( Prob_Params * prob, X_INT spec_size, X_FLOAT thresh, X_FLOAT alphaT );

void Delete_Prob_Params( Prob_Params * prob );

void Reset_Prob_Params( Prob_Params * prob );

void Prob_Denoise(X_FLOAT * pri,		// primary signal (magnitude)
				   X_FLOAT * ref,		// reference signal (magnitude)
				X_FLOAT * pri2, X_FLOAT * ref2,
				   X_FLOAT * res_mag,	// magnitude of result
				   Prob_Params * PP
				   );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -