profile.c

来自「CHAPTER 1- real-Time Digital Signal Proc」· C语言 代码 · 共 47 行

C
47
字号
// 
//  Project: Experiment 1.6.5 Profile - Chapter 1 
//  File name: profile.c   
//
//  Description: This function is for example 1.6.5 profile
//
//  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 <stdio.h>
#include <math.h>
#include "profile.h"

void main()
{ 
  FILE  *outFile;  // File pointer of output file
  short x[2],i;

  outFile = fopen("..\\data\\output.wav", "wb");
                
  // Add wav header to left and right channel output files
  fwrite(wavHeader, sizeof(char), 44, outFile);  
    
  // Generate 1 second 1 kHz sine wave at 8kHz sampling rate
  for (i=0; i<8000; i++)
  {    
    x[0] = sinewave(i);     // <- Profile range start
    x[1] = (x[0]>>8)&0xFF;  // <- Profile range stop
    x[0] = x[0]&0xFF;
    fwrite(x, sizeof(char), 2, outFile);     
  }
    
  fclose(outFile);
}

// Integer sine-wave generator
short sinewave(short n)          // <- Profile function
{
  return( (short)(sin(TWOPI_f_F*(float)n)*16384.0));
}

⌨️ 快捷键说明

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