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

add chroma feature to NoveltySlice #68

Merged
merged 1 commit into from
Dec 8, 2021
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
22 changes: 18 additions & 4 deletions include/clients/rt/NoveltySliceClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ under the European Union’s Horizon 2020 research and innovation programme
#include "../common/ParameterConstraints.hpp"
#include "../common/ParameterSet.hpp"
#include "../common/ParameterTypes.hpp"
#include "../../algorithms/public/ChromaFilterBank.hpp"
#include "../../algorithms/public/DCT.hpp"
#include "../../algorithms/public/Loudness.hpp"
#include "../../algorithms/public/MelBands.hpp"
Expand Down Expand Up @@ -43,7 +44,8 @@ enum NoveltyParamIndex {
};

constexpr auto NoveltySliceParams = defineParameters(
EnumParam("feature", "Feature", 0, "Spectrum", "MFCC", "Pitch", "Loudness"),
EnumParam("feature", "Feature", 0, "Spectrum", "MFCC", "Chroma", "Pitch",
"Loudness"),
LongParam("kernelSize", "KernelSize", 3, Min(3), Odd(),
UpperLimit<kMaxKernelSize>()),
FloatParam("threshold", "Threshold", 0.5, Min(0)),
Expand Down Expand Up @@ -85,7 +87,8 @@ class NoveltySliceClient : public FluidBaseClient,
: mParams{p}, mNovelty{get<kMaxKernelSize>(), get<kMaxFilterSize>()},
mSTFT{get<kFFT>().winSize(), get<kFFT>().fftSize(),
get<kFFT>().hopSize()},
mMelBands{40, get<kMaxFFTSize>()}, mLoudness{get<kMaxFFTSize>()}
mMelBands{40, get<kMaxFFTSize>()},
mChroma(12, get<kMaxFFTSize>()), mLoudness{get<kMaxFFTSize>()}
{
audioChannelsIn(1);
audioChannelsOut(1);
Expand Down Expand Up @@ -113,7 +116,12 @@ class NoveltySliceClient : public FluidBaseClient,
mDCT.init(40, 13);
nDims = 13;
}
else if (feature == 3)
else if (feature == 2)
{
mChroma.init(12, get<kFFT>().frameSize(), 440, sampleRate());
nDims = 12;
}
else if (feature == 4)
{
mLoudness.init(windowSize, sampleRate());
}
Expand Down Expand Up @@ -165,9 +173,14 @@ class NoveltySliceClient : public FluidBaseClient,
case 2:
mSTFT.processFrame(in.row(0), mSpectrum);
mSTFT.magnitude(mSpectrum, mMagnitude);
mYinFFT.processFrame(mMagnitude, mFeature, 20, 5000, sampleRate());
mChroma.processFrame(mMagnitude, mFeature, 20, 5000);
break;
case 3:
mSTFT.processFrame(in.row(0), mSpectrum);
mSTFT.magnitude(mSpectrum, mMagnitude);
mYinFFT.processFrame(mMagnitude, mFeature, 20, 5000, sampleRate());
break;
case 4:
mLoudness.processFrame(in.row(0), mFeature, true, true);
break;
}
Expand Down Expand Up @@ -205,6 +218,7 @@ class NoveltySliceClient : public FluidBaseClient,
FluidTensor<double, 1> mFeature;
algorithm::MelBands mMelBands;
algorithm::DCT mDCT{40, 13};
algorithm::ChromaFilterBank mChroma;
algorithm::YINFFT mYinFFT;
algorithm::Loudness mLoudness;
};
Expand Down