RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
unq_iir.cpp
Go to the documentation of this file.
1 //
2 // File = unq_iir.cpp
3 //
4 
5 #include "unq_iir.h"
6 #include <fstream>
7 #include <stdlib.h>
8 #ifdef _DEBUG
9 extern std::ofstream DebugFile;
10 #endif
11 
13  int num_denom_coeff,
14  double* numer_coeff,
15  double* denom_coeff)
16 {
17  int n;
18  Num_Numer_Coeff = num_numer_coeff;
19  Num_Denom_Coeff = num_denom_coeff;
20  Input_Buffer = new double[num_numer_coeff];
21  Output_Buffer = new double[num_denom_coeff + 1];
22  Numer_Coeff = new double[num_numer_coeff];
23  Denom_Coeff = new double[num_denom_coeff + 1];
24  Input_Write_Indx = 0;
26 
27 #ifdef _DEBUG
28  DebugFile << "In UnquantDirectFormIir" << std::endl;
29 #endif
30 
31  for (n = 0; n < num_numer_coeff; n++) {
32  Numer_Coeff[n] = numer_coeff[n];
33  Input_Buffer[n] = 0.0;
34  }
35  for (n = 1; n <= num_denom_coeff; n++) {
36  Denom_Coeff[n] = denom_coeff[n];
37  Output_Buffer[n] = 0.0;
38  }
39  return;
40 }
41 
42 double
44 {
45  double output_val;
46  double term, sum;
47  int input_read_indx, output_read_indx, tap_indx;
48 
49  Input_Buffer[Input_Write_Indx] = input_val;
50  input_read_indx = Input_Write_Indx;
53  Input_Write_Indx = 0;
54 
55  sum = 0.0;
56 
57  for (tap_indx = 0; tap_indx < Num_Numer_Coeff; tap_indx++) {
58  term = Numer_Coeff[tap_indx] * Input_Buffer[input_read_indx];
59  sum += term;
60  input_read_indx--;
61  if (input_read_indx < 0)
62  input_read_indx = Num_Numer_Coeff - 1;
63  }
64 
65  output_read_indx = Output_Write_Indx;
66  for (tap_indx = 1; tap_indx <= Num_Denom_Coeff; tap_indx++) {
67  term = Denom_Coeff[tap_indx] * Output_Buffer[output_read_indx];
68  sum += term;
69  output_read_indx--;
70  if (output_read_indx < 1)
71  output_read_indx = Num_Denom_Coeff;
72  }
73 
78 
79  output_val = sum;
80  return (output_val);
81 }
82 
83 int
85 {
86  return (Num_Numer_Coeff);
87 }
88 
89 int
91 {
92  return (Num_Numer_Coeff);
93 }
94 
95 int
97 {
98  return (Num_Denom_Coeff);
99 }
int GetNumTaps(void)
Definition: unq_iir.cpp:90
UnquantDirectFormIir(int num_numer_coeff, int num_denom_coeff, double *numer_coeff, double *denom_coeff)
Definition: unq_iir.cpp:12
double * Denom_Coeff
Definition: unq_iir.h:26
int GetNumNumerCoeff(void)
Definition: unq_iir.cpp:84
double * Numer_Coeff
Definition: unq_iir.h:25
double * Output_Buffer
Definition: unq_iir.h:24
double * Input_Buffer
Definition: unq_iir.h:23
std::ofstream DebugFile
int GetNumDenomCoeff(void)
Definition: unq_iir.cpp:96
double ProcessSample(double input_val)
Definition: unq_iir.cpp:43