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-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 * 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 // 00045 // Computes a reassigned short-time Fourier spectrum and identifies 00046 // (interpolates) short-time magnitude-spectral peaks. 00047 // 00048 class ReassignedSpectrum 00049 { 00050 // -- instance variables -- 00051 private: 00052 // transforms: 00053 FourierTransform _transform, _ratransform; 00054 00055 // windows: 00056 std::vector< double > _window; 00057 std::vector< std::complex< double > > _rawindow; 00058 00059 // -- public interface -- 00060 public: 00061 // construction: 00062 ReassignedSpectrum( const std::vector< double > & window ); 00063 ~ReassignedSpectrum( void ); 00064 00065 // spectrum computation: 00066 void transform( const double * sampsBegin, const double * pos, const double * sampsEnd ); 00067 00068 // length of the three Fourier transforms: 00069 long size( void ) const { return _transform.size(); } 00070 00071 // peers may need to know about the analysis window 00072 // or about the scale factors in introduces: 00073 const std::vector< double > & window( void ) const { return _window; } 00074 00075 // reassigned spectral data access: 00076 double reassignedFrequency( unsigned long idx ) const; 00077 double reassignedTime( unsigned long idx ) const; 00078 double reassignedPhase( long idx, double fracFreqSample, double timeCorrection ) const; 00079 double reassignedMagnitude( double fracBinNum, long intBinNumber ) const; 00080 00081 const std::complex< double > & operator[]( unsigned long idx ) const 00082 { return _transform[idx]; } 00083 00084 // time and frequency corrections 00085 // at transform sample indices: 00086 double frequencyCorrection( long sample ) const; 00087 double timeCorrection( long sample ) const; 00088 00089 }; // end of class ReassignedSpectrum 00090 00091 } // end of namespace Loris 00092 00093 #endif /* ndef INCLUDE_REASSIGNEDSPECTRUM_H */
1.3.4