From 5fda001de0a395bceb23d92ad539a47c5de24861 Mon Sep 17 00:00:00 2001 From: g-roma Date: Fri, 26 Nov 2021 18:16:30 +0000 Subject: [PATCH] add chroma feature to NoveltySlice --- include/clients/rt/NoveltySliceClient.hpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/include/clients/rt/NoveltySliceClient.hpp b/include/clients/rt/NoveltySliceClient.hpp index 492c8a67a..7ba4ac948 100644 --- a/include/clients/rt/NoveltySliceClient.hpp +++ b/include/clients/rt/NoveltySliceClient.hpp @@ -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" @@ -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()), FloatParam("threshold", "Threshold", 0.5, Min(0)), @@ -85,7 +87,8 @@ class NoveltySliceClient : public FluidBaseClient, : mParams{p}, mNovelty{get(), get()}, mSTFT{get().winSize(), get().fftSize(), get().hopSize()}, - mMelBands{40, get()}, mLoudness{get()} + mMelBands{40, get()}, + mChroma(12, get()), mLoudness{get()} { audioChannelsIn(1); audioChannelsOut(1); @@ -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().frameSize(), 440, sampleRate()); + nDims = 12; + } + else if (feature == 4) { mLoudness.init(windowSize, sampleRate()); } @@ -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; } @@ -205,6 +218,7 @@ class NoveltySliceClient : public FluidBaseClient, FluidTensor mFeature; algorithm::MelBands mMelBands; algorithm::DCT mDCT{40, 13}; + algorithm::ChromaFilterBank mChroma; algorithm::YINFFT mYinFFT; algorithm::Loudness mLoudness; };