LinearEnvelope.h

00001 #ifndef INCLUDE_LINEARENVELOPE_H
00002 #define INCLUDE_LINEARENVELOPE_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  * LinearEnvelope.h
00026  *
00027  * Definition of class LinearEnvelope.
00028  *
00029  * Kelly Fitz, 23 April 2005
00030  * loris@cerlsoundgroup.org
00031  *
00032  * http://www.cerlsoundgroup.org/Loris/
00033  *
00034  */
00035 
00036 #include "Envelope.h"
00037 #include <map>
00038 
00039 //  begin namespace
00040 namespace Loris {
00041 
00042 // ---------------------------------------------------------------------------
00043 //  class LinearEnvelope
00044 //
00068 //
00069 class LinearEnvelope : public Envelope, private std::map< double, double >
00070 {
00071 //  -- public interface --
00072 public:
00073 //  -- construction --
00074 
00077     LinearEnvelope( void );
00078 
00085     explicit LinearEnvelope( double initialValue );
00086 
00087     //  compiler-generated copy, assignment, and destruction are OK.
00088     
00089 //  -- Envelope interface --
00090 
00093     virtual LinearEnvelope * clone( void ) const;
00094 
00100     virtual double valueAt( double t ) const;   
00101     
00102 //  -- envelope composition --
00103 
00111     void insert( double time, double value );
00112     
00119     void insertBreakpoint( double time, double value ) 
00120          { insert( time, value ); }
00121          
00122          
00127     LinearEnvelope & operator+=( double offset );
00128 
00133     LinearEnvelope & operator-=( double offset )
00134     {
00135         return operator+=( -offset );
00136     }
00137 
00143     LinearEnvelope & operator*=( double scale );
00144 
00150     LinearEnvelope & operator/=( double div )
00151     {
00152         return operator*=( 1.0 / div );
00153     }
00154 
00155 //  -- interface inherited from std::map --
00156 
00157     using std::map< double, double >::size;
00158     using std::map< double, double >::empty;
00159     using std::map< double, double >::clear;
00160     using std::map< double, double >::begin;
00161     using std::map< double, double >::end;
00162     using std::map< double, double >::size_type;
00163     using std::map< double, double >::value_type;
00164     using std::map< double, double >::iterator;
00165     using std::map< double, double >::const_iterator;
00166 
00167 };  //  end of class LinearEnvelope
00168 
00169 
00170 //  --  binary operators (inline nonmembers) --
00171 
00174 inline
00175 LinearEnvelope operator+( LinearEnvelope env, double offset )
00176 {
00177     env += offset;
00178     return env;
00179 }
00180 
00183 inline
00184 LinearEnvelope operator+( double offset, LinearEnvelope env )
00185 {
00186     env += offset;
00187     return env;
00188 }
00189 
00192 inline
00193 LinearEnvelope operator-( LinearEnvelope env, double offset )
00194 {
00195     env -= offset;
00196     return env;
00197 }
00198 
00201 inline
00202 LinearEnvelope operator-( double offset, LinearEnvelope env )
00203 {
00204     env *= -1.0;
00205     env += offset;
00206     return env;
00207 }
00208 
00211 inline
00212 LinearEnvelope operator*( LinearEnvelope env, double scale )
00213 {
00214     env *= scale;
00215     return env;
00216 }
00217 
00220 inline
00221 LinearEnvelope operator*( double scale, LinearEnvelope env )
00222 {
00223     env *= scale;
00224     return env;
00225 }
00226 
00229 inline
00230 LinearEnvelope operator/( LinearEnvelope env, double div )
00231 {
00232     env /= div;
00233     return env;
00234 }
00235 
00239 LinearEnvelope operator/( double scale, LinearEnvelope env );
00240 
00241 
00242 }   //  end of namespace Loris
00243 
00244 #endif /* ndef INCLUDE_LINEARENVELOPE_H */

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