randnoise.c

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

C
31
字号
// 
//  Project: Experiment 3.6.6.1 Real Time Signal Generation - Chapter 3  
//  File name: randNoise.c   
//
//  Description: This function generates random numbers using math library rand()
//
//  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
//

#include <stdlib.h>

// Function prototype
void initRand(unsigned short seed);
short randNoise(void);        

void initRand(unsigned short seed)
{
  srand(seed);
}

short randNoise(void)          
{   
  return((rand()-RAND_MAX/2)>>1);
}

⌨️ 快捷键说明

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