|
Loris 1.5
|
00001 #ifndef INCLUDE_SIEVE_H 00002 #define INCLUDE_SIEVE_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-2010 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 * Sieve.h 00026 * 00027 * Definition of class Sieve. 00028 * 00029 * Lippold Haken, 20 Jan 2001 00030 * loris@cerlsoundgroup.org 00031 * 00032 * http://www.cerlsoundgroup.org/Loris/ 00033 * 00034 */ 00035 00036 #include "Distiller.h" // for default fade time and silent time 00037 00038 #if defined(NO_TEMPLATE_MEMBERS) 00039 #include "PartialList.h" 00040 #endif 00041 00042 #include "PartialPtrs.h" 00043 00044 // begin namespace 00045 namespace Loris { 00046 00047 // --------------------------------------------------------------------------- 00048 // class Sieve 00049 // 00068 // 00069 class Sieve 00070 { 00071 // -- instance variables -- 00072 00073 double _fadeTime; 00074 00075 00076 00077 // -- public interface -- 00078 public: 00079 00080 // -- global defaults and constants -- 00081 00082 enum 00083 { 00084 00089 DefaultFadeTimeMs = Distiller::DefaultFadeTimeMs, 00090 00096 DefaultSilentTimeMs = Distiller::DefaultSilentTimeMs 00097 }; 00098 00099 // -- construction -- 00100 00111 explicit Sieve( double partialFadeTime = Sieve::DefaultFadeTimeMs/1000.0 ); 00112 00113 // Use compiler-generated copy, assign, and destroy. 00114 00115 // -- sifting -- 00116 00129 #if ! defined(NO_TEMPLATE_MEMBERS) 00130 template<typename Iter> 00131 void sift( Iter sift_begin, Iter sift_end ); 00132 #else 00133 inline 00134 void sift( PartialList::iterator sift_begin, PartialList::iterator sift_end ); 00135 #endif 00136 00148 #if ! defined(NO_TEMPLATE_MEMBERS) 00149 template< typename Container > 00150 void sift( Container & partials ) 00151 #else 00152 inline 00153 void sift( PartialList & partials ) 00154 #endif 00155 { 00156 sift( partials.begin(), partials.end() ); 00157 } 00158 00159 // -- static members -- 00160 00178 #if ! defined(NO_TEMPLATE_MEMBERS) 00179 template< typename Iter > 00180 static 00181 void sift( Iter sift_begin, Iter sift_end, 00182 double partialFadeTime ); 00183 #else 00184 static inline 00185 void sift( PartialList::iterator sift_begin, PartialList::iterator sift_end, 00186 double partialFadeTime ); 00187 #endif 00188 00189 // -- helper -- 00190 private: 00191 00201 void sift_ptrs( PartialPtrs & ptrs ); 00202 00203 }; // end of class Sieve 00204 00205 // --------------------------------------------------------------------------- 00206 // sift 00207 // --------------------------------------------------------------------------- 00220 #if ! defined(NO_TEMPLATE_MEMBERS) 00221 template< typename Iter > 00222 void Sieve::sift( Iter sift_begin, Iter sift_end ) 00223 #else 00224 inline 00225 void Sieve::sift( PartialList::iterator sift_begin, PartialList::iterator sift_end ) 00226 #endif 00227 { 00228 PartialPtrs ptrs; 00229 fillPartialPtrs( sift_begin, sift_end, ptrs ); 00230 sift_ptrs( ptrs ); 00231 } 00232 00233 // --------------------------------------------------------------------------- 00234 // sift (static) 00235 // --------------------------------------------------------------------------- 00253 #if ! defined(NO_TEMPLATE_MEMBERS) 00254 template< typename Iter > 00255 void Sieve::sift( Iter sift_begin, Iter sift_end, 00256 double partialFadeTime ) 00257 #else 00258 inline 00259 void Sieve::sift( PartialList::iterator sift_begin, PartialList::iterator sift_end, 00260 double partialFadeTime ) 00261 #endif 00262 { 00263 Sieve instance( partialFadeTime ); 00264 instance.sift( sift_begin, sift_end ); 00265 } 00266 00267 } // end of namespace Loris 00268 00269 #endif /* ndef INCLUDE_SIEVE_H */