Channelizer.h

00001 #ifndef INCLUDE_CHANNELIZER_H
00002 #define INCLUDE_CHANNELIZER_H
00003 /*
00004  * This is the Loris C++ Class Library, implementing analysis, 
00005  * manipulation, and synthesis of digitized sounds using the Reassigned 
00006  * Bandwidth-Enhanced Additive Sound Model.
00007  *
00008  * Loris is Copyright (c) 1999-2007 by Kelly Fitz and Lippold Haken
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  *
00025  * Channelizer.h
00026  *
00027  * Definition of class Loris::Channelizer.
00028  *
00029  * Kelly Fitz, 21 July 2000
00030  * loris@cerlsoundgroup.org
00031  *
00032  * http://www.cerlsoundgroup.org/Loris/
00033  *
00034  */
00035 
00036 #if defined(NO_TEMPLATE_MEMBERS)
00037 #include "PartialList.h"
00038 #endif
00039 
00040 #include <memory>
00041 
00042 //  begin namespace
00043 namespace Loris {
00044 
00045 class Envelope;
00046 class Partial;
00047 
00048 // ---------------------------------------------------------------------------
00049 //  Channelizer
00050 //  
00086 //
00087 class Channelizer
00088 {
00089 //  -- implementaion --
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 //  -- public interface --
00108 public:
00109 //  -- construction --
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 //  -- channelizing --
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 //  -- access/mutation --
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 // -- static members --
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 };  //  end of class Channelizer
00416 
00417 // ---------------------------------------------------------------------------
00418 //  channelize (sequence of Partials)
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 //  channelize (static)
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 }   //  end of namespace Loris
00488 
00489 #endif /* ndef INCLUDE_CHANNELIZER_H */

Generated on Sat Jan 19 19:02:50 2008 for Loris by  doxygen 1.5.2