interp3.c

来自「dsp AD公司ADSP21的代码,里面有FFT FIR IIR EQULIZE」· C语言 代码 · 共 48 行

C
48
字号
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "rtdspc.h"

/**************************************************************************

INTERP3.C - PROGRAM TO DEMONSTRATE 3:1 FIR FILTER INTERPOLATION
            USES TWO INTERPOLATION FILTERS AND MULTIPLE CALLS TO THE
            REAL TIME FILTER FUNCTION fir_filter().

*************************************************************************/

main()
{
    int i;
    float signal_in;
/* interpolation coefficients for the decimated filters */
    static float coef31[16],coef32[16];
/* history arrays for the decimated filters */
    static float hist31[15],hist32[15];

/* 3:1 interpolation coefficients, PB 0-0.133, SB 0.2-0.5 */
    static float interp3[47] = {
  -0.00178662, -0.00275941, 0.,  0.00556927,  0.00749929, 0.,
  -0.01268113, -0.01606336, 0.,  0.02482278,  0.03041984, 0.,
  -0.04484686, -0.05417098, 0.,  0.07917613,  0.09644332, 0.,
  -0.14927754, -0.19365910, 0.,  0.40682136,  0.82363913, 1.0,
   0.82363913,  0.40682136, 0., -0.19365910, -0.14927754, 0.,
   0.09644332,  0.07917613, 0., -0.05417098, -0.04484686, 0.,
   0.03041984,  0.02482278, 0., -0.01606336, -0.01268113, 0.,
   0.00749928,  0.00556927, 0., -0.00275941, -0.00178662
              };

    for(i = 0 ; i < 16 ; i++) coef31[i] = interp3[3*i];

    for(i = 0 ; i < 16 ; i++) coef32[i] = interp3[3*i+1];

/* make three samples for each input */
    for(;;) {
        signal_in = getinput();
        sendout(hist31[7]); /* delayed input */
        sendout(fir_filter(signal_in,coef31,16,hist31));
        sendout(fir_filter(signal_in,coef32,16,hist32));
    }
}

⌨️ 快捷键说明

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