fir.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:3k
- /*
- * Copyright 2001 by Texas Instruments Incorporated.
- * All rights reserved. Property of Texas Instruments Incorporated.
- * Restricted rights to use, duplicate or disclose this code are
- * granted through contract.
- * U.S. Patent Nos. 5,283,900 5,392,448
- */
- /* "@(#) DSP/BIOS 4.51.0 05-23-01 (barracuda-i10)" */
- /***************************************************************************/
- /* */
- /* V O L U M E . C */
- /* */
- /* Audio gain processing in a main loop */
- /* */
- /***************************************************************************/
- #include <stdio.h>
- #include "volume.h"
- /* Global declarations */
- short inp_buffer[BUFSIZE]; /* processing data buffers */
- short out_buffer[BUFSIZE]={0x00000000,
- 0x0000000f,
- 0x0000001e,
- 0x0000002d,
- 0x0000003a,
- 0x00000046,
- 0x00000050,
- 0x00000059};
- short h[BUFSIZE]={1,2,3,4,5,6,7,8};
- int gain = MINGAIN; /* volume control variable */
- unsigned int processingLoad = BASELOAD; /* processing routine load value */
- struct PARMS str =
- {
- 2934,
- 9432,
- 213,
- 9432,
- &str
- };
- /* Functions */
- extern void load(unsigned int loadValue);
- static int processing(short *input, short *output);
- static void dataIO(void);
- void fir8(short x[], short h[], short y[], int N, int M)
- {
- int i, j, sum;
-
- for (j = 0; j < M; j++) {
- sum = 0;
- for (i = 0; i < N; i++)
- sum += x[i + j] * h[i];
- y[j] = sum >> 15;
- }
- }
- /*
- * ======== main ========
- */
- void main()
- {
- short *input = &inp_buffer[0];
- short *output = &out_buffer[0];
-
- puts("volume example startedn");
- /* loop forever */
- while(TRUE)
- {
- /*
- * Read input data using a probe-point connected to a host file.
- * Write output data to a graph connected through a probe-point.
- */
- dataIO();
- #ifdef FILEIO
- puts("begin processing") /* deliberate syntax error */
- #endif
-
- /* apply gain */
- processing(input, output);
- }
- }
- /*
- * ======== processing ========
- *
- * FUNCTION: apply signal processing transform to input signal.
- *
- * PARAMETERS: address of input and output buffers.
- *
- * RETURN VALUE: TRUE.
- */
- static int processing(short *input, short *output)
- {
- fir8( input, &h[0],output, 8, 2);
- /* additional processing load */
- load(processingLoad);
-
- return(TRUE);
- }
- /*
- * ======== dataIO ========
- *
- * FUNCTION: read input signal and write processed output signal.
- *
- * PARAMETERS: none.
- *
- * RETURN VALUE: none.
- */
- static void dataIO()
- {
- /* do data I/O */
- return;
- }