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 #if defined(NO_TEMPLATE_MEMBERS)
00037 #include "PartialList.h"
00038 #endif
00039
00040 #include <memory>
00041
00042
00043 namespace Loris {
00044
00045 class Envelope;
00046 class Partial;
00047
00048
00049
00050
00086
00087 class Channelizer
00088 {
00089
00090 std::auto_ptr< Envelope > _refChannelFreq;
00091
00092 int _refChannelLabel;
00093
00094
00095 double _stretchFactor;
00096
00097
00098
00099
00100
00101 double _ampWeighting;
00102
00103
00104
00105
00106
00107
00108 public:
00109
00110
00129 Channelizer( const Envelope & refChanFreq, int refChanLabel, double stretchFactor = 0 );
00130
00143 Channelizer( double refFreq, double stretchFactor = 0 );
00144
00150 Channelizer( const Channelizer & other );
00151
00157 Channelizer & operator=( const Channelizer & rhs );
00158
00160 ~Channelizer( void );
00161
00162
00163
00168 void channelize( Partial & partial ) const;
00169
00180 #if ! defined(NO_TEMPLATE_MEMBERS)
00181 template<typename Iter>
00182 void channelize( Iter begin, Iter end ) const;
00183 #else
00184 void channelize( PartialList::iterator begin, PartialList::iterator end ) const;
00185 #endif
00186
00188 #if ! defined(NO_TEMPLATE_MEMBERS)
00189 template<typename Iter>
00190 void operator() ( Iter begin, Iter end ) const
00191 #else
00192 inline
00193 void operator() ( PartialList::iterator begin, PartialList::iterator end ) const
00194 #endif
00195 { channelize( begin, end ); }
00196
00213 double channelFrequencyAt( double time, int channel ) const;
00214
00231 int computeChannelNumber( double time, double frequency ) const;
00232
00253 double computeFractionalChannelNumber( double time, double frequency ) const;
00254
00255
00265 double referenceFrequencyAt( double time ) const;
00266
00267
00268
00276 double amplitudeWeighting( void ) const;
00277
00285 void setAmplitudeWeighting( double expon );
00286
00298 double stretchFactor( void ) const;
00299
00316 void setStretchFactor( double stretch );
00317
00340 void setStretchFactor( double fm, int m, double fn, int n );
00341
00342
00343
00365 #if ! defined(NO_TEMPLATE_MEMBERS)
00366 template< typename Iter >
00367 static
00368 void channelize( Iter begin, Iter end,
00369 const Envelope & refChanFreq, int refChanLabel );
00370 #else
00371 static inline
00372 void channelize( PartialList::iterator begin, PartialList::iterator end,
00373 const Envelope & refChanFreq, int refChanLabel );
00374 #endif
00375
00401 static double computeStretchFactor( double fm, int m, double fn, int n );
00402
00413 static double computeStretchFactor( double fref, double fn, double n );
00414
00415 };
00416
00417
00418
00419
00430
00431 #if ! defined(NO_TEMPLATE_MEMBERS)
00432 template<typename Iter>
00433 void Channelizer::channelize( Iter begin, Iter end ) const
00434 #else
00435 inline
00436 void Channelizer::channelize( PartialList::iterator begin, PartialList::iterator end ) const
00437 #endif
00438 {
00439 while ( begin != end )
00440 {
00441 channelize( *begin++ );
00442 }
00443 }
00444
00445
00446
00447
00469
00470 #if ! defined(NO_TEMPLATE_MEMBERS)
00471 template< typename Iter >
00472 void Channelizer::channelize( Iter begin, Iter end,
00473 const Envelope & refChanFreq, int refChanLabel )
00474 #else
00475 inline
00476 void Channelizer::channelize( PartialList::iterator begin, PartialList::iterator end,
00477 const Envelope & refChanFreq, int refChanLabel )
00478 #endif
00479 {
00480 Channelizer instance( refChanFreq, refChanLabel );
00481 while ( begin != end )
00482 {
00483 instance.channelize( *begin++ );
00484 }
00485 }
00486
00487 }
00488
00489 #endif