3BandSpectralAM.cxx

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 #include "3BandSpectralAM.hxx"
00023 #include "ProcessingFactory.hxx"
00024 
00025 namespace CLAM
00026 {
00027 namespace Hidden
00028 {
00029         static FactoryRegistrator<ProcessingFactory, ThreeBandAM> regThreeBandAM("ThreeBandAM");
00030 }
00031 
00032 
00033 bool ThreeBandAM::Do(const Spectrum& in, Spectrum& out)
00034 {
00035         if ( !mConfig.GetPreserveOuts() )
00036         {
00037                 out = in; //TODO big cludge for streaming
00038         }
00039         
00040         int spectrumSize = in.GetSize();
00041         
00042         TData spectralResolution = spectrumSize/in.GetSpectralRange();
00043         
00044         mLFOscillator.GetInControl("Pitch").DoControl(mLowPitchCtl.GetLastValue());
00045         mMFOscillator.GetInControl("Pitch").DoControl(mMidPitchCtl.GetLastValue());
00046         mHFOscillator.GetInControl("Pitch").DoControl(mHighPitchCtl.GetLastValue());
00047         
00048         mLFOscillator.GetInControl("Amplitude").DoControl(mModAmplitudeCtl.GetLastValue());
00049         mMFOscillator.GetInControl("Amplitude").DoControl(mModAmplitudeCtl.GetLastValue());
00050         mHFOscillator.GetInControl("Amplitude").DoControl(mModAmplitudeCtl.GetLastValue());
00051         
00052         //kludge: this is not taking into account the possible overlap between windows!!
00053         mLFOscillator.GetInControl("SamplesBetweenCalls").DoControl((spectrumSize-1)/2);
00054         mMFOscillator.GetInControl("SamplesBetweenCalls").DoControl((spectrumSize-1)/2);
00055         mHFOscillator.GetInControl("SamplesBetweenCalls").DoControl((spectrumSize-1)/2);
00056         
00057         
00058         DataArray& oMag = out.GetMagBuffer();
00059         
00060         int lowCutoff = Round(mLowCutoffFreqCtl.GetLastValue()* spectralResolution);
00061         int highCutoff =        Round(mHighCutoffFreqCtl.GetLastValue()* spectralResolution);
00062 
00063         TData modFactorLF,modFactorMF, modFactorHF;
00064         mLFOscillator.Do(modFactorLF);
00065         mMFOscillator.Do(modFactorMF);
00066         mHFOscillator.Do(modFactorHF);
00067         
00068         TData currentGain = 1+modFactorLF;
00069         for(int i = 0; i<spectrumSize; i++)
00070         {
00071                 if(i>highCutoff) 
00072                         currentGain = (1+modFactorHF);
00073                 else if(i>lowCutoff) 
00074                         currentGain = (1+modFactorMF);
00075                 oMag[i] *= currentGain;
00076         }
00077         return true;
00078 }
00079 
00080 
00081 }
00082 

Generated on Tue Jun 19 20:34:52 2007 for CLAM-Development by  doxygen 1.5.2