annotate src/vamp-sdk/PluginAdapter.cpp @ 486:42904505a18f

Update MSVC build projects - two solutions, one for plugin SDK and one for host SDK, with each containing the two relevant projects. Default is now release x64.
author Chris Cannam
date Thu, 23 Feb 2017 15:03:29 +0000
parents 59f7c7ae2f64
children df32b473b9b6
rev   line source
cannam@3 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@3 2
cannam@3 3 /*
cannam@3 4 Vamp
cannam@3 5
cannam@3 6 An API for audio analysis and feature extraction plugins.
cannam@3 7
cannam@3 8 Centre for Digital Music, Queen Mary, University of London.
cannam@3 9 Copyright 2006 Chris Cannam.
cannam@3 10
cannam@3 11 Permission is hereby granted, free of charge, to any person
cannam@3 12 obtaining a copy of this software and associated documentation
cannam@3 13 files (the "Software"), to deal in the Software without
cannam@3 14 restriction, including without limitation the rights to use, copy,
cannam@3 15 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@3 16 of the Software, and to permit persons to whom the Software is
cannam@3 17 furnished to do so, subject to the following conditions:
cannam@3 18
cannam@3 19 The above copyright notice and this permission notice shall be
cannam@3 20 included in all copies or substantial portions of the Software.
cannam@3 21
cannam@3 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@3 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@3 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@6 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@3 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@3 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@3 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@3 29
cannam@3 30 Except as contained in this notice, the names of the Centre for
cannam@3 31 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@3 32 shall not be used in advertising or otherwise to promote the sale,
cannam@3 33 use or other dealings in this Software without prior written
cannam@3 34 authorization.
cannam@3 35 */
cannam@3 36
cannam@230 37 #include <vamp-sdk/PluginAdapter.h>
cannam@3 38
cannam@130 39 #include <cstring>
cannam@130 40 #include <cstdlib>
cannam@130 41
Chris@424 42 #if ( VAMP_SDK_MAJOR_VERSION != 2 || VAMP_SDK_MINOR_VERSION != 7 )
cannam@308 43 #error Unexpected version of Vamp SDK header included
cannam@234 44 #endif
cannam@234 45
cannam@234 46
cannam@23 47 //#define DEBUG_PLUGIN_ADAPTER 1
cannam@22 48
cannam@233 49 _VAMP_SDK_PLUGSPACE_BEGIN(PluginAdapter.cpp)
cannam@230 50
cannam@3 51 namespace Vamp {
cannam@3 52
cannam@76 53 class PluginAdapterBase::Impl
cannam@3 54 {
cannam@76 55 public:
cannam@76 56 Impl(PluginAdapterBase *);
cannam@76 57 ~Impl();
cannam@76 58
cannam@76 59 const VampPluginDescriptor *getDescriptor();
cannam@76 60
cannam@76 61 protected:
cannam@76 62 PluginAdapterBase *m_base;
cannam@76 63
cannam@76 64 static VampPluginHandle vampInstantiate(const VampPluginDescriptor *desc,
cannam@167 65 float inputSampleRate);
cannam@76 66
cannam@76 67 static void vampCleanup(VampPluginHandle handle);
cannam@76 68
cannam@76 69 static int vampInitialise(VampPluginHandle handle, unsigned int channels,
cannam@76 70 unsigned int stepSize, unsigned int blockSize);
cannam@76 71
cannam@76 72 static void vampReset(VampPluginHandle handle);
cannam@76 73
cannam@76 74 static float vampGetParameter(VampPluginHandle handle, int param);
cannam@76 75 static void vampSetParameter(VampPluginHandle handle, int param, float value);
cannam@76 76
cannam@76 77 static unsigned int vampGetCurrentProgram(VampPluginHandle handle);
cannam@76 78 static void vampSelectProgram(VampPluginHandle handle, unsigned int program);
cannam@76 79
cannam@76 80 static unsigned int vampGetPreferredStepSize(VampPluginHandle handle);
cannam@76 81 static unsigned int vampGetPreferredBlockSize(VampPluginHandle handle);
cannam@76 82 static unsigned int vampGetMinChannelCount(VampPluginHandle handle);
cannam@76 83 static unsigned int vampGetMaxChannelCount(VampPluginHandle handle);
cannam@76 84
cannam@76 85 static unsigned int vampGetOutputCount(VampPluginHandle handle);
cannam@76 86
cannam@76 87 static VampOutputDescriptor *vampGetOutputDescriptor(VampPluginHandle handle,
cannam@76 88 unsigned int i);
cannam@76 89
cannam@76 90 static void vampReleaseOutputDescriptor(VampOutputDescriptor *desc);
cannam@76 91
cannam@76 92 static VampFeatureList *vampProcess(VampPluginHandle handle,
cannam@76 93 const float *const *inputBuffers,
cannam@76 94 int sec,
cannam@76 95 int nsec);
cannam@76 96
cannam@76 97 static VampFeatureList *vampGetRemainingFeatures(VampPluginHandle handle);
cannam@76 98
cannam@76 99 static void vampReleaseFeatureSet(VampFeatureList *fs);
cannam@76 100
cannam@268 101 void checkOutputMap(Plugin *plugin);
cannam@268 102 void markOutputsChanged(Plugin *plugin);
cannam@268 103
cannam@76 104 void cleanup(Plugin *plugin);
cannam@76 105 unsigned int getOutputCount(Plugin *plugin);
cannam@76 106 VampOutputDescriptor *getOutputDescriptor(Plugin *plugin,
cannam@76 107 unsigned int i);
cannam@76 108 VampFeatureList *process(Plugin *plugin,
cannam@76 109 const float *const *inputBuffers,
cannam@76 110 int sec, int nsec);
cannam@76 111 VampFeatureList *getRemainingFeatures(Plugin *plugin);
cannam@76 112 VampFeatureList *convertFeatures(Plugin *plugin,
cannam@76 113 const Plugin::FeatureSet &features);
cannam@76 114
cannam@76 115 // maps both plugins and descriptors to adapters
cannam@76 116 typedef std::map<const void *, Impl *> AdapterMap;
cannam@76 117 static AdapterMap *m_adapterMap;
cannam@76 118 static Impl *lookupAdapter(VampPluginHandle);
cannam@76 119
cannam@76 120 bool m_populated;
cannam@76 121 VampPluginDescriptor m_descriptor;
cannam@76 122 Plugin::ParameterList m_parameters;
cannam@76 123 Plugin::ProgramList m_programs;
cannam@76 124
cannam@76 125 typedef std::map<Plugin *, Plugin::OutputList *> OutputMap;
cannam@76 126 OutputMap m_pluginOutputs;
cannam@76 127
cannam@76 128 std::map<Plugin *, VampFeatureList *> m_fs;
cannam@76 129 std::map<Plugin *, std::vector<size_t> > m_fsizes;
cannam@76 130 std::map<Plugin *, std::vector<std::vector<size_t> > > m_fvsizes;
cannam@76 131 void resizeFS(Plugin *plugin, int n);
cannam@76 132 void resizeFL(Plugin *plugin, int n, size_t sz);
cannam@76 133 void resizeFV(Plugin *plugin, int n, int j, size_t sz);
cannam@76 134 };
cannam@76 135
cannam@76 136 PluginAdapterBase::PluginAdapterBase()
cannam@76 137 {
cannam@76 138 m_impl = new Impl(this);
cannam@76 139 }
cannam@76 140
cannam@76 141 PluginAdapterBase::~PluginAdapterBase()
cannam@76 142 {
cannam@76 143 delete m_impl;
cannam@3 144 }
cannam@3 145
cannam@3 146 const VampPluginDescriptor *
cannam@3 147 PluginAdapterBase::getDescriptor()
cannam@3 148 {
cannam@76 149 return m_impl->getDescriptor();
cannam@76 150 }
cannam@76 151
cannam@76 152 PluginAdapterBase::Impl::Impl(PluginAdapterBase *base) :
cannam@76 153 m_base(base),
cannam@76 154 m_populated(false)
cannam@76 155 {
cannam@22 156 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 157 std::cerr << "PluginAdapterBase::Impl[" << this << "]::Impl" << std::endl;
cannam@76 158 #endif
cannam@76 159 }
cannam@76 160
cannam@76 161 const VampPluginDescriptor *
cannam@76 162 PluginAdapterBase::Impl::getDescriptor()
cannam@76 163 {
cannam@76 164 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 165 std::cerr << "PluginAdapterBase::Impl[" << this << "]::getDescriptor" << std::endl;
cannam@22 166 #endif
cannam@22 167
cannam@3 168 if (m_populated) return &m_descriptor;
Chris@467 169
cannam@76 170 Plugin *plugin = m_base->createPlugin(48000);
cannam@285 171
cannam@285 172 if (!plugin) {
cannam@285 173 std::cerr << "PluginAdapterBase::Impl::getDescriptor: Failed to create plugin" << std::endl;
cannam@285 174 return 0;
cannam@285 175 }
cannam@3 176
cannam@50 177 if (plugin->getVampApiVersion() != VAMP_API_VERSION) {
cannam@76 178 std::cerr << "Vamp::PluginAdapterBase::Impl::getDescriptor: ERROR: "
cannam@194 179 << "API version " << plugin->getVampApiVersion()
cannam@194 180 << " for\nplugin \"" << plugin->getIdentifier() << "\" "
cannam@194 181 << "differs from version "
cannam@194 182 << VAMP_API_VERSION << " for adapter.\n"
cannam@194 183 << "This plugin is probably linked against a different version of the Vamp SDK\n"
cannam@194 184 << "from the version it was compiled with. It will need to be re-linked correctly\n"
cannam@194 185 << "before it can be used." << std::endl;
cannam@50 186 delete plugin;
cannam@50 187 return 0;
cannam@50 188 }
cannam@50 189
cannam@3 190 m_parameters = plugin->getParameterDescriptors();
cannam@3 191 m_programs = plugin->getPrograms();
cannam@50 192
cannam@50 193 m_descriptor.vampApiVersion = plugin->getVampApiVersion();
cannam@49 194 m_descriptor.identifier = strdup(plugin->getIdentifier().c_str());
cannam@3 195 m_descriptor.name = strdup(plugin->getName().c_str());
cannam@3 196 m_descriptor.description = strdup(plugin->getDescription().c_str());
cannam@3 197 m_descriptor.maker = strdup(plugin->getMaker().c_str());
cannam@3 198 m_descriptor.pluginVersion = plugin->getPluginVersion();
cannam@3 199 m_descriptor.copyright = strdup(plugin->getCopyright().c_str());
cannam@3 200
cannam@3 201 m_descriptor.parameterCount = m_parameters.size();
cannam@3 202 m_descriptor.parameters = (const VampParameterDescriptor **)
cannam@3 203 malloc(m_parameters.size() * sizeof(VampParameterDescriptor));
cannam@7 204
cannam@7 205 unsigned int i;
cannam@3 206
cannam@7 207 for (i = 0; i < m_parameters.size(); ++i) {
cannam@3 208 VampParameterDescriptor *desc = (VampParameterDescriptor *)
cannam@3 209 malloc(sizeof(VampParameterDescriptor));
cannam@49 210 desc->identifier = strdup(m_parameters[i].identifier.c_str());
cannam@3 211 desc->name = strdup(m_parameters[i].name.c_str());
cannam@3 212 desc->description = strdup(m_parameters[i].description.c_str());
cannam@3 213 desc->unit = strdup(m_parameters[i].unit.c_str());
cannam@3 214 desc->minValue = m_parameters[i].minValue;
cannam@3 215 desc->maxValue = m_parameters[i].maxValue;
cannam@3 216 desc->defaultValue = m_parameters[i].defaultValue;
cannam@3 217 desc->isQuantized = m_parameters[i].isQuantized;
cannam@3 218 desc->quantizeStep = m_parameters[i].quantizeStep;
cannam@9 219 desc->valueNames = 0;
cannam@9 220 if (desc->isQuantized && !m_parameters[i].valueNames.empty()) {
cannam@9 221 desc->valueNames = (const char **)
cannam@9 222 malloc((m_parameters[i].valueNames.size()+1) * sizeof(char *));
cannam@9 223 for (unsigned int j = 0; j < m_parameters[i].valueNames.size(); ++j) {
cannam@9 224 desc->valueNames[j] = strdup(m_parameters[i].valueNames[j].c_str());
cannam@9 225 }
cannam@9 226 desc->valueNames[m_parameters[i].valueNames.size()] = 0;
cannam@9 227 }
cannam@3 228 m_descriptor.parameters[i] = desc;
cannam@3 229 }
cannam@3 230
cannam@3 231 m_descriptor.programCount = m_programs.size();
cannam@3 232 m_descriptor.programs = (const char **)
cannam@3 233 malloc(m_programs.size() * sizeof(const char *));
cannam@3 234
cannam@7 235 for (i = 0; i < m_programs.size(); ++i) {
cannam@3 236 m_descriptor.programs[i] = strdup(m_programs[i].c_str());
cannam@3 237 }
cannam@3 238
cannam@3 239 if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
cannam@3 240 m_descriptor.inputDomain = vampFrequencyDomain;
cannam@3 241 } else {
cannam@3 242 m_descriptor.inputDomain = vampTimeDomain;
cannam@3 243 }
cannam@3 244
cannam@3 245 m_descriptor.instantiate = vampInstantiate;
cannam@3 246 m_descriptor.cleanup = vampCleanup;
cannam@3 247 m_descriptor.initialise = vampInitialise;
cannam@3 248 m_descriptor.reset = vampReset;
cannam@3 249 m_descriptor.getParameter = vampGetParameter;
cannam@3 250 m_descriptor.setParameter = vampSetParameter;
cannam@3 251 m_descriptor.getCurrentProgram = vampGetCurrentProgram;
cannam@3 252 m_descriptor.selectProgram = vampSelectProgram;
cannam@3 253 m_descriptor.getPreferredStepSize = vampGetPreferredStepSize;
cannam@3 254 m_descriptor.getPreferredBlockSize = vampGetPreferredBlockSize;
cannam@3 255 m_descriptor.getMinChannelCount = vampGetMinChannelCount;
cannam@3 256 m_descriptor.getMaxChannelCount = vampGetMaxChannelCount;
cannam@3 257 m_descriptor.getOutputCount = vampGetOutputCount;
cannam@3 258 m_descriptor.getOutputDescriptor = vampGetOutputDescriptor;
cannam@3 259 m_descriptor.releaseOutputDescriptor = vampReleaseOutputDescriptor;
cannam@3 260 m_descriptor.process = vampProcess;
cannam@3 261 m_descriptor.getRemainingFeatures = vampGetRemainingFeatures;
cannam@3 262 m_descriptor.releaseFeatureSet = vampReleaseFeatureSet;
cannam@3 263
cannam@13 264 if (!m_adapterMap) {
cannam@13 265 m_adapterMap = new AdapterMap;
cannam@13 266 }
cannam@15 267 (*m_adapterMap)[&m_descriptor] = this;
cannam@3 268
cannam@3 269 delete plugin;
cannam@3 270
cannam@3 271 m_populated = true;
cannam@3 272 return &m_descriptor;
cannam@3 273 }
cannam@3 274
cannam@76 275 PluginAdapterBase::Impl::~Impl()
cannam@3 276 {
cannam@22 277 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 278 std::cerr << "PluginAdapterBase::Impl[" << this << "]::~Impl" << std::endl;
cannam@22 279 #endif
cannam@22 280
cannam@3 281 if (!m_populated) return;
cannam@3 282
cannam@49 283 free((void *)m_descriptor.identifier);
cannam@3 284 free((void *)m_descriptor.name);
cannam@3 285 free((void *)m_descriptor.description);
cannam@3 286 free((void *)m_descriptor.maker);
cannam@3 287 free((void *)m_descriptor.copyright);
cannam@3 288
cannam@3 289 for (unsigned int i = 0; i < m_descriptor.parameterCount; ++i) {
cannam@3 290 const VampParameterDescriptor *desc = m_descriptor.parameters[i];
cannam@49 291 free((void *)desc->identifier);
cannam@3 292 free((void *)desc->name);
cannam@3 293 free((void *)desc->description);
cannam@3 294 free((void *)desc->unit);
cannam@9 295 if (desc->valueNames) {
cannam@9 296 for (unsigned int j = 0; desc->valueNames[j]; ++j) {
cannam@9 297 free((void *)desc->valueNames[j]);
cannam@9 298 }
cannam@9 299 free((void *)desc->valueNames);
cannam@9 300 }
Chris@467 301 free((void *)desc);
cannam@3 302 }
cannam@3 303 free((void *)m_descriptor.parameters);
cannam@3 304
cannam@3 305 for (unsigned int i = 0; i < m_descriptor.programCount; ++i) {
cannam@3 306 free((void *)m_descriptor.programs[i]);
cannam@3 307 }
cannam@3 308 free((void *)m_descriptor.programs);
cannam@3 309
cannam@13 310 if (m_adapterMap) {
cannam@13 311
cannam@13 312 m_adapterMap->erase(&m_descriptor);
cannam@13 313
cannam@13 314 if (m_adapterMap->empty()) {
cannam@13 315 delete m_adapterMap;
cannam@13 316 m_adapterMap = 0;
cannam@13 317 }
cannam@13 318 }
cannam@3 319 }
cannam@3 320
cannam@76 321 PluginAdapterBase::Impl *
cannam@76 322 PluginAdapterBase::Impl::lookupAdapter(VampPluginHandle handle)
cannam@3 323 {
cannam@22 324 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 325 std::cerr << "PluginAdapterBase::Impl::lookupAdapter(" << handle << ")" << std::endl;
cannam@22 326 #endif
cannam@22 327
cannam@13 328 if (!m_adapterMap) return 0;
cannam@13 329 AdapterMap::const_iterator i = m_adapterMap->find(handle);
cannam@13 330 if (i == m_adapterMap->end()) return 0;
cannam@3 331 return i->second;
cannam@3 332 }
cannam@3 333
cannam@3 334 VampPluginHandle
cannam@76 335 PluginAdapterBase::Impl::vampInstantiate(const VampPluginDescriptor *desc,
cannam@268 336 float inputSampleRate)
cannam@3 337 {
cannam@22 338 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 339 std::cerr << "PluginAdapterBase::Impl::vampInstantiate(" << desc << ")" << std::endl;
cannam@22 340 #endif
cannam@22 341
cannam@15 342 if (!m_adapterMap) {
cannam@15 343 m_adapterMap = new AdapterMap();
cannam@15 344 }
cannam@15 345
cannam@15 346 if (m_adapterMap->find(desc) == m_adapterMap->end()) {
cannam@76 347 std::cerr << "WARNING: PluginAdapterBase::Impl::vampInstantiate: Descriptor " << desc << " not in adapter map" << std::endl;
cannam@15 348 return 0;
cannam@15 349 }
cannam@15 350
cannam@76 351 Impl *adapter = (*m_adapterMap)[desc];
cannam@3 352 if (desc != &adapter->m_descriptor) return 0;
cannam@3 353
cannam@76 354 Plugin *plugin = adapter->m_base->createPlugin(inputSampleRate);
cannam@3 355 if (plugin) {
cannam@13 356 (*m_adapterMap)[plugin] = adapter;
cannam@3 357 }
cannam@3 358
cannam@22 359 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 360 std::cerr << "PluginAdapterBase::Impl::vampInstantiate(" << desc << "): returning handle " << plugin << std::endl;
cannam@22 361 #endif
cannam@22 362
cannam@3 363 return plugin;
cannam@3 364 }
cannam@3 365
cannam@3 366 void
cannam@76 367 PluginAdapterBase::Impl::vampCleanup(VampPluginHandle handle)
cannam@3 368 {
cannam@22 369 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 370 std::cerr << "PluginAdapterBase::Impl::vampCleanup(" << handle << ")" << std::endl;
cannam@22 371 #endif
cannam@22 372
cannam@76 373 Impl *adapter = lookupAdapter(handle);
cannam@3 374 if (!adapter) {
cannam@3 375 delete ((Plugin *)handle);
cannam@3 376 return;
cannam@3 377 }
cannam@3 378 adapter->cleanup(((Plugin *)handle));
cannam@3 379 }
cannam@3 380
cannam@3 381 int
cannam@76 382 PluginAdapterBase::Impl::vampInitialise(VampPluginHandle handle,
cannam@268 383 unsigned int channels,
cannam@268 384 unsigned int stepSize,
cannam@268 385 unsigned int blockSize)
cannam@3 386 {
cannam@22 387 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 388 std::cerr << "PluginAdapterBase::Impl::vampInitialise(" << handle << ", " << channels << ", " << stepSize << ", " << blockSize << ")" << std::endl;
cannam@22 389 #endif
cannam@22 390
cannam@268 391 Impl *adapter = lookupAdapter(handle);
cannam@268 392 if (!adapter) return 0;
cannam@268 393 bool result = ((Plugin *)handle)->initialise(channels, stepSize, blockSize);
cannam@268 394 adapter->markOutputsChanged((Plugin *)handle);
cannam@3 395 return result ? 1 : 0;
cannam@3 396 }
cannam@3 397
cannam@3 398 void
cannam@76 399 PluginAdapterBase::Impl::vampReset(VampPluginHandle handle)
cannam@3 400 {
cannam@22 401 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 402 std::cerr << "PluginAdapterBase::Impl::vampReset(" << handle << ")" << std::endl;
cannam@22 403 #endif
cannam@22 404
cannam@3 405 ((Plugin *)handle)->reset();
cannam@3 406 }
cannam@3 407
cannam@3 408 float
cannam@76 409 PluginAdapterBase::Impl::vampGetParameter(VampPluginHandle handle,
cannam@3 410 int param)
cannam@3 411 {
cannam@22 412 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 413 std::cerr << "PluginAdapterBase::Impl::vampGetParameter(" << handle << ", " << param << ")" << std::endl;
cannam@22 414 #endif
cannam@22 415
cannam@76 416 Impl *adapter = lookupAdapter(handle);
cannam@3 417 if (!adapter) return 0.0;
cannam@3 418 Plugin::ParameterList &list = adapter->m_parameters;
cannam@49 419 return ((Plugin *)handle)->getParameter(list[param].identifier);
cannam@3 420 }
cannam@3 421
cannam@3 422 void
cannam@76 423 PluginAdapterBase::Impl::vampSetParameter(VampPluginHandle handle,
cannam@3 424 int param, float value)
cannam@3 425 {
cannam@22 426 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 427 std::cerr << "PluginAdapterBase::Impl::vampSetParameter(" << handle << ", " << param << ", " << value << ")" << std::endl;
cannam@22 428 #endif
cannam@22 429
cannam@76 430 Impl *adapter = lookupAdapter(handle);
cannam@3 431 if (!adapter) return;
cannam@3 432 Plugin::ParameterList &list = adapter->m_parameters;
cannam@49 433 ((Plugin *)handle)->setParameter(list[param].identifier, value);
cannam@268 434 adapter->markOutputsChanged((Plugin *)handle);
cannam@3 435 }
cannam@3 436
cannam@3 437 unsigned int
cannam@76 438 PluginAdapterBase::Impl::vampGetCurrentProgram(VampPluginHandle handle)
cannam@3 439 {
cannam@22 440 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 441 std::cerr << "PluginAdapterBase::Impl::vampGetCurrentProgram(" << handle << ")" << std::endl;
cannam@22 442 #endif
cannam@22 443
cannam@76 444 Impl *adapter = lookupAdapter(handle);
cannam@3 445 if (!adapter) return 0;
cannam@3 446 Plugin::ProgramList &list = adapter->m_programs;
cannam@3 447 std::string program = ((Plugin *)handle)->getCurrentProgram();
cannam@3 448 for (unsigned int i = 0; i < list.size(); ++i) {
cannam@3 449 if (list[i] == program) return i;
cannam@3 450 }
cannam@3 451 return 0;
cannam@3 452 }
cannam@3 453
cannam@3 454 void
cannam@76 455 PluginAdapterBase::Impl::vampSelectProgram(VampPluginHandle handle,
cannam@268 456 unsigned int program)
cannam@3 457 {
cannam@22 458 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 459 std::cerr << "PluginAdapterBase::Impl::vampSelectProgram(" << handle << ", " << program << ")" << std::endl;
cannam@22 460 #endif
cannam@22 461
cannam@76 462 Impl *adapter = lookupAdapter(handle);
cannam@3 463 if (!adapter) return;
cannam@268 464
cannam@3 465 Plugin::ProgramList &list = adapter->m_programs;
cannam@3 466 ((Plugin *)handle)->selectProgram(list[program]);
cannam@268 467
cannam@268 468 adapter->markOutputsChanged((Plugin *)handle);
cannam@3 469 }
cannam@3 470
cannam@3 471 unsigned int
cannam@76 472 PluginAdapterBase::Impl::vampGetPreferredStepSize(VampPluginHandle handle)
cannam@3 473 {
cannam@22 474 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 475 std::cerr << "PluginAdapterBase::Impl::vampGetPreferredStepSize(" << handle << ")" << std::endl;
cannam@22 476 #endif
cannam@22 477
cannam@3 478 return ((Plugin *)handle)->getPreferredStepSize();
cannam@3 479 }
cannam@3 480
cannam@3 481 unsigned int
cannam@76 482 PluginAdapterBase::Impl::vampGetPreferredBlockSize(VampPluginHandle handle)
cannam@3 483 {
cannam@22 484 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 485 std::cerr << "PluginAdapterBase::Impl::vampGetPreferredBlockSize(" << handle << ")" << std::endl;
cannam@22 486 #endif
cannam@22 487
cannam@3 488 return ((Plugin *)handle)->getPreferredBlockSize();
cannam@3 489 }
cannam@3 490
cannam@3 491 unsigned int
cannam@76 492 PluginAdapterBase::Impl::vampGetMinChannelCount(VampPluginHandle handle)
cannam@3 493 {
cannam@22 494 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 495 std::cerr << "PluginAdapterBase::Impl::vampGetMinChannelCount(" << handle << ")" << std::endl;
cannam@22 496 #endif
cannam@22 497
cannam@3 498 return ((Plugin *)handle)->getMinChannelCount();
cannam@3 499 }
cannam@3 500
cannam@3 501 unsigned int
cannam@76 502 PluginAdapterBase::Impl::vampGetMaxChannelCount(VampPluginHandle handle)
cannam@3 503 {
cannam@22 504 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 505 std::cerr << "PluginAdapterBase::Impl::vampGetMaxChannelCount(" << handle << ")" << std::endl;
cannam@22 506 #endif
cannam@22 507
cannam@3 508 return ((Plugin *)handle)->getMaxChannelCount();
cannam@3 509 }
cannam@3 510
cannam@3 511 unsigned int
cannam@76 512 PluginAdapterBase::Impl::vampGetOutputCount(VampPluginHandle handle)
cannam@3 513 {
cannam@22 514 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 515 std::cerr << "PluginAdapterBase::Impl::vampGetOutputCount(" << handle << ")" << std::endl;
cannam@22 516 #endif
cannam@22 517
cannam@76 518 Impl *adapter = lookupAdapter(handle);
cannam@15 519
cannam@15 520 // std::cerr << "vampGetOutputCount: handle " << handle << " -> adapter "<< adapter << std::endl;
cannam@15 521
cannam@3 522 if (!adapter) return 0;
cannam@3 523 return adapter->getOutputCount((Plugin *)handle);
cannam@3 524 }
cannam@3 525
cannam@3 526 VampOutputDescriptor *
cannam@76 527 PluginAdapterBase::Impl::vampGetOutputDescriptor(VampPluginHandle handle,
cannam@268 528 unsigned int i)
cannam@3 529 {
cannam@22 530 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 531 std::cerr << "PluginAdapterBase::Impl::vampGetOutputDescriptor(" << handle << ", " << i << ")" << std::endl;
cannam@22 532 #endif
cannam@22 533
cannam@76 534 Impl *adapter = lookupAdapter(handle);
cannam@15 535
cannam@15 536 // std::cerr << "vampGetOutputDescriptor: handle " << handle << " -> adapter "<< adapter << std::endl;
cannam@15 537
cannam@3 538 if (!adapter) return 0;
cannam@3 539 return adapter->getOutputDescriptor((Plugin *)handle, i);
cannam@3 540 }
cannam@3 541
cannam@3 542 void
cannam@76 543 PluginAdapterBase::Impl::vampReleaseOutputDescriptor(VampOutputDescriptor *desc)
cannam@3 544 {
cannam@22 545 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 546 std::cerr << "PluginAdapterBase::Impl::vampReleaseOutputDescriptor(" << desc << ")" << std::endl;
cannam@22 547 #endif
cannam@22 548
cannam@49 549 if (desc->identifier) free((void *)desc->identifier);
cannam@3 550 if (desc->name) free((void *)desc->name);
cannam@3 551 if (desc->description) free((void *)desc->description);
cannam@3 552 if (desc->unit) free((void *)desc->unit);
cannam@40 553 if (desc->hasFixedBinCount && desc->binNames) {
cannam@40 554 for (unsigned int i = 0; i < desc->binCount; ++i) {
cannam@40 555 if (desc->binNames[i]) {
cannam@40 556 free((void *)desc->binNames[i]);
cannam@40 557 }
cannam@40 558 }
cannam@3 559 }
cannam@9 560 if (desc->binNames) free((void *)desc->binNames);
cannam@3 561 free((void *)desc);
cannam@3 562 }
cannam@3 563
cannam@12 564 VampFeatureList *
cannam@76 565 PluginAdapterBase::Impl::vampProcess(VampPluginHandle handle,
cannam@108 566 const float *const *inputBuffers,
cannam@108 567 int sec,
cannam@108 568 int nsec)
cannam@3 569 {
cannam@22 570 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 571 std::cerr << "PluginAdapterBase::Impl::vampProcess(" << handle << ", " << sec << ", " << nsec << ")" << std::endl;
cannam@22 572 #endif
cannam@22 573
cannam@76 574 Impl *adapter = lookupAdapter(handle);
cannam@3 575 if (!adapter) return 0;
cannam@268 576 return adapter->process((Plugin *)handle, inputBuffers, sec, nsec);
cannam@3 577 }
cannam@3 578
cannam@12 579 VampFeatureList *
cannam@76 580 PluginAdapterBase::Impl::vampGetRemainingFeatures(VampPluginHandle handle)
cannam@3 581 {
cannam@22 582 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 583 std::cerr << "PluginAdapterBase::Impl::vampGetRemainingFeatures(" << handle << ")" << std::endl;
cannam@22 584 #endif
cannam@22 585
cannam@76 586 Impl *adapter = lookupAdapter(handle);
cannam@3 587 if (!adapter) return 0;
cannam@3 588 return adapter->getRemainingFeatures((Plugin *)handle);
cannam@3 589 }
cannam@3 590
cannam@3 591 void
Chris@398 592 PluginAdapterBase::Impl::vampReleaseFeatureSet(VampFeatureList *)
cannam@3 593 {
cannam@22 594 #ifdef DEBUG_PLUGIN_ADAPTER
cannam@76 595 std::cerr << "PluginAdapterBase::Impl::vampReleaseFeatureSet" << std::endl;
cannam@22 596 #endif
cannam@3 597 }
cannam@3 598
cannam@3 599 void
cannam@76 600 PluginAdapterBase::Impl::cleanup(Plugin *plugin)
cannam@3 601 {
cannam@12 602 if (m_fs.find(plugin) != m_fs.end()) {
cannam@12 603 size_t outputCount = 0;
cannam@12 604 if (m_pluginOutputs[plugin]) {
cannam@12 605 outputCount = m_pluginOutputs[plugin]->size();
cannam@12 606 }
Chris@471 607 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@471 608 std::cerr << "PluginAdapterBase::Impl::cleanup: " << outputCount << " output(s)" << std::endl;
Chris@471 609 #endif
cannam@12 610 VampFeatureList *list = m_fs[plugin];
cannam@12 611 for (unsigned int i = 0; i < outputCount; ++i) {
cannam@12 612 for (unsigned int j = 0; j < m_fsizes[plugin][i]; ++j) {
cannam@168 613 if (list[i].features[j].v1.label) {
cannam@168 614 free(list[i].features[j].v1.label);
cannam@12 615 }
cannam@168 616 if (list[i].features[j].v1.values) {
cannam@168 617 free(list[i].features[j].v1.values);
cannam@12 618 }
cannam@12 619 }
cannam@12 620 if (list[i].features) free(list[i].features);
cannam@12 621 }
Chris@467 622 if (list) free((void *)list);
cannam@12 623 m_fs.erase(plugin);
cannam@12 624 m_fsizes.erase(plugin);
cannam@12 625 m_fvsizes.erase(plugin);
cannam@12 626 }
cannam@12 627
cannam@3 628 if (m_pluginOutputs.find(plugin) != m_pluginOutputs.end()) {
cannam@3 629 delete m_pluginOutputs[plugin];
cannam@3 630 m_pluginOutputs.erase(plugin);
cannam@3 631 }
cannam@13 632
cannam@13 633 if (m_adapterMap) {
cannam@13 634 m_adapterMap->erase(plugin);
cannam@13 635
cannam@13 636 if (m_adapterMap->empty()) {
cannam@13 637 delete m_adapterMap;
cannam@13 638 m_adapterMap = 0;
cannam@13 639 }
cannam@13 640 }
cannam@13 641
cannam@3 642 delete ((Plugin *)plugin);
cannam@3 643 }
cannam@3 644
cannam@3 645 void
cannam@76 646 PluginAdapterBase::Impl::checkOutputMap(Plugin *plugin)
cannam@3 647 {
cannam@268 648 OutputMap::iterator i = m_pluginOutputs.find(plugin);
cannam@268 649
cannam@268 650 if (i == m_pluginOutputs.end() || !i->second) {
cannam@268 651
cannam@3 652 m_pluginOutputs[plugin] = new Plugin::OutputList
cannam@3 653 (plugin->getOutputDescriptors());
cannam@268 654
cannam@76 655 // std::cerr << "PluginAdapterBase::Impl::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin " << plugin->getIdentifier() << std::endl;
cannam@3 656 }
cannam@3 657 }
cannam@3 658
cannam@268 659 void
cannam@268 660 PluginAdapterBase::Impl::markOutputsChanged(Plugin *plugin)
cannam@268 661 {
cannam@268 662 OutputMap::iterator i = m_pluginOutputs.find(plugin);
cannam@268 663
cannam@268 664 // std::cerr << "PluginAdapterBase::Impl::markOutputsChanged" << std::endl;
cannam@268 665
cannam@268 666 if (i != m_pluginOutputs.end()) {
cannam@268 667
cannam@268 668 Plugin::OutputList *list = i->second;
cannam@268 669 m_pluginOutputs.erase(i);
cannam@268 670 delete list;
cannam@268 671 }
cannam@268 672 }
cannam@268 673
cannam@3 674 unsigned int
cannam@76 675 PluginAdapterBase::Impl::getOutputCount(Plugin *plugin)
cannam@3 676 {
cannam@3 677 checkOutputMap(plugin);
cannam@268 678
cannam@3 679 return m_pluginOutputs[plugin]->size();
cannam@3 680 }
cannam@3 681
cannam@3 682 VampOutputDescriptor *
cannam@76 683 PluginAdapterBase::Impl::getOutputDescriptor(Plugin *plugin,
cannam@268 684 unsigned int i)
cannam@3 685 {
cannam@3 686 checkOutputMap(plugin);
cannam@268 687
cannam@3 688 Plugin::OutputDescriptor &od =
cannam@3 689 (*m_pluginOutputs[plugin])[i];
cannam@3 690
cannam@3 691 VampOutputDescriptor *desc = (VampOutputDescriptor *)
cannam@3 692 malloc(sizeof(VampOutputDescriptor));
cannam@3 693
cannam@49 694 desc->identifier = strdup(od.identifier.c_str());
cannam@3 695 desc->name = strdup(od.name.c_str());
cannam@3 696 desc->description = strdup(od.description.c_str());
cannam@3 697 desc->unit = strdup(od.unit.c_str());
cannam@9 698 desc->hasFixedBinCount = od.hasFixedBinCount;
cannam@9 699 desc->binCount = od.binCount;
cannam@3 700
cannam@240 701 if (od.hasFixedBinCount && od.binCount > 0
cannam@240 702 // We would like to do "&& !od.binNames.empty()" here -- but we
cannam@240 703 // can't, because it will crash older versions of the host adapter
cannam@240 704 // which try to copy the names across whenever the bin count is
cannam@240 705 // non-zero, regardless of whether they exist or not
cannam@240 706 ) {
cannam@9 707 desc->binNames = (const char **)
cannam@9 708 malloc(od.binCount * sizeof(const char *));
cannam@3 709
cannam@9 710 for (unsigned int i = 0; i < od.binCount; ++i) {
cannam@9 711 if (i < od.binNames.size()) {
cannam@9 712 desc->binNames[i] = strdup(od.binNames[i].c_str());
cannam@7 713 } else {
cannam@9 714 desc->binNames[i] = 0;
cannam@7 715 }
cannam@3 716 }
cannam@7 717 } else {
cannam@9 718 desc->binNames = 0;
cannam@3 719 }
cannam@3 720
cannam@3 721 desc->hasKnownExtents = od.hasKnownExtents;
cannam@3 722 desc->minValue = od.minValue;
cannam@3 723 desc->maxValue = od.maxValue;
cannam@3 724 desc->isQuantized = od.isQuantized;
cannam@3 725 desc->quantizeStep = od.quantizeStep;
cannam@3 726
cannam@3 727 switch (od.sampleType) {
cannam@3 728 case Plugin::OutputDescriptor::OneSamplePerStep:
cannam@3 729 desc->sampleType = vampOneSamplePerStep; break;
cannam@3 730 case Plugin::OutputDescriptor::FixedSampleRate:
cannam@3 731 desc->sampleType = vampFixedSampleRate; break;
cannam@3 732 case Plugin::OutputDescriptor::VariableSampleRate:
cannam@3 733 desc->sampleType = vampVariableSampleRate; break;
cannam@3 734 }
cannam@3 735
cannam@3 736 desc->sampleRate = od.sampleRate;
cannam@192 737 desc->hasDuration = od.hasDuration;
cannam@3 738
cannam@3 739 return desc;
cannam@3 740 }
cannam@3 741
cannam@12 742 VampFeatureList *
cannam@76 743 PluginAdapterBase::Impl::process(Plugin *plugin,
cannam@108 744 const float *const *inputBuffers,
cannam@108 745 int sec, int nsec)
cannam@3 746 {
cannam@76 747 // std::cerr << "PluginAdapterBase::Impl::process" << std::endl;
cannam@3 748 RealTime rt(sec, nsec);
cannam@12 749 checkOutputMap(plugin);
cannam@12 750 return convertFeatures(plugin, plugin->process(inputBuffers, rt));
cannam@3 751 }
cannam@3 752
cannam@12 753 VampFeatureList *
cannam@76 754 PluginAdapterBase::Impl::getRemainingFeatures(Plugin *plugin)
cannam@3 755 {
cannam@76 756 // std::cerr << "PluginAdapterBase::Impl::getRemainingFeatures" << std::endl;
cannam@12 757 checkOutputMap(plugin);
cannam@12 758 return convertFeatures(plugin, plugin->getRemainingFeatures());
cannam@3 759 }
cannam@3 760
cannam@12 761 VampFeatureList *
cannam@76 762 PluginAdapterBase::Impl::convertFeatures(Plugin *plugin,
cannam@167 763 const Plugin::FeatureSet &features)
cannam@3 764 {
cannam@12 765 int lastN = -1;
cannam@3 766
cannam@12 767 int outputCount = 0;
cannam@12 768 if (m_pluginOutputs[plugin]) outputCount = m_pluginOutputs[plugin]->size();
cannam@12 769
cannam@12 770 resizeFS(plugin, outputCount);
cannam@12 771 VampFeatureList *fs = m_fs[plugin];
cannam@3 772
cannam@168 773 // std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: sizeof(Feature) == " << sizeof(Plugin::Feature) << ", sizeof(VampFeature) == " << sizeof(VampFeature) << ", sizeof(VampFeatureList) == " << sizeof(VampFeatureList) << std::endl;
cannam@168 774
cannam@12 775 for (Plugin::FeatureSet::const_iterator fi = features.begin();
cannam@12 776 fi != features.end(); ++fi) {
cannam@3 777
cannam@12 778 int n = fi->first;
cannam@12 779
cannam@76 780 // std::cerr << "PluginAdapterBase::Impl::convertFeatures: n = " << n << std::endl;
cannam@7 781
cannam@12 782 if (n >= int(outputCount)) {
cannam@76 783 std::cerr << "WARNING: PluginAdapterBase::Impl::convertFeatures: Too many outputs from plugin (" << n+1 << ", only should be " << outputCount << ")" << std::endl;
cannam@7 784 continue;
cannam@7 785 }
cannam@7 786
cannam@12 787 if (n > lastN + 1) {
cannam@12 788 for (int i = lastN + 1; i < n; ++i) {
cannam@12 789 fs[i].featureCount = 0;
cannam@12 790 }
cannam@12 791 }
cannam@7 792
cannam@7 793 const Plugin::FeatureList &fl = fi->second;
cannam@7 794
cannam@12 795 size_t sz = fl.size();
cannam@12 796 if (sz > m_fsizes[plugin][n]) resizeFL(plugin, n, sz);
cannam@12 797 fs[n].featureCount = sz;
cannam@12 798
cannam@12 799 for (size_t j = 0; j < sz; ++j) {
cannam@7 800
cannam@76 801 // std::cerr << "PluginAdapterBase::Impl::convertFeatures: j = " << j << std::endl;
cannam@7 802
cannam@168 803 VampFeature *feature = &fs[n].features[j].v1;
cannam@7 804
cannam@7 805 feature->hasTimestamp = fl[j].hasTimestamp;
cannam@7 806 feature->sec = fl[j].timestamp.sec;
cannam@7 807 feature->nsec = fl[j].timestamp.nsec;
cannam@7 808 feature->valueCount = fl[j].values.size();
cannam@7 809
cannam@168 810 VampFeatureV2 *v2 = &fs[n].features[j + sz].v2;
cannam@167 811
cannam@167 812 v2->hasDuration = fl[j].hasDuration;
cannam@167 813 v2->durationSec = fl[j].duration.sec;
cannam@167 814 v2->durationNsec = fl[j].duration.nsec;
cannam@167 815
cannam@12 816 if (feature->label) free(feature->label);
cannam@12 817
cannam@12 818 if (fl[j].label.empty()) {
cannam@12 819 feature->label = 0;
cannam@12 820 } else {
cannam@12 821 feature->label = strdup(fl[j].label.c_str());
cannam@7 822 }
cannam@7 823
cannam@12 824 if (feature->valueCount > m_fvsizes[plugin][n][j]) {
cannam@12 825 resizeFV(plugin, n, j, feature->valueCount);
cannam@12 826 }
cannam@7 827
cannam@7 828 for (unsigned int k = 0; k < feature->valueCount; ++k) {
cannam@76 829 // std::cerr << "PluginAdapterBase::Impl::convertFeatures: k = " << k << std::endl;
cannam@7 830 feature->values[k] = fl[j].values[k];
cannam@3 831 }
cannam@3 832 }
cannam@12 833
cannam@12 834 lastN = n;
cannam@3 835 }
cannam@3 836
cannam@12 837 if (lastN == -1) return 0;
cannam@12 838
cannam@12 839 if (int(outputCount) > lastN + 1) {
cannam@12 840 for (int i = lastN + 1; i < int(outputCount); ++i) {
cannam@12 841 fs[i].featureCount = 0;
cannam@12 842 }
cannam@12 843 }
cannam@3 844
cannam@168 845 // std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: have " << outputCount << " outputs" << std::endl;
cannam@168 846 // for (int i = 0; i < outputCount; ++i) {
cannam@168 847 // std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: output " << i << " has " << fs[i].featureCount << " features" << std::endl;
cannam@168 848 // }
cannam@168 849
cannam@168 850
cannam@3 851 return fs;
cannam@3 852 }
cannam@3 853
cannam@12 854 void
cannam@76 855 PluginAdapterBase::Impl::resizeFS(Plugin *plugin, int n)
cannam@12 856 {
Chris@467 857 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@467 858 std::cerr << "PluginAdapterBase::Impl::resizeFS(" << plugin << ", " << n << ")" << std::endl;
Chris@467 859 #endif
cannam@12 860
cannam@12 861 int i = m_fsizes[plugin].size();
cannam@12 862 if (i >= n) return;
cannam@12 863
Chris@467 864 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@467 865 std::cerr << "resizing from " << i << std::endl;
Chris@467 866 #endif
cannam@12 867
cannam@12 868 m_fs[plugin] = (VampFeatureList *)realloc
cannam@12 869 (m_fs[plugin], n * sizeof(VampFeatureList));
cannam@12 870
cannam@12 871 while (i < n) {
cannam@12 872 m_fs[plugin][i].featureCount = 0;
cannam@12 873 m_fs[plugin][i].features = 0;
cannam@12 874 m_fsizes[plugin].push_back(0);
cannam@12 875 m_fvsizes[plugin].push_back(std::vector<size_t>());
cannam@12 876 i++;
cannam@12 877 }
cannam@12 878 }
cannam@12 879
cannam@12 880 void
cannam@76 881 PluginAdapterBase::Impl::resizeFL(Plugin *plugin, int n, size_t sz)
cannam@12 882 {
Chris@467 883 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@467 884 std::cerr << "PluginAdapterBase::Impl::resizeFL(" << plugin << ", " << n << ", "
Chris@467 885 << sz << ")" << std::endl;
Chris@467 886 #endif
Chris@467 887
cannam@12 888 size_t i = m_fsizes[plugin][n];
cannam@12 889 if (i >= sz) return;
cannam@12 890
Chris@467 891 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@467 892 std::cerr << "resizing from " << i << std::endl;
Chris@467 893 #endif
cannam@12 894
cannam@168 895 m_fs[plugin][n].features = (VampFeatureUnion *)realloc
cannam@168 896 (m_fs[plugin][n].features, 2 * sz * sizeof(VampFeatureUnion));
cannam@167 897
cannam@12 898 while (m_fsizes[plugin][n] < sz) {
cannam@168 899 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.hasTimestamp = 0;
cannam@168 900 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.valueCount = 0;
cannam@168 901 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.values = 0;
cannam@168 902 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.label = 0;
cannam@189 903 m_fs[plugin][n].features[m_fsizes[plugin][n] + sz].v2.hasDuration = 0;
cannam@12 904 m_fvsizes[plugin][n].push_back(0);
cannam@12 905 m_fsizes[plugin][n]++;
cannam@12 906 }
cannam@12 907 }
cannam@12 908
cannam@12 909 void
cannam@76 910 PluginAdapterBase::Impl::resizeFV(Plugin *plugin, int n, int j, size_t sz)
cannam@12 911 {
Chris@467 912 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@467 913 std::cerr << "PluginAdapterBase::Impl::resizeFV(" << plugin << ", " << n << ", "
Chris@467 914 << j << ", " << sz << ")" << std::endl;
Chris@467 915 #endif
Chris@467 916
cannam@12 917 size_t i = m_fvsizes[plugin][n][j];
cannam@12 918 if (i >= sz) return;
cannam@12 919
Chris@467 920 #ifdef DEBUG_PLUGIN_ADAPTER
Chris@467 921 std::cerr << "resizing from " << i << std::endl;
Chris@467 922 #endif
Chris@467 923
cannam@168 924 m_fs[plugin][n].features[j].v1.values = (float *)realloc
cannam@168 925 (m_fs[plugin][n].features[j].v1.values, sz * sizeof(float));
cannam@12 926
cannam@12 927 m_fvsizes[plugin][n][j] = sz;
cannam@12 928 }
cannam@12 929
cannam@76 930 PluginAdapterBase::Impl::AdapterMap *
cannam@76 931 PluginAdapterBase::Impl::m_adapterMap = 0;
cannam@3 932
cannam@3 933 }
cannam@3 934
cannam@233 935 _VAMP_SDK_PLUGSPACE_END(PluginAdapter.cpp)
cannam@230 936