annotate vamp-support/PluginConfiguration.h @ 218:ea8994465322

Rebuild these for capnp v0.6. But it would probably be better at this point not to commit them, as the main reason they are in the repo is because the compiler wasn't available for Visual Studio builds, and that's no longer the case.
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 09 May 2017 11:46:23 +0100
parents ad6025dc0b04
children
rev   line source
c@97 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@97 2
c@97 3 /*
c@97 4 Piper C++
c@97 5
c@97 6 An API for audio analysis and feature extraction plugins.
c@97 7
c@97 8 Centre for Digital Music, Queen Mary, University of London.
c@97 9 Copyright 2006-2016 Chris Cannam and QMUL.
c@97 10
c@97 11 Permission is hereby granted, free of charge, to any person
c@97 12 obtaining a copy of this software and associated documentation
c@97 13 files (the "Software"), to deal in the Software without
c@97 14 restriction, including without limitation the rights to use, copy,
c@97 15 modify, merge, publish, distribute, sublicense, and/or sell copies
c@97 16 of the Software, and to permit persons to whom the Software is
c@97 17 furnished to do so, subject to the following conditions:
c@97 18
c@97 19 The above copyright notice and this permission notice shall be
c@97 20 included in all copies or substantial portions of the Software.
c@97 21
c@97 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@97 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@97 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@97 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
c@97 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@97 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@97 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@97 29
c@97 30 Except as contained in this notice, the names of the Centre for
c@97 31 Digital Music; Queen Mary, University of London; and Chris Cannam
c@97 32 shall not be used in advertising or otherwise to promote the sale,
c@97 33 use or other dealings in this Software without prior written
c@97 34 authorization.
c@97 35 */
c@97 36
c@97 37 #ifndef PIPER_PLUGIN_CONFIGURATION_H
c@97 38 #define PIPER_PLUGIN_CONFIGURATION_H
c@97 39
c@97 40 #include <vamp-hostsdk/Plugin.h>
c@97 41
c@97 42 #include <map>
c@97 43 #include <string>
c@97 44
c@97 45 namespace piper_vamp {
c@97 46
c@97 47 /**
cannam@185 48 * \struct Framing
cannam@185 49 *
cannam@185 50 * A structure bundling the processing step and block size.
cannam@185 51 */
cannam@185 52 struct Framing
cannam@185 53 {
cannam@185 54 Framing() : // invalid by default
cannam@185 55 stepSize(0), blockSize(0) { }
cannam@185 56
cannam@185 57 int stepSize;
cannam@185 58 int blockSize;
cannam@185 59 };
cannam@185 60
cannam@185 61 /**
c@97 62 * \class PluginConfiguration
c@97 63 *
c@97 64 * PluginConfiguration is a structure bundling together data that
c@97 65 * affect the configuration of a plugin: parameter values, programs,
c@97 66 * and initialisation settings. Although an interactive Vamp plugin
c@97 67 * host may configure a plugin in stages, for example to take into
c@97 68 * account that a plugin's preferred step and block size may change
c@97 69 * when its parameters are changed, a batch host or a host supporting
c@97 70 * store and recall of configurations may wish to keep all
c@97 71 * configuration settings together.
c@97 72 */
c@97 73 struct PluginConfiguration
c@97 74 {
c@97 75 PluginConfiguration() : // invalid configuration by default
cannam@185 76 channelCount(0) { }
c@97 77
c@97 78 int channelCount;
cannam@185 79 Framing framing;
c@97 80 typedef std::map<std::string, float> ParameterMap;
c@97 81 ParameterMap parameterValues;
c@97 82 std::string currentProgram;
c@97 83
cannam@187 84 /**
cannam@187 85 * Extract the configuration from the given plugin (without
cannam@187 86 * retaining any persistent reference to the plugin itself).
cannam@187 87 */
c@97 88 static PluginConfiguration
c@97 89 fromPlugin(Vamp::Plugin *p,
c@97 90 int channelCount,
c@97 91 int stepSize,
c@97 92 int blockSize) {
c@97 93
c@97 94 PluginConfiguration c;
c@97 95
c@97 96 c.channelCount = channelCount;
cannam@185 97 c.framing.stepSize = stepSize;
cannam@185 98 c.framing.blockSize = blockSize;
c@97 99
c@97 100 Vamp::PluginBase::ParameterList params = p->getParameterDescriptors();
c@97 101 for (Vamp::PluginBase::ParameterList::const_iterator i = params.begin();
c@97 102 i != params.end(); ++i) {
c@97 103 std::string pid = i->identifier;
c@97 104 c.parameterValues[pid] = p->getParameter(pid);
c@97 105 }
c@97 106
c@97 107 if (!p->getPrograms().empty()) {
c@97 108 c.currentProgram = p->getCurrentProgram();
c@97 109 }
c@97 110
c@97 111 return c;
c@97 112 }
c@97 113 };
c@97 114
c@97 115 }
c@97 116
c@97 117 #endif