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

📄 signal_gen2.c

📁 TI的DSP C55X的应用程序
💻 C
字号:
/*
      signal_gen2 - generate two sinewaves of f1 and f2
*/
#include <intrindefs.h>

#define DELTA 0x7fa0           /* Delat - excite signal */
#define UNIT  0x7fff 
#define THIRD 0x2aaa	       /* 1/3 */
#define PI    3.1415926 
#define N     1024             /* Max number of samples per block */
/* Fs = 8000 Sampling frequency */
/* f1 = 800, f2 = 1800, f3 = 3300 */
#define A1    0x678d           /* UNIT*cos(2*PI*f1/Fs) */
#define A2    0x1405           /* UNIT*cos(2*PI*f2/Fs) */
#define A3    0x92de           /* UNIT*cos(2*PI*f3/Fs) */
#define D1    0x4b04           /* DELTA*sin(2*PI*f1/Fs) */
#define D2    0x7e0e           /* DELTA*sin(2*PI*f2/Fs) */
#define D3    0x42af           /* DELTA*sin(2*PI*f3/Fs) */

static int w1[2]={(int)D1,0};  /* Determine the excite signal 1 */
static int w2[2]={(int)D2,0};  /* Determine the excite signal 2 */
static int w3[2]={(int)D3,0};  /* Determine the excite signal 3 */
static int cos_w1=(int)A1;     /* Determine the coefficient 1 */
static int cos_w2=(int)A2;     /* Determine the coefficient 2 */
static int cos_w3=(int)A3;     /* Determine the coefficient 3 */        

int  x1[N],x2[N],x3[N]; 

extern void sine(int *, int *, unsigned int, int);

void signal_gen2(int *x, unsigned int M)
{                    
    unsigned int i;
	
    sine(x1,w1,M,cos_w1);   /* x1=A1*sin(2*PI*n*f1/Fs) */
    sine(x2,w2,M,cos_w2);   /* x2=A2*sin(2*PI*n*f2/Fs) */
    sine(x3,w3,M,cos_w3);   /* x3=A3*sin(2*PI*n*f3/Fs) */
    for (i=0; i<M; i++)
    {
        x[i] = _smpy(x1[i],THIRD);
        x[i] = _sadd(x[i], _smpy(x2[i],THIRD));
        x[i] = _sadd(x[i], _smpy(x3[i],THIRD));
    }
}

⌨️ 快捷键说明

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