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 typedef PhaseManagementConfig Config; 00049 PhaseManagement(const PhaseManagementConfig& c = Config()); 00050 ~PhaseManagement (); 00051 00052 const char * GetClassName() const {return "PhaseManagement";} 00053 00054 bool Do(){ return false;} 00055 bool Do(Frame& currentFrame); 00056 00059 bool Do(SpectralPeakArray& in); 00060 00062 bool ConcreteConfigure(const ProcessingConfig&); 00063 00064 const ProcessingConfig &GetConfig() const {return mConfig;} 00065 00066 void Init(); 00067 00068 //Controls 00069 FloatInControl mCurrentTime; 00070 FloatInControl mCurrentPitch; 00071 00072 public: 00073 void ResetPhaseAlignment(); 00074 00075 void DoPhaseAlignment (SpectralPeakArray& peakArray); 00076 void DoRandomPhases (SpectralPeakArray& peakArray); 00077 void DoPhaseContinuation(SpectralPeakArray& p); 00078 void SetLastPhasesAndFreqs (SpectralPeakArray& peakArray); 00079 void GenerateRandomPhases(DataArray& a); 00080 00081 00082 00083 00084 private: 00085 double mFrameTime, 00086 mLastPeriodTime, 00087 mNextPeriodTime, 00088 mLastFundFreq; 00089 00090 DataArray mRandomPhase; 00091 SpectralPeakArray mLastPeakArray; 00092 00093 00094 /* private configuration*/ 00095 PhaseManagementConfig mConfig; 00096 00097 00098 }; 00099 00100 } //CLAM namespace 00101 #endif 00102