VOLUME.C
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:3k
源码类别:

DSP编程

开发平台:

C/C++

  1. #include "volume.h"
  2. int inp_buffer[BUF_SIZE]; /* BUF_SIZE的定义见volume.h */
  3. int out_buffer[BUF_SIZE];
  4. int *input;
  5. int *output;
  6. int volume = 1;
  7. struct PARMS str = 
  8. {
  9. 2934,9432,213,9432,&str
  10. };
  11. /***************************************************************************/
  12. /*                                                                         */
  13. /* NAME: read_signals()                                                    */
  14. /*                                                                         */
  15. /* FUNCTION: read input signal.                                            */
  16. /*                                                                         */
  17. /* PARAMETERS: none.                                                       */
  18. /*                                                                         */
  19. /* RETURN VALUE: TRUE.                                                     */
  20. /*                                                                         */
  21. /***************************************************************************/
  22. int read_signals(int *input)
  23. {
  24. /* read reference signal */
  25. /* read input signal */
  26. return(TRUE);
  27. }
  28. /***************************************************************************/
  29. /*                                                                         */
  30. /* NAME: write_buffer()                                                    */
  31. /*                                                                         */
  32. /* FUNCTION: write to the output buffer. Use the volume variable     */
  33. /*  to control the volume.                    */
  34. /*                                                                         */
  35. /* PARAMETERS: input , output, num.                                        */
  36. /*                                                                         */
  37. /* RETURN VALUE: TRUE.                                                     */
  38. /*                                                                         */
  39. /***************************************************************************/
  40. int write_buffer(int *input,int *output,int count)
  41. {
  42. while( count--)
  43. {
  44. *output++ = (*input++) * volume;
  45. }
  46. return(TRUE);
  47. }
  48. /***************************************************************************/
  49. /*                                                                         */
  50. /* NAME: main()                                                            */
  51. /*                                                                         */
  52. /* FUNCTION: Volume Control: Read input buffer    */
  53. /*           multiply by volume coeficient and write to                    */
  54. /*  output buffer.    */
  55. /*                                                                         */
  56. /* PARAMETERS: none.                                                       */
  57. /*                                                                         */
  58. /* RETURN VALUE: none.                                                     */
  59. /*                                                                         */
  60. /***************************************************************************/
  61. main()
  62. {   
  63. int num = BUF_SIZE;
  64.     while(TRUE)  /* loop forever */
  65. {               
  66. input = &inp_buffer[0]; 
  67. output = &out_buffer[0];
  68. /* read input signals from PC file */
  69. read_signals(input);
  70. /* write to output buffer  */
  71. write_buffer(input, output, num);
  72. }
  73. }