Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MFCC - fixes startCoeff #195

Merged
merged 2 commits into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions include/clients/rt/MFCCClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut
{
mMagnitude = FluidTensor<double, 1>(get<kFFT>().maxFrameSize());
mBands = FluidTensor<double, 1>(get<kNBands>().max());
mCoefficients = FluidTensor<double, 1>(get<kNCoefs>().max() + get<kDrop0>());
mCoefficients = FluidTensor<double, 1>(get<kNCoefs>().max() + 1); //adding a spare item to the allocation to pad for has0
audioChannelsIn(1);
controlChannelsOut({1, get<kNCoefs>(), get<kNCoefs>().max()});
setInputLabels({"audio input"});
Expand All @@ -103,16 +103,16 @@ class MFCCClient : public FluidBaseClient, public AudioIn, public ControlOut
nBands, get<kMinFreq>(), get<kMaxFreq>(),
sampleRate()))
{
mMelBands.init(get<kMinFreq>(), get<kMaxFreq>(), get<kNBands>(),
mMelBands.init(get<kMinFreq>(), get<kMaxFreq>(), nBands,
get<kFFT>().frameSize(), sampleRate(),
get<kFFT>().winSize());
mDCT.init(get<kNBands>(), 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<kDrop0>(), 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) {
Expand All @@ -121,22 +121,24 @@ 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<kDrop0>(), nCoefs)); // copying from has0 for nCoefs
output[0](Slice(nCoefs, get<kNCoefs>().max() - nCoefs)).fill(0);
}

index latency() { return get<kFFT>().winSize(); }

void reset()
{
index nBands = get<kNBands>();

mSTFTBufferedProcess.reset();
mMagnitude.resize(get<kFFT>().frameSize());
mBands.resize(get<kNBands>());
mCoefficients.resize(get<kNCoefs>().max() + get<kDrop0>());
mMelBands.init(get<kMinFreq>(), get<kMaxFreq>(), get<kNBands>(),
mBands.resize(nBands);
mCoefficients.resize(get<kNCoefs>().max() + 1); //same as line 79
mMelBands.init(get<kMinFreq>(), get<kMaxFreq>(), nBands,
get<kFFT>().frameSize(), sampleRate(),
get<kFFT>().winSize());
mDCT.init(get<kNBands>(), get<kNCoefs>() + get<kDrop0>());
mDCT.init(nBands, fmin((get<kNCoefs>() + get<kDrop0>()), nBands)); //making sure that we don't ask for more than nBands coeff in case of has0
}

AnalysisSize analysisSettings()
Expand Down