Changeset 6326

Show
Ignore:
Timestamp:
02/01/08 15:02:31 (5 years ago)
Author:
jgaeddert
Message:

updating decimator to use calculated coefficients only when none are specified in the properties list

Location:
components/Decimator/branches/Decimator-0.6.2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • components/Decimator/branches/Decimator-0.6.2/Decimator.cpp

    r6325 r6326  
    3232    //#define PRINT_ENERGY 1 
    3333 
    34 Decimator_i::Decimator_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition), M(1), sample_count(0), previous_length(0) 
     34Decimator_i::Decimator_i(const char *uuid, omni_condition *condition) : 
     35    Resource_impl(uuid), 
     36    component_running(condition), 
     37    calculateFilterCoefficients(true), 
     38    M(1), 
     39    sample_count(0), 
     40    previous_length(0) 
    3541{ 
    3642    // Create the port for output data 
     
    115121            std::cout << "Decimation factor set to " << M << std::endl; 
    116122 
    117             // calculate filter coefficients dynamically 
    118             unsigned int m(3);      // filter delay (symbols) 
    119             float beta(0.5f);       // excess bandwidth factor 
    120             len_h = 2*D*m+1;        // filter length (samples) 
    121             delete [] h; 
    122             h = new float[len_h]; 
    123             SigProc::DesignRRCFilter(D, m, beta, h); 
    124  
    125             // delete old filters 
    126             delete i_filter; 
    127             delete q_filter; 
    128  
    129             // print coefficients 
    130             unsigned int k; 
    131             for (k=0; k<len_h; k++) 
    132                 printf("  h[%u] = %E\n", k, h[k]); 
    133  
    134             i_filter = new SigProc::fir_filter(h, len_h); 
    135             q_filter = new SigProc::fir_filter(h, len_h); 
     123            if (calculateFilterCoefficients) { 
     124                // calculate filter coefficients dynamically 
     125                unsigned int m(3);      // filter delay (symbols) 
     126                float beta(0.5f);       // excess bandwidth factor 
     127                len_h = 2*D*m+1;        // filter length (samples) 
     128                delete [] h; 
     129                h = new float[len_h]; 
     130                SigProc::DesignRRCFilter(D, m, beta, h); 
     131 
     132                // delete old filters 
     133                delete i_filter; 
     134                delete q_filter; 
     135 
     136                // print coefficients 
     137                for (unsigned int k=0; k<len_h; k++) 
     138                    DEBUG(2, Decimator, " h[" << k << "] = " << h[k]); 
     139 
     140                i_filter = new SigProc::fir_filter(h, len_h); 
     141                q_filter = new SigProc::fir_filter(h, len_h); 
     142            } 
    136143        } else if (strcmp(props[i].id, "DCE:134e5dd8-c773-47af-a557-2837076358c4") == 0) { 
    137144            // filter property, Filter coefficients 
    138             std::cout << "WARNING: Decimator::configure(), ignoring coefficients property" 
    139                       << std::endl; 
    140             break; 
    141  
    142145            CORBA::FloatSeq *coeff_ptr; 
    143146            props[i].value >>= coeff_ptr; 
    144147 
    145148            len_h = coeff_ptr->length(); 
    146  
    147             delete []h; 
    148             delete i_filter; 
    149             delete q_filter; 
    150  
    151             h = new float[len_h]; 
    152             std::cout << "Decimator filter length = " << len_h << std::endl; 
    153             for (unsigned int k = 0; k < len_h; k++) { 
    154                 h[k] = (*coeff_ptr)[k]; 
    155                 std::cout << "Coeff[" << k << "] = " << h[k] << std::endl; 
     149             
     150            if (len_h < 2) { 
     151                calculateFilterCoefficients = true; 
     152            } else { 
     153                calculateFilterCoefficients = false; 
     154 
     155                delete []h; 
     156                delete i_filter; 
     157                delete q_filter; 
     158 
     159                h = new float[len_h]; 
     160                std::cout << "Decimator filter length = " << len_h << std::endl; 
     161                for (unsigned int k = 0; k < len_h; k++) { 
     162                    h[k] = (*coeff_ptr)[k]; 
     163                    DEBUG(3, Decimator, "Coeff[" << k << "] = " << h[k]) 
     164                } 
     165                i_filter = new SigProc::fir_filter(h, len_h); 
     166                q_filter = new SigProc::fir_filter(h, len_h); 
    156167            } 
    157             i_filter = new SigProc::fir_filter(h, len_h); 
    158             q_filter = new SigProc::fir_filter(h, len_h); 
    159168 
    160169        } else { 
  • components/Decimator/branches/Decimator-0.6.2/Decimator.h

    r4395 r6326  
    2626#include "ossie/cf.h" 
    2727#include "ossie/PortTypes.h" 
     28#include "ossie/debug.h" 
    2829 
    2930#include "standardinterfaces/complexShort.h" 
     
    6768 
    6869    // For decimation operation 
    69     float *h;  // Array for filter coefficients 
    70     unsigned int len_h;  // Length of filter 
     70    float *h;                           ///< Array for filter coefficients 
     71    unsigned int len_h;                 ///< Length of filter 
     72 
     73    /// Automatically calculate filter coefficients?  This will only happen 
     74    /// if length of the filter coefficient property is zero 
     75    bool calculateFilterCoefficients; 
    7176 
    7277    unsigned int M;  // Decimation factor