# HG changeset patch # User Chris Cannam # Date 1417543356 0 # Node ID 014cce47e998f9fe0c841da005e96af82a0ea126 # Parent ac7f544c7b2093a3cdf37a3ca7f9b139630f9f43 Add an output that returns some actual feature of the input channels (also counting the channels, effectively) diff -r ac7f544c7b20 -r 014cce47e998 VampTestPlugin.cpp --- a/VampTestPlugin.cpp Tue Nov 25 12:00:52 2014 +0000 +++ b/VampTestPlugin.cpp Tue Dec 02 18:02:36 2014 +0000 @@ -3,6 +3,7 @@ #include "VampTestPlugin.h" #include +#include using std::stringstream; @@ -12,6 +13,7 @@ Plugin(inputSampleRate), m_produceOutput(true), m_n(0), + m_channels(1), m_stepSize(0), m_blockSize(0) { @@ -87,7 +89,7 @@ size_t VampTestPlugin::getMaxChannelCount() const { - return 1; + return 10; } VampTestPlugin::ParameterList @@ -266,6 +268,19 @@ 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.unit = ""; + d.hasFixedBinCount = true; + d.binCount = m_channels; + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::OneSamplePerStep; + d.hasDuration = false; + m_outputNumbers[d.identifier] = n++; + list.push_back(d); + return list; } @@ -275,6 +290,7 @@ if (channels < getMinChannelCount() || channels > getMaxChannelCount()) return false; + m_channels = channels; m_stepSize = stepSize; m_blockSize = blockSize; @@ -471,6 +487,18 @@ { if (!m_produceOutput) return FeatureSet(); FeatureSet fs = featuresFrom(timestamp, false); + + Feature f; + for (int c = 0; c < m_channels; ++c) { + float sum = 0.f; + for (int i = 0; i < m_blockSize; ++i) { + sum += inputBuffers[c][i] * inputBuffers[c][i]; + } + float rms = sqrtf(sum / m_blockSize); + f.values.push_back(rms); + } + fs[m_outputNumbers["rmss"]].push_back(f); + return fs; } diff -r ac7f544c7b20 -r 014cce47e998 VampTestPlugin.h --- a/VampTestPlugin.h Tue Nov 25 12:00:52 2014 +0000 +++ b/VampTestPlugin.h Tue Dec 02 18:02:36 2014 +0000 @@ -48,6 +48,7 @@ bool m_produceOutput; int m_n; std::vector m_instants; + int m_channels; int m_stepSize; int m_blockSize; Vamp::RealTime m_lastTime;