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

📄 process_data.c

📁 this introduce infinite impulse response (IIR) filters. The filters are designed in MATLAB using th
💻 C
字号:
#include "Talkthrough.h"
#include <filter.h>

fract16 sample[2];
fract16 LP_sample[2];
fract16 HP_sample[2];

int buffer[500];

//--------------------------------------------------------------------------//
// Function:	Process_Data()												//
//																			//
// Description: This function is called from inside the SPORT0 ISR every 	//
//				time a complete audio frame has been received. The new 		//
//				input samples can be found in the variables iChannel0LeftIn,//
//				iChannel0RightIn, iChannel1LeftIn and iChannel1RightIn 		//
//				respectively. The processed	data should be stored in 		//
//				iChannel0LeftOut, iChannel0RightOut, iChannel1LeftOut,		//
//				iChannel1RightOut, iChannel2LeftOut and	iChannel2RightOut	//
//				respectively.												//
//--------------------------------------------------------------------------//
void Process_Data(void)
{
    static int c = 0;
    
    sample[0] = (short)(iChannel0LeftIn >> 8); //float_to_fr16( (float)(iChannel0LeftIn << 8) / 0x7FFFFF00); 
    sample[1] = (short)(iChannel0RightIn >> 8); //float_to_fr16( (float)(iChannel0RightIn << 8) / 0x7FFFFF00);  
    
    //sample[0] = mult_fr1x16(sample[0], float_to_fr16(0.002140694065)); 
    //sample[1] = mult_fr1x16(sample[1], float_to_fr16(0.002140694065)); 

        
    // Low pass filter
    iir_fr16(&sample[0], &LP_sample[0], 1, &LP_filt);
    iir_fr16(&sample[1], &LP_sample[1], 1, &LP_filt);
    
    // High pass filter
    iir_fr16(&sample[0], &HP_sample[0], 1, &HP_filt);
    iir_fr16(&sample[1], &HP_sample[1], 1, &HP_filt);

    
    int LeftSample =  ((int)(LP_sample[0])) ; //(int)(fr16_to_float(LP_sample[0]) * 0x7FFFFF00) >> 8;
    int RightSample = ((int)(LP_sample[1])) ; //(int)(fr16_to_float(LP_sample[1]) * 0x7FFFFF00) >> 8;

    buffer[c] = LeftSample;
    c = (c + 1) % 500;
    
	iChannel0LeftOut = LeftSample;
	iChannel0RightOut = iChannel0RightIn;
	
	
	
	
	
	
	//iChannel1LeftOut = iChannel1LeftIn;
	//iChannel1RightOut = iChannel1RightIn;
	
	
	
}

⌨️ 快捷键说明

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