Mercurial > hg > vamp-test-plugin
changeset 19:534b001d8e8f
Switch to a feature that permits drawing some conclusions about the input data having arrived in the right order
author | Chris Cannam |
---|---|
date | Wed, 03 Dec 2014 10:40:07 +0000 |
parents | 014cce47e998 |
children | cfff2b6ff0fd |
files | VampTestPlugin.cpp |
diffstat | 1 files changed, 16 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/VampTestPlugin.cpp Tue Dec 02 18:02:36 2014 +0000 +++ b/VampTestPlugin.cpp Wed Dec 03 10:40:07 2014 +0000 @@ -2,10 +2,11 @@ #include "VampTestPlugin.h" +#include <iostream> #include <sstream> #include <cmath> -using std::stringstream; +using namespace std; using Vamp::RealTime; @@ -268,9 +269,9 @@ m_outputNumbers[d.identifier] = n++; list.push_back(d); - d.identifier = "rmss"; - d.name = "RMS of Input Channels"; - d.description = "RMS levels of each input channel"; + d.identifier = "input-summary"; + d.name = "Data derived from inputs"; + d.description = "One-sample-per-step features with n values, where n is the number of input channels. Each feature contains, for each input channel, the first sample value on that channel plus the total number of non-zero samples on that channel"; d.unit = ""; d.hasFixedBinCount = true; d.binCount = m_channels; @@ -306,7 +307,7 @@ static Vamp::Plugin::Feature instant(RealTime r, int i, int n) { - std::stringstream s; + stringstream s; Vamp::Plugin::Feature f; f.hasTimestamp = true; f.timestamp = r; @@ -319,7 +320,7 @@ static Vamp::Plugin::Feature untimedCurveValue(RealTime r, int i, int n) { - std::stringstream s; + stringstream s; Vamp::Plugin::Feature f; f.hasTimestamp = false; f.hasDuration = false; @@ -333,7 +334,7 @@ static Vamp::Plugin::Feature timedCurveValue(RealTime r, int i, int n) { - std::stringstream s; + stringstream s; Vamp::Plugin::Feature f; f.hasTimestamp = true; f.timestamp = r; @@ -348,7 +349,7 @@ static Vamp::Plugin::Feature snappedCurveValue(RealTime r, RealTime sn, int i, int n) { - std::stringstream s; + stringstream s; Vamp::Plugin::Feature f; f.hasTimestamp = true; f.timestamp = r; @@ -363,7 +364,7 @@ static Vamp::Plugin::Feature gridColumn(RealTime r, int i, int n) { - std::stringstream s; + stringstream s; Vamp::Plugin::Feature f; f.hasTimestamp = false; f.hasDuration = false; @@ -379,7 +380,7 @@ static Vamp::Plugin::Feature noteOrRegion(RealTime r, RealTime d, int i, int n) { - std::stringstream s; + stringstream s; Vamp::Plugin::Feature f; f.hasTimestamp = true; f.timestamp = r; @@ -490,14 +491,14 @@ Feature f; for (int c = 0; c < m_channels; ++c) { - float sum = 0.f; + // first value plus number of non-zero values + float sum = inputBuffers[c][0]; for (int i = 0; i < m_blockSize; ++i) { - sum += inputBuffers[c][i] * inputBuffers[c][i]; + if (inputBuffers[c][i] != 0.f) sum += 1; } - float rms = sqrtf(sum / m_blockSize); - f.values.push_back(rms); + f.values.push_back(sum); } - fs[m_outputNumbers["rmss"]].push_back(f); + fs[m_outputNumbers["input-summary"]].push_back(f); return fs; }