Spectrum.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef _Spectrum_
00023 #define _Spectrum_
00024 
00025 #include <typeinfo>
00026 #include "Array.hxx"
00027 #include "Complex.hxx"
00028 #include "Polar.hxx"
00029 #include "BPF.hxx"
00030 #include "ProcessingData.hxx"
00031 
00032 namespace CLAM {
00033 
00034 class SpectrumConfig;
00035 
00036 struct SpecTypeFlags;
00037 
00045 class Spectrum : public ProcessingData
00046 {
00047 public:
00048         DYNAMIC_TYPE_USING_INTERFACE (Spectrum, 10, ProcessingData);
00052         DYN_ATTRIBUTE (0, public, EScale, Scale);
00053         DYN_ATTRIBUTE (1, public, TData, SpectralRange);
00054         
00055 private:
00056         DYN_ATTRIBUTE (2, private, int, prSize);
00057         DYN_ATTRIBUTE (3, private, int, prBPFSize);
00058 public:
00059         DYN_ATTRIBUTE (4, public, DataArray, MagBuffer);
00060         DYN_ATTRIBUTE (5, public, DataArray, PhaseBuffer);
00061         DYN_ATTRIBUTE (6, public, Array<Complex>, ComplexArray);
00062         DYN_ATTRIBUTE (7, public, Array<Polar>, PolarArray);
00063         DYN_ATTRIBUTE (8, public, BPF, MagBPF);
00064         DYN_ATTRIBUTE (9, public, BPF, PhaseBPF);
00065 
00066 public:
00067         Spectrum(const SpectrumConfig &newConfig);
00068  
00069         void Configure(const SpectrumConfig &newConfig);
00070 
00078         void GetConfig(SpectrumConfig& c) const;
00079 protected:
00080         void DefaultInit();
00081 
00082 public:
00086         TData GetMag(TIndex pos) const;
00090         TData GetMag(TData freq) const;
00094         TData GetPhase(TIndex pos) const;
00098         TData GetPhase(TData freq) const;
00102         void SetMag(TIndex pos,TData newMag);
00106         void SetMag(TData freq,TData newMag);
00110         void SetPhase(TIndex pos,TData newPhase);
00114         void SetPhase(TData freq,TData newPhase);
00116         void SynchronizeTo(const SpecTypeFlags& tmpFlags);
00118         void SynchronizeTo(const Spectrum& in);
00120         void SynchronizeTo(const SpecTypeFlags& tmpFlags,const Spectrum& in);
00121 
00122 
00123 
00124 // Config shortcut interface.
00125 
00127         int GetSize() const;
00129         void SetSize(int s);
00130 
00137         int GetBPFSize() const;
00144         void SetBPFSize(int s);
00145         
00149         void GetType(SpecTypeFlags& f) const;
00150 
00155         void SetType(const SpecTypeFlags& newFlags);
00156         
00160         void SetTypeSynchronize(const SpecTypeFlags& newFlags);
00161 
00165         void ToDB();
00166         
00170         void ToLinear();
00171 
00172 private:
00173         
00177         void PRSetType(const SpecTypeFlags& tmpFlags,int size,int bpfsize);
00178 
00179 public:
00181         inline TIndex IndexFromFreq(TData freq) const;
00182 
00183 
00184 public:
00185 // Internal converting routines
00187         inline void Complex2Polar() ;
00189         inline void Polar2Complex() ;
00191         inline void Complex2MagPhase() ;
00193         inline void Polar2MagPhase() ;
00195         inline void MagPhase2Polar() ;
00197         inline void MagPhase2Complex() ;
00199         inline void MagPhase2BPF() ;
00201         inline void BPF2MagPhase();
00202 
00203 // Converting routines from a second input spectrum
00205         inline void Complex2Polar(const Spectrum& in) ;
00207         inline void Polar2Complex(const Spectrum& in) ;
00209         inline void Complex2MagPhase(const Spectrum& in) ;
00211         inline void Polar2MagPhase(const Spectrum& in) ;
00213         inline void MagPhase2Polar(const Spectrum& in) ;
00215         inline void MagPhase2Complex(const Spectrum& in) ;
00217         inline void MagPhase2BPF(const Spectrum& in) ;
00219         inline void BPF2MagPhase(const Spectrum& in);
00220 private:
00221 //Low level converting routines
00222         inline void Polar2MagPhase(const Array<Polar>& polarArray,DataArray& magBuffer, DataArray& phaseBuffer);
00223         inline void Complex2MagPhase(const Array<Complex>& complexArray, DataArray& magBuffer, DataArray& phaseBuffer);
00224         inline void MagPhase2Polar(const DataArray& magBuffer,const DataArray& phaseBuffer,Array<Polar>& polarArray);
00225         inline void MagPhase2Complex(const DataArray& magBuffer,const DataArray& phaseBuffer,Array<Complex>& complexArray);
00226         inline void MagPhase2BPF(const DataArray& magBuffer, const DataArray& phaseBuffer, BPF& magBPF, BPF& phaseBPF);
00227         inline void BPF2MagPhase( const BPF& magBPF, const BPF& phaseBPF, DataArray& magBuffer, DataArray& phaseBuffer);
00228 
00229 };
00230 
00231 }; // namespace CLAM
00232 
00233 #endif
00234 
Generated by  doxygen 1.6.3