bpmdsp/print_filter.c

Go to the documentation of this file.
00001 
00006 #include "bpm/bpm_dsp.h"
00007 
00008 void print_filter( FILE *of, filter_t *f ) {
00009 
00010   int i = 0;
00011 
00012   if ( ! of || ! f ) {
00013     bpm_error( "Invalid pointer in print_filter()", __FILE__, __LINE__  );
00014     return;
00015   }
00016 
00017   fprintf( of, "Filter: %s\n", f->name );
00018 
00019   // print some more bla bla here if i find the time...
00020 
00021   if(f->cplane) print_filter_representation( of, f->cplane );
00022   fprintf( of, "\n" );
00023 
00024   fprintf( of, " - filter gains: %s\n", f->name );
00025   fprintf( of, "   DC mag= %f, phase= %f pi\n", c_abs(f->dc_gain), c_arg(f->dc_gain)/PI );
00026   fprintf( of, "   FC mag= %f, phase= %f pi\n", c_abs(f->fc_gain), c_arg(f->fc_gain)/PI );
00027   fprintf( of, "   HF mag= %f, phase= %f pi\n", c_abs(f->hf_gain), c_arg(f->hf_gain)/PI );
00028   fprintf( of, "   Filter gain = %f\n", f->gain );
00029   fprintf( of, "\n" );
00030 
00031   fprintf( of, " - Recurrence relation :\n" );
00032   fprintf( of, "   y[n] = \n" );
00033 
00034   if ( f->options & CAUSAL ) { // print the causal part
00035     for ( i=0; i<f->nxc; i++ ) {
00036       if ( fabs( f->xc[i]) > FILT_EPS ) {
00037         fprintf( of, "        %s %14.10f * x[n-%d]\n", 
00038                  f->xc[i]>=0.?"+":"-", fabs(f->xc[i]), f->nxc-1-i );
00039       }
00040     }
00041   }
00042 
00043 
00044   if ( f->options & ANTICAUSAL ) { // print the anti-causal part
00045     for ( i=1; i<f->nxc_ac; i++ ) {
00046       if ( fabs( f->xc_ac[i]) > FILT_EPS ) {
00047         fprintf( of, "        %s %14.10f * x[n+%d]\n", 
00048                  f->xc_ac[i]>=0.?"+":"-", fabs(f->xc_ac[i]), i );
00049       }
00050     }
00051   }
00052 
00053 
00054   for ( i=0; i<f->nyc-1; i++ ) {
00055     if ( fabs(f->yc[i]) > FILT_EPS ) {
00056       fprintf( of, "        %s %14.10f * y[n-%d]\n", f->yc[i]>=0.?"+":"-", 
00057                fabs(f->yc[i]), f->nyc-1-i );
00058     }
00059   }
00060 
00061   fprintf( of, "\n" );
00062 
00063   return;
00064 }

Generated on Thu Jan 10 10:18:04 2008 for libbpm by  doxygen 1.5.1