Skip to content
Closed
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions include/algorithms/public/CepstrumF0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ class CepstrumF0

void init(index size)
{
// avoid allocation of maxSize^2 at constructor
mDCT = DCT(size, size);
// avoid allocation of maxSize^2 at constructor, but don't reallocate if not needed

if (mDCT.maxOutputSize() < size || mDCT.maxInputSize() < size)
mDCT = DCT(size, size);

mDCT.init(size, size);

mCepstrum = mCepstrumStorage.segment(0, size);
Expand Down
17 changes: 15 additions & 2 deletions include/algorithms/public/DCT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class DCT
using MatrixXd = Eigen::MatrixXd;

DCT(index maxInputSize, index maxOutputSize)
: mMaxInputSize(maxInputSize)
, mMaxOutputSize(maxOutputSize)
{
mTableStorage = MatrixXd::Zero(maxOutputSize, maxInputSize);
}
Expand All @@ -36,6 +38,11 @@ class DCT
{
using namespace std;
assert(inputSize >= outputSize);
assert(inputSize <= mMaxInputSize);
assert(outputSize <= mMaxOutputSize);
// Exit if already initialised
if (mInputSize == inputSize && mOutputSize == outputSize)
return;
mInputSize = inputSize;
mOutputSize = outputSize;
mTable = mTableStorage.block(0, 0, mOutputSize, mInputSize);
Expand All @@ -61,8 +68,14 @@ class DCT
{
output = (mTable * input.matrix()).array();
}
index mInputSize{40};
index mOutputSize{13};

index maxInputSize() const { return mMaxInputSize; }
index maxOutputSize() const { return mMaxOutputSize; }

index mInputSize{0};
index mOutputSize{0};
index mMaxInputSize{0};
index mMaxOutputSize{0};
MatrixXd mTable;
MatrixXd mTableStorage;
};
Expand Down
2 changes: 1 addition & 1 deletion include/clients/rt/PitchClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class PitchClient : public FluidBaseClient, public AudioIn, public ControlOut
return { get<kFFT>().winSize(), get<kFFT>().hopSize() };
}

void reset()
void reset()
{
mSTFTBufferedProcess.reset();
cepstrumF0.init(get<kFFT>().frameSize());
Expand Down