diff --git a/include/clients/rt/MFCCClient.hpp b/include/clients/rt/MFCCClient.hpp index fea91451f..830cad669 100644 --- a/include/clients/rt/MFCCClient.hpp +++ b/include/clients/rt/MFCCClient.hpp @@ -76,7 +76,7 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut { mMagnitude = FluidTensor(get().maxFrameSize()); mBands = FluidTensor(get().max()); - mCoefficients = FluidTensor(get().max() + get()); + mCoefficients = FluidTensor(get().max() + 1); //adding a spare item to the allocation to pad for has0 audioChannelsIn(1); controlChannelsOut({1, get(), get().max()}); setInputLabels({"audio input"}); @@ -103,16 +103,16 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut nBands, get(), get(), sampleRate())) { - mMelBands.init(get(), get(), get(), + mMelBands.init(get(), get(), nBands, get().frameSize(), sampleRate(), get().winSize()); - mDCT.init(get(), nCoefs + !has0); + mDCT.init(nBands, fmin(nCoefs + !has0, nBands)); //making sure that we don't ask for more than nBands coeff in case of has0 controlChannelsOut({1, nCoefs}); } auto mags = mMagnitude(Slice(0,frameSize)); auto bands = mBands(Slice(0,nBands)); - auto coefs = mCoefficients(Slice(get(), nCoefs)); + auto coefs = mCoefficients(Slice(0, fmin(nCoefs + !has0, nBands))); //making sure that we don't ask for more than nBands coeff in case of has0 mSTFTBufferedProcess.processInput( mParams, input, c, [&](ComplexMatrixView in) { @@ -121,7 +121,7 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut mDCT.processFrame(bands, coefs); }); - output[0](Slice(0, nCoefs)) <<= coefs; + output[0](Slice(0, nCoefs)) <<= mCoefficients(Slice(get(), nCoefs)); // copying from has0 for nCoefs output[0](Slice(nCoefs, get().max() - nCoefs)).fill(0); } @@ -129,14 +129,16 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut void reset() { + index nBands = get(); + mSTFTBufferedProcess.reset(); mMagnitude.resize(get().frameSize()); - mBands.resize(get()); - mCoefficients.resize(get().max() + get()); - mMelBands.init(get(), get(), get(), + mBands.resize(nBands); + mCoefficients.resize(get().max() + 1); //same as line 79 + mMelBands.init(get(), get(), nBands, get().frameSize(), sampleRate(), get().winSize()); - mDCT.init(get(), get() + get()); + mDCT.init(nBands, fmin((get() + get()), nBands)); //making sure that we don't ask for more than nBands coeff in case of has0 } AnalysisSize analysisSettings()