|
Loris 1.5
|
00001 /* 00002 * This is the Loris C++ Class Library, implementing analysis, 00003 * manipulation, and synthesis of digitized sounds using the Reassigned 00004 * Bandwidth-Enhanced Additive Sound Model. 00005 * 00006 * Loris is Copyright (c) 1999-2010 by Kelly Fitz and Lippold Haken 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 * 00023 * SdifFile.h 00024 * 00025 * Definition of SdifFile class for Partial import and export in Loris. 00026 * 00027 * Kelly Fitz, 8 Jan 2003 00028 * loris@cerlsoundgroup.org 00029 * 00030 * http://www.cerlsoundgroup.org/Loris/ 00031 * 00032 */ 00033 00034 #include "Marker.h" 00035 #include "Partial.h" 00036 #include "PartialList.h" 00037 00038 #include <string> 00039 #include <vector> 00040 00041 // begin namespace 00042 namespace Loris { 00043 00044 // --------------------------------------------------------------------------- 00045 // class SdifFile 00046 // 00096 // 00097 class SdifFile 00098 { 00099 // -- public interface -- 00100 public: 00101 00102 // -- types -- 00103 00105 typedef std::vector< Marker > markers_type; 00106 00108 typedef PartialList partials_type; 00109 00110 // -- construction -- 00111 00114 explicit SdifFile( const std::string & filename ); 00115 00121 #if !defined(NO_TEMPLATE_MEMBERS) 00122 template<typename Iter> 00123 SdifFile( Iter begin_partials, Iter end_partials ); 00124 #else 00125 SdifFile( PartialList::const_iterator begin_partials, 00126 PartialList::const_iterator end_partials ); 00127 #endif 00128 00130 SdifFile( void ); 00131 00132 // copy, assign, and delete are compiler-generated 00133 00134 // -- access -- 00135 00138 markers_type & markers( void ); 00139 00142 const markers_type & markers( void ) const; 00143 00146 partials_type & partials( void ); 00147 00150 const partials_type & partials( void ) const; 00151 // -- mutation -- 00152 00154 void addPartial( const Loris::Partial & p ); 00155 00161 #if !defined(NO_TEMPLATE_MEMBERS) 00162 template<typename Iter> 00163 void addPartials( Iter begin_partials, Iter end_partials ); 00164 #else 00165 void addPartials( PartialList::const_iterator begin_partials, 00166 PartialList::const_iterator end_partials ); 00167 #endif 00168 00169 // -- export -- 00170 00173 void write( const std::string & path ); 00174 00178 void write1TRC( const std::string & path ); 00179 00180 // -- legacy export -- 00181 00191 static void Export( const std::string & filename, 00192 const PartialList & plist, 00193 const bool enhanced = true ); 00194 00195 private: 00196 // -- implementation -- 00197 partials_type partials_; // Partials to store in SDIF format 00198 markers_type markers_; // AIFF Markers 00199 00200 }; // end of class SdifFile 00201 00202 // -- template members -- 00203 00204 // --------------------------------------------------------------------------- 00205 // constructor from Partial range 00206 // --------------------------------------------------------------------------- 00207 // Initialize an instance of SdifFile with copies of the Partials 00208 // on the specified half-open (STL-style) range. 00209 // 00210 // If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts 00211 // only PartialList::const_iterator arguments. 00212 // 00213 #if !defined(NO_TEMPLATE_MEMBERS) 00214 template< typename Iter > 00215 SdifFile::SdifFile( Iter begin_partials, Iter end_partials ) 00216 #else 00217 SdifFile::SdifFile( PartialList::const_iterator begin_partials, 00218 PartialList::const_iterator end_partials ) 00219 #endif 00220 { 00221 addPartials( begin_partials, end_partials ); 00222 } 00223 00224 // --------------------------------------------------------------------------- 00225 // addPartials 00226 // --------------------------------------------------------------------------- 00227 // Add a copy of each Partial on the specified half-open (STL-style) 00228 // range to this SdifFile. 00229 // 00230 // If compiled with NO_TEMPLATE_MEMBERS defined, this member accepts 00231 // only PartialList::const_iterator arguments. 00232 // 00233 #if !defined(NO_TEMPLATE_MEMBERS) 00234 template<typename Iter> 00235 void SdifFile::addPartials( Iter begin_partials, Iter end_partials ) 00236 #else 00237 void SdifFile::addPartials( PartialList::const_iterator begin_partials, 00238 PartialList::const_iterator end_partials ) 00239 #endif 00240 { 00241 partials_.insert( partials_.end(), begin_partials, end_partials ); 00242 } 00243 00244 } // end of namespace Loris 00245