00001 /* 00002 * Copyright (c) 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 _PhaseManagement_ 00023 #define _PhaseManagement_ 00024 00025 #include "OSDefines.hxx" 00026 #include "DataTypes.hxx" 00027 #include "SpectralPeakArray.hxx" 00028 #include "Frame.hxx" 00029 #include "Processing.hxx" 00030 #include "InControl.hxx" 00031 00032 00033 #include "PhaseManagementConfig.hxx" 00034 00035 namespace CLAM 00036 { 00037 /* PhaseManagementConfig moved to PhaseManagementConfig.hxx */ 00045 class PhaseManagement:public Processing 00046 { 00047 public: 00048 00049 PhaseManagement(); 00050 PhaseManagement(PhaseManagementConfig& c); 00051 ~PhaseManagement (); 00052 00053 const char * GetClassName() const {return "PhaseManagement";} 00054 00055 bool Do(void){ return false;} 00056 bool Do(Frame& currentFrame); 00057 00060 bool Do(SpectralPeakArray& in); 00061 00063 bool ConcreteConfigure(const ProcessingConfig&); 00064 00065 const ProcessingConfig &GetConfig() const {return mConfig;} 00066 00067 void Init(); 00068 00069 //Controls 00070 InControlTmpl<PhaseManagement> mCurrentTime; 00071 InControlTmpl<PhaseManagement> mCurrentPitch; 00072 00073 public: 00074 void ResetPhaseAlignment(); 00075 00076 void DoPhaseAlignment (SpectralPeakArray& peakArray); 00077 void DoRandomPhases (SpectralPeakArray& peakArray); 00078 void DoPhaseContinuation(SpectralPeakArray& p); 00079 void SetLastPhasesAndFreqs (SpectralPeakArray& peakArray); 00080 void GenerateRandomPhases(DataArray& a); 00081 00082 00083 00084 00085 private: 00086 double mFrameTime, 00087 mLastPeriodTime, 00088 mNextPeriodTime, 00089 mLastFundFreq; 00090 00091 DataArray mRandomPhase; 00092 SpectralPeakArray mLastPeakArray; 00093 00094 00095 /* private configuration*/ 00096 PhaseManagementConfig mConfig; 00097 00098 00099 }; 00100 00101 } //CLAM namespace 00102 #endif 00103