summaryrefslogtreecommitdiff
path: root/libs/vamp-plugins/EBUr128.cpp
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-11-03 07:51:39 +0100
committerRobin Gareus <robin@gareus.org>2015-11-03 19:21:32 +0100
commit72ec5e9a0139b6b5eb8debaffd88f0ebd69df501 (patch)
tree9a3abda82cc6e2ed11f96436b4aba79c692eb966 /libs/vamp-plugins/EBUr128.cpp
parent2f7c91c7da3793713482880864dded1a8cf4e820 (diff)
add basic VAMP plugin for EBUr128 analysis
FeatureSet will be extended to report detailed analysis.
Diffstat (limited to 'libs/vamp-plugins/EBUr128.cpp')
-rw-r--r--libs/vamp-plugins/EBUr128.cpp170
1 files changed, 170 insertions, 0 deletions
diff --git a/libs/vamp-plugins/EBUr128.cpp b/libs/vamp-plugins/EBUr128.cpp
new file mode 100644
index 0000000000..1a3b9a401c
--- /dev/null
+++ b/libs/vamp-plugins/EBUr128.cpp
@@ -0,0 +1,170 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Vamp
+
+ An API for audio analysis and feature extraction plugins.
+
+ Centre for Digital Music, Queen Mary, University of London.
+ Copyright 2006 Chris Cannam.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use, copy,
+ modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+#include "EBUr128.h"
+
+using std::string;
+using std::vector;
+using std::cerr;
+using std::endl;
+
+
+VampEBUr128::VampEBUr128(float inputSampleRate)
+ : Plugin(inputSampleRate)
+ , m_stepSize(0)
+{
+}
+
+VampEBUr128::~VampEBUr128()
+{
+}
+
+string
+VampEBUr128::getIdentifier() const
+{
+ return "ebur128";
+}
+
+string
+VampEBUr128::getName() const
+{
+ return "EBU R128 Loudness";
+}
+
+string
+VampEBUr128::getDescription() const
+{
+ return "Loudness measurements according to the EBU Recommendation 128";
+}
+
+string
+VampEBUr128::getMaker() const
+{
+ return "Harrison Consoles";
+}
+
+int
+VampEBUr128::getPluginVersion() const
+{
+ return 2;
+}
+
+string
+VampEBUr128::getCopyright() const
+{
+ return "GPL version 2 or later";
+}
+
+bool
+VampEBUr128::initialise(size_t channels, size_t stepSize, size_t blockSize)
+{
+ if (channels < getMinChannelCount() ||
+ channels > getMaxChannelCount()) return false;
+
+ m_stepSize = std::min(stepSize, blockSize);
+ m_channels = channels;
+
+ ebu.init (m_channels, m_inputSampleRate);
+
+ return true;
+}
+
+void
+VampEBUr128::reset()
+{
+ ebu.reset ();
+}
+
+VampEBUr128::OutputList
+VampEBUr128::getOutputDescriptors() const
+{
+ OutputList list;
+
+ OutputDescriptor zc;
+ zc.identifier = "loundless";
+ zc.name = "Integrated loudness";
+ zc.description = "Integrated loudness";
+ zc.unit = "LUFS";
+ zc.hasFixedBinCount = true;
+ zc.binCount = 0;
+ zc.hasKnownExtents = false;
+ zc.isQuantized = false;
+ zc.sampleType = OutputDescriptor::OneSamplePerStep;
+ list.push_back(zc);
+
+ zc.identifier = "range";
+ zc.name = "Integrated loudness Range";
+ zc.description = "Dynamic Range of the audio";
+ zc.unit = "LU";
+ zc.hasFixedBinCount = true;
+ zc.binCount = 0;
+ zc.hasKnownExtents = false;
+ zc.isQuantized = false;
+ zc.sampleType = OutputDescriptor::OneSamplePerStep;
+ list.push_back(zc);
+
+ return list;
+}
+
+VampEBUr128::FeatureSet
+VampEBUr128::process(const float *const *inputBuffers,
+ Vamp::RealTime timestamp)
+{
+ if (m_stepSize == 0) {
+ cerr << "ERROR: VampEBUr128::process: "
+ << "VampEBUr128 has not been initialised"
+ << endl;
+ return FeatureSet();
+ }
+
+ ebu.integr_start (); // noop if already started
+ ebu.process (m_stepSize, inputBuffers);
+
+ return FeatureSet();
+}
+
+VampEBUr128::FeatureSet
+VampEBUr128::getRemainingFeatures()
+{
+ FeatureSet returnFeatures;
+
+ Feature loudness;
+ loudness.hasTimestamp = false;
+ loudness.values.push_back(ebu.integrated());
+ returnFeatures[0].push_back(loudness);
+
+ Feature range;
+ range.hasTimestamp = false;
+ range.values.push_back(ebu.range_max () - ebu.range_min ());
+ returnFeatures[1].push_back(range);
+
+ return returnFeatures;
+}