00001 #ifndef INCLUDE_CHANNELIZER_H
00002 #define INCLUDE_CHANNELIZER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "PartialList.h"
00037
00038 #include <memory>
00039
00040
00041 namespace Loris {
00042
00043 class Envelope;
00044 class Partial;
00045
00046
00047
00048
00084
00085 class Channelizer
00086 {
00087
00088 std::auto_ptr< Envelope > _refChannelFreq;
00089
00090 int _refChannelLabel;
00091
00092
00093 double _stretchFactor;
00094
00095
00096
00097
00098
00099 double _ampWeighting;
00100
00101
00102
00103
00104
00105
00106 public:
00107
00108
00127 Channelizer( const Envelope & refChanFreq, int refChanLabel, double stretchFactor = 0 );
00128
00141 Channelizer( double refFreq, double stretchFactor = 0 );
00142
00148 Channelizer( const Channelizer & other );
00149
00155 Channelizer & operator=( const Channelizer & rhs );
00156
00158 ~Channelizer( void );
00159
00160
00161
00166 void channelize( Partial & partial ) const;
00167
00178 #if ! defined(NO_TEMPLATE_MEMBERS)
00179 template<typename Iter>
00180 void channelize( Iter begin, Iter end ) const;
00181 #else
00182 void channelize( PartialList::iterator begin, PartialList::iterator end ) const;
00183 #endif
00184
00186 #if ! defined(NO_TEMPLATE_MEMBERS)
00187 template<typename Iter>
00188 void operator() ( Iter begin, Iter end ) const
00189 #else
00190 inline
00191 void operator() ( PartialList::iterator begin, PartialList::iterator end ) const
00192 #endif
00193 { channelize( begin, end ); }
00194
00211 double channelFrequencyAt( double time, int channel ) const;
00212
00229 int computeChannelNumber( double time, double frequency ) const;
00230
00251 double computeFractionalChannelNumber( double time, double frequency ) const;
00252
00253
00263 double referenceFrequencyAt( double time ) const;
00264
00265
00266
00274 double amplitudeWeighting( void ) const;
00275
00283 void setAmplitudeWeighting( double expon );
00284
00296 double stretchFactor( void ) const;
00297
00314 void setStretchFactor( double stretch );
00315
00316
00317
00318
00319
00345 static double computeStretchFactor( double fm, int m, double fn, int n );
00346
00347
00348
00349
00366 static
00367 void channelize( PartialList & partials,
00368 const Envelope & refChanFreq, int refChanLabel );
00369
00370
00371
00372
00373
00398 void setStretchFactor( double fm, int m, double fn, int n );
00399
00400
00424 #if ! defined(NO_TEMPLATE_MEMBERS)
00425 template< typename Iter >
00426 static
00427 void channelize( Iter begin, Iter end,
00428 const Envelope & refChanFreq, int refChanLabel );
00429 #else
00430 static inline
00431 void channelize( PartialList::iterator begin, PartialList::iterator end,
00432 const Envelope & refChanFreq, int refChanLabel );
00433 #endif
00434
00435
00448 static double computeStretchFactor( double f1, double fn, double n );
00449
00450 };
00451
00452
00453
00454
00465
00466 #if ! defined(NO_TEMPLATE_MEMBERS)
00467 template<typename Iter>
00468 void Channelizer::channelize( Iter begin, Iter end ) const
00469 #else
00470 inline
00471 void Channelizer::channelize( PartialList::iterator begin, PartialList::iterator end ) const
00472 #endif
00473 {
00474 while ( begin != end )
00475 {
00476 channelize( *begin++ );
00477 }
00478 }
00479
00480
00481
00482
00506
00507 #if ! defined(NO_TEMPLATE_MEMBERS)
00508 template< typename Iter >
00509 void Channelizer::channelize( Iter begin, Iter end,
00510 const Envelope & refChanFreq, int refChanLabel )
00511 #else
00512 inline
00513 void Channelizer::channelize( PartialList::iterator begin, PartialList::iterator end,
00514 const Envelope & refChanFreq, int refChanLabel )
00515 #endif
00516 {
00517 Channelizer instance( refChanFreq, refChanLabel );
00518 while ( begin != end )
00519 {
00520 instance.channelize( *begin++ );
00521 }
00522 }
00523
00524 }
00525
00526 #endif