Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Resampler.h

00001 #ifndef INCLUDE_RESAMPLER_H
00002 #define INCLUDE_RESAMPLER_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-2004 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  * Resampler.h
00026  *
00027  * Definition of class Resampler, for converting reassigned Partial envelopes
00028  * into more conventional additive synthesis envelopes, having data points
00029  * at regular time intervals. The benefits of reassigned analysis are NOT
00030  * lost in this process, since the elimination of unreliable data and the
00031  * reduction of temporal smearing are reflected in the resampled data.
00032  *
00033  * Lippold, 7 Aug 2003
00034  * loris@cerlsoundgroup.org
00035  *
00036  * http://www.cerlsoundgroup.org/Loris/
00037  *
00038  */
00039 
00040 #include "PartialList.h"
00041 
00042 //  begin namespace
00043 namespace Loris {
00044 
00045 class Partial;
00046 
00047 // ---------------------------------------------------------------------------
00048 //  class Resampler
00049 //
00057 //
00058 class Resampler
00059 {
00060 //  --- public interface ---
00061 public:
00062 //  --- lifecycle ---
00063 
00071     explicit Resampler( double sampleInterval );
00072    
00073     // use compiler-generated copy/assign/destroy
00074     
00075 //  --- resampling ---
00076 
00085     void resample( Partial & p ) const;
00086     
00087      
00089     void operator() ( Partial & p ) const 
00090     { 
00091        resample( p ); 
00092     }
00093      
00109 #if ! defined(NO_TEMPLATE_MEMBERS)
00110     template<typename Iter>
00111     void resample( Iter begin, Iter end ) const;
00112 #else
00113    inline 
00114     void resample( PartialList::iterator begin, PartialList::iterator end  ) const;
00115 #endif   
00116 
00118 #if ! defined(NO_TEMPLATE_MEMBERS)
00119     template<typename Iter>
00120     void operator()( Iter begin, Iter end ) const
00121 #else
00122     void operator()( PartialList::iterator begin, PartialList::iterator end  ) const
00123 #endif   
00124     { 
00125        resample( begin, end ); 
00126     }
00127      
00128 // -- static members --
00129 
00147 #if ! defined(NO_TEMPLATE_MEMBERS)
00148     template< typename Iter >
00149     static 
00150     void resample( Iter begin, Iter end, double sampleInterval );
00151 #else
00152     static inline 
00153     void resample( PartialList::iterator begin, PartialList::iterator end,
00154                   double sampleInterval );
00155 #endif   
00156 
00157 //  --- instance variables ---
00158 private:
00159 
00161     double interval_;   
00162     
00163 };  //  end of class Resampler
00164 
00165 // ---------------------------------------------------------------------------
00166 //  resample (sequence of Partials)
00167 // ---------------------------------------------------------------------------
00183 //
00184 #if ! defined(NO_TEMPLATE_MEMBERS)
00185 template<typename Iter>
00186 void Resampler::resample( Iter begin, Iter end ) const
00187 #else
00188 inline 
00189 void Resampler::resample( PartialList::iterator begin, PartialList::iterator end  ) const
00190 #endif   
00191 {
00192     while ( begin != end )
00193     {
00194         resample( *begin++ );
00195     }
00196 }
00197 
00198 // ---------------------------------------------------------------------------
00199 //  resample (static)
00200 // ---------------------------------------------------------------------------
00218 //
00219 #if ! defined(NO_TEMPLATE_MEMBERS)
00220 template< typename Iter >
00221 void Resampler::resample( Iter begin, Iter end, double sampleInterval )
00222 #else
00223 inline
00224 void Resampler::resample( PartialList::iterator begin, PartialList::iterator end,
00225                           double sampleInterval )
00226 #endif   
00227 {
00228    Resampler instance( sampleInterval );
00229    instance.resample( begin, end );
00230 }
00231 
00232 }   //  end of namespace Loris
00233 
00234 #endif /* ndef INCLUDE_RESAMPLER_H */
00235 

Generated on Thu Apr 14 22:01:55 2005 for Loris by doxygen 1.3.4