SMSPitchShift.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SMSPitchShift_
00024 #define _SMSPitchShift_
00025
00026 #include "InPort.hxx"
00027 #include "OutPort.hxx"
00028 #include "InControl.hxx"
00029 #include "FrameTransformation.hxx"
00030 #include "SpectralEnvelopeExtract.hxx"
00031 #include "SpectralEnvelopeApply.hxx"
00032 #include "FDCombFilter.hxx"
00033 #include "SpectralPeakArray.hxx"
00034 #include "Frame.hxx"
00035
00036 #include "FrameTransformationConfig.hxx"
00037 #include "SegmentTransformationConfig.hxx"
00038
00039
00040 namespace CLAM{
00041
00042
00047 class SMSPitchShift: public FrameTransformation
00048 {
00049 const char *GetClassName() const {return "SMSPitchShift";}
00050
00051 InPort<SpectralPeakArray> mInPeaks;
00052 OutPort<SpectralPeakArray> mOutPeaks;
00053 InPort<Fundamental> mInFundamental;
00054 OutPort<Fundamental> mOutFundamental;
00055 InPort<Spectrum> mInSpectrum;
00056 OutPort<Spectrum> mOutSpectrum;
00057
00058 FloatInControl mIsHarmonic;
00059 FloatInControl mPitchSteps;
00060 public:
00061 SMSPitchShift()
00062 :
00063 mInPeaks("In SpectralPeaks", this),
00064 mOutPeaks("Out SpectralPeaks", this),
00065 mInFundamental("In Fundamental", this),
00066 mOutFundamental("Out Fundamental", this),
00067 mInSpectrum("In Spectrum", this),
00068 mOutSpectrum("Out Spectrum", this),
00069 mIsHarmonic("Harmonic", this),
00070 mPitchSteps("PitchSteps", this),
00071 mIgnoreResidual("IgnoreResidual", this)
00072 {
00073 Configure( SegmentTransformationConfig() );
00074 }
00075
00076 ~SMSPitchShift() {}
00077
00078 bool ConcreteConfigure( const ProcessingConfig& config )
00079 {
00080 mPitchSteps.SetBounds(1,100);
00081 mPitchSteps.SetDefaultValue(1);
00082 mPitchSteps.DoControl(1);
00083
00084 mIgnoreResidual.SetBounds(0.,1.);
00085 mIgnoreResidual.SetDefaultValue(0.);
00086 mIgnoreResidual.DoControl(0.);
00087 return true;
00088 }
00089
00090 bool Do(const SpectralPeakArray& inPeaks,
00091 const Fundamental& inFund,
00092 const Spectrum& inRes,
00093 SpectralPeakArray& outPeaks,
00094 Fundamental& outFund,
00095 Spectrum& outRes);
00096
00097 bool Do(const Frame& in, Frame& out);
00098
00099 bool Do()
00100 {
00101 bool result = Do(mInPeaks.GetData(),
00102 mInFundamental.GetData(),
00103 mInSpectrum.GetData(),
00104 mOutPeaks.GetData(),
00105 mOutFundamental.GetData(),
00106 mOutSpectrum.GetData()
00107 );
00108
00109 mInPeaks.Consume();
00110 mOutPeaks.Produce();
00111 mInFundamental.Consume();
00112 mOutFundamental.Produce();
00113 mInSpectrum.Consume();
00114 mOutSpectrum.Produce();
00115
00116 return result;
00117 }
00118
00119 private:
00120 SpectralEnvelopeExtract mSpectralEnvelopeExtract;
00121 SpectralEnvelopeApply mSpectralEnvelopeApply;
00122 FDCombFilter mFDCombFilter;
00123 Spectrum mSpectralEnvelope;
00124 public:
00128 FloatInControl mIgnoreResidual;
00129 };
00130 }
00131
00132 #endif // _SMSPitchShift_
00133