Loris 1.5

ReassignedSpectrum.h

00001 #ifndef INCLUDE_REASSIGNEDSPECTRUM_H
00002 #define INCLUDE_REASSIGNEDSPECTRUM_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  * ReassignedSpectrum.h
00026  *
00027  * Definition of class Loris::ReassignedSpectrum.
00028  *
00029  * Kelly Fitz, 7 Dec 1999
00030  * loris@cerlsoundgroup.org
00031  *
00032  * http://www.cerlsoundgroup.org/Loris/
00033  *
00034  */
00035 
00036 #include "FourierTransform.h"
00037 #include <vector>
00038 
00039 //  begin namespace
00040 namespace Loris {
00041 
00042 // ---------------------------------------------------------------------------
00043 //  class ReassignedSpectrum
00044 //
00047 //  
00048 class ReassignedSpectrum
00049 {
00050 //  -- public interface --
00051 public:
00054     typedef FourierTransform::size_type size_type;
00055 
00056 //  --- lifecycle ---
00057 
00061     ReassignedSpectrum( const std::vector< double > & window );
00062 
00067     ReassignedSpectrum( const std::vector< double > & window,
00068                         const std::vector< double > & windowDerivative );
00069     
00070     // compiler-generated copy, assign, and destroy are sufficient
00071 
00072 //  --- operations ---
00073 
00090     void transform( const double * sampsBegin, const double * pos, const double * sampsEnd );
00091     
00092 //  --- inquiry ---
00093 
00095     size_type size( void ) const;   
00096 
00100     const std::vector< double > & window( void ) const;
00101     
00102 
00103 //  --- reassigned transform access ---
00104         
00112     double convergence( long idx ) const;
00113 
00119     double reassignedFrequency( long idx ) const;
00120 
00126     double reassignedMagnitude( long idx ) const;
00127 
00135     double reassignedPhase( long idx ) const;   
00136 
00142     double reassignedTime( long idx ) const;
00143 
00144 //  --- reassignment operations ---
00145     
00154     double frequencyCorrection( long sample ) const;
00155 
00162     double timeCorrection( long sample ) const;
00163 
00164 //  --- legacy support ---
00165 
00166     //  These members are deprecated, and included only
00167     //  to support old code. New code should use the
00168     //  corresponding documented members.
00169     //  All of these members are deprecated.
00170     
00171     double reassignedPhase( long idx, double, double ) const
00172         { return reassignedPhase( idx ); }
00173     double reassignedMagnitude( double, long intBinNumber ) const
00174         { return reassignedMagnitude( intBinNumber ); }
00175     
00176     //  subscript operator
00177     //  The signature has changed, can no longer return a reference,
00178     //  but since the reference returned was const, this version should 
00179     //  keep most old code working, if not all.
00180     std::complex< double > operator[]( unsigned long idx ) const;
00181     
00182 private:
00183 
00184 //  -- window building helpers --
00185 
00186     //  Build a pair of complex-valued windows, one having the frequency-ramp 
00187     //  (time-derivative) window in the real part and the time-ramp window in the 
00188     //  imagnary part, and the other having the unmodified window in the real part
00189     //  and, if computing mixed deriviatives, the time-ramp time-derivative window
00190     //  in the imaginary part.
00191     //
00192     //  Input is the unmodified window function.
00193     void buildReassignmentWindows( const std::vector< double > & window );
00194     
00195     //  Build a pair of complex-valued windows, one having the frequency-ramp 
00196     //  (time-derivative) window in the real part and the time-ramp window in the 
00197     //  imagnary part, and the other having the unmodified window in the real part
00198     //  and, if computing mixed deriviatives, the time-ramp time-derivative window
00199     //  in the imaginary part.
00200     //
00201     //  Input is the unmodified window function and its time derivative, so the
00202     //  DFT kludge is unnecessary.
00203     void buildReassignmentWindows( const std::vector< double > & window,
00204                                    const std::vector< double > & windowDerivative );    
00205 
00206 //  -- instance variables --
00207 
00209     FourierTransform mMagnitudeTransform;
00210     
00212     FourierTransform mCorrectionTransform;
00213     
00215     std::vector< double > mWindow;                          //  W(n)
00216     
00219     std::vector< std::complex< double > > mCplxWin_W_Wtd;   //  real W(n), imag nW'(n)
00220 
00223     std::vector< std::complex< double > > mCplxWin_Wd_Wt;   //  real W'(n), imag nW(n)
00224         
00225 };  //  end of class ReassignedSpectrum
00226 
00227 }   //  end of namespace Loris
00228 
00229 #endif /* ndef INCLUDE_REASSIGNEDSPECTRUM_H */
 All Classes Functions Variables Typedefs Enumerator Friends