aud.c
上传用户:hepax88
上传日期:2007-01-03
资源大小:1101k
文件大小:0k
源码类别:

TCP/IP协议栈

开发平台:

Visual C++

  1. #include <stdio.h>
  2. #include <math.h>
  3. #define DMASIZE 16384
  4. main()
  5. {
  6. unsigned char buf[DMASIZE];
  7. double x,y;
  8. unsigned samp;
  9. int i;
  10. FILE *fp;
  11. fp = fopen("test.aud","wb");
  12. for(i=0;i<4096;i++){
  13. x = 2*3.141592653589*(i*256.)/4096.;
  14. samp = 32767 * cos(x);
  15. buf[4*i] = samp;
  16. buf[4*i+1] = samp >> 8;
  17. x = 2*3.141592653589*(i*192.)/4096.;
  18. samp = 32767 * cos(x);
  19. buf[4*i+2] = samp;
  20. buf[4*i+3] = samp >> 8;
  21. }
  22. fwrite(buf,1,DMASIZE,fp);
  23. fclose(fp);
  24. }