| | 55 | \subsection ExampleRRCFilter Example: design a root raised-cosine filter |
| | 56 | \code |
| | 57 | // A simple SigProc example: examplerrcfilter.cpp |
| | 58 | |
| | 59 | #include "sigproc/SigProc.h" |
| | 60 | |
| | 61 | int main() { |
| | 62 | unsigned int h_len; // filter length |
| | 63 | float * h; // array for filter coefficients |
| | 64 | |
| | 65 | unsigned int k(4); // samples per symbol |
| | 66 | unsigned int m(3); // filter delay (symbols) |
| | 67 | float beta(0.3); // excess bandwidth factor |
| | 68 | |
| | 69 | // Calculate filter coefficients |
| | 70 | SigProc::DesignRRCFilter(k, m, beta, h, h_len); |
| | 71 | |
| | 72 | // Print filter coefficients to the screen |
| | 73 | for (unsigned int i=0; i<h_len; i++) |
| | 74 | printf("h[%d] = %f\n", i, h[i]); |
| | 75 | |
| | 76 | // Clean up memory |
| | 77 | delete [] h; |
| | 78 | |
| | 79 | return 0; |
| | 80 | } |
| | 81 | \endcode |
| | 82 | |
| | 83 | Compile and run |
| | 84 | \verbatim |
| | 85 | $ g++ -lsigproc examplerrcfilter.cpp -o ExampleRRCFilter |
| | 86 | $ ./ExampleRRCFilter |
| | 87 | \endverbatim |
| | 88 | |