1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6 An API for audio analysis and feature extraction plugins.
8 Centre for Digital Music, Queen Mary, University of London.
9 Copyright 2006 Chris Cannam.
11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation
13 files (the "Software"), to deal in the Software without
14 restriction, including without limitation the rights to use, copy,
15 modify, merge, publish, distribute, sublicense, and/or sell copies
16 of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 VampEBUr128::VampEBUr128(float inputSampleRate)
41 : Plugin(inputSampleRate)
46 VampEBUr128::~VampEBUr128()
51 VampEBUr128::getIdentifier() const
57 VampEBUr128::getName() const
59 return "EBU R128 Loudness";
63 VampEBUr128::getDescription() const
65 return "Loudness measurements according to the EBU Recommendation 128";
69 VampEBUr128::getMaker() const
71 return "Harrison Consoles";
75 VampEBUr128::getPluginVersion() const
81 VampEBUr128::getCopyright() const
83 return "GPL version 2 or later";
87 VampEBUr128::initialise(size_t channels, size_t stepSize, size_t blockSize)
89 if (channels < getMinChannelCount() ||
90 channels > getMaxChannelCount()) return false;
92 m_stepSize = std::min(stepSize, blockSize);
93 m_channels = channels;
95 ebu.init (m_channels, m_inputSampleRate);
106 VampEBUr128::OutputList
107 VampEBUr128::getOutputDescriptors() const
112 zc.identifier = "loundless";
113 zc.name = "Integrated loudness";
114 zc.description = "Integrated Loudness";
116 zc.hasFixedBinCount = true;
118 zc.hasKnownExtents = false;
119 zc.isQuantized = false;
120 zc.sampleType = OutputDescriptor::OneSamplePerStep;
123 zc.identifier = "range";
124 zc.name = "Integrated Loudness Range";
125 zc.description = "Dynamic Range of the Audio";
127 zc.hasFixedBinCount = true;
129 zc.hasKnownExtents = false;
130 zc.isQuantized = false;
131 zc.sampleType = OutputDescriptor::OneSamplePerStep;
134 zc.identifier = "histogram";
135 zc.name = "Loudness Histogram";
136 zc.description = "Dynamic Range of the audio";
138 zc.hasFixedBinCount = false;
140 zc.hasKnownExtents = false;
141 zc.isQuantized = false;
142 zc.sampleType = OutputDescriptor::OneSamplePerStep;
148 VampEBUr128::FeatureSet
149 VampEBUr128::process(const float *const *inputBuffers,
150 Vamp::RealTime timestamp)
152 if (m_stepSize == 0) {
153 cerr << "ERROR: VampEBUr128::process: "
154 << "VampEBUr128 has not been initialised"
159 ebu.integr_start (); // noop if already started
160 ebu.process (m_stepSize, inputBuffers);
165 VampEBUr128::FeatureSet
166 VampEBUr128::getRemainingFeatures()
168 FeatureSet returnFeatures;
171 loudness.hasTimestamp = false;
172 loudness.values.push_back(ebu.integrated());
173 returnFeatures[0].push_back(loudness);
176 range.hasTimestamp = false;
177 range.values.push_back(ebu.range_max () - ebu.range_min ());
178 returnFeatures[1].push_back(range);
181 hist.hasTimestamp = false;
182 const int * hist_S = ebu.histogram_S();
183 for (int i = 110; i < 650; ++i) {
184 hist.values.push_back(hist_S[i]);
186 returnFeatures[2].push_back(hist);
188 return returnFeatures;