Skip to content

Commit

Permalink
Merge pull request #68 from g-roma/feature/chroma-novelty
Browse files Browse the repository at this point in the history
add chroma feature to NoveltySlice
  • Loading branch information
James Bradbury authored Dec 8, 2021
2 parents e16d3c4 + 5fda001 commit 0f4a37c
Showing 1 changed file with 18 additions and 4 deletions.
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

0 comments on commit 0f4a37c

Please sign in to comment.