tone.c

来自「CHP 3 - Real-Time Digital Signal Process」· C语言 代码 · 共 42 行

C
42
字号
// 
//  Project: Experiment 3.6.6.5 Real Time Signal Generation - Chapter 3  
//  File name: tone.c   
//
//  Description: This function generates a tone by calling
//               C55x assembly routine, cosine()
//
//  For the book "Real Time Digital Signal Processing: 
//                Implementation and Application, 2nd Ed"
//                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
//                Publisher: John Wiley and Sons, Ltd
//
//  Tools used: CCS v.2.12.07
//              TMS320VC5510 DSK Rev-C
//

#define PI          0x7FFF

// Function prototype
void  initTone(unsigned short f, unsigned short Fs);
short tone(void);        
extern short cosine(short); 

// Variable definition
static unsigned short n;         
static short twoPI_f_Fs;

void initTone(unsigned short f, unsigned short Fs)
{
  n = 0;
  twoPI_f_Fs = (short)((2.0*PI*(float)f/(float)Fs));
}

short tone(void)          
{            
  short theta;
    
  theta = (short)(twoPI_f_Fs * n++);
  return (cosine(theta)); 
}

⌨️ 快捷键说明

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