Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/PluginAdapter.cpp @ 9:44113b1e296b
* Add valueNames to parameter descriptor
* Change valueCount and valueNames to binCount and binNames in output
descriptor, to avoid confusion with other uses of value
* Some explanatory notes about FFT alignment
author | cannam |
---|---|
date | Wed, 05 Apr 2006 16:50:07 +0000 |
parents | c66551966b5f |
children | a3d35e11c3fe |
comparison
equal
deleted
inserted
replaced
8:c4662bbef275 | 9:44113b1e296b |
---|---|
74 desc->minValue = m_parameters[i].minValue; | 74 desc->minValue = m_parameters[i].minValue; |
75 desc->maxValue = m_parameters[i].maxValue; | 75 desc->maxValue = m_parameters[i].maxValue; |
76 desc->defaultValue = m_parameters[i].defaultValue; | 76 desc->defaultValue = m_parameters[i].defaultValue; |
77 desc->isQuantized = m_parameters[i].isQuantized; | 77 desc->isQuantized = m_parameters[i].isQuantized; |
78 desc->quantizeStep = m_parameters[i].quantizeStep; | 78 desc->quantizeStep = m_parameters[i].quantizeStep; |
79 desc->valueNames = 0; | |
80 if (desc->isQuantized && !m_parameters[i].valueNames.empty()) { | |
81 desc->valueNames = (const char **) | |
82 malloc((m_parameters[i].valueNames.size()+1) * sizeof(char *)); | |
83 for (unsigned int j = 0; j < m_parameters[i].valueNames.size(); ++j) { | |
84 desc->valueNames[j] = strdup(m_parameters[i].valueNames[j].c_str()); | |
85 } | |
86 desc->valueNames[m_parameters[i].valueNames.size()] = 0; | |
87 } | |
79 m_descriptor.parameters[i] = desc; | 88 m_descriptor.parameters[i] = desc; |
80 } | 89 } |
81 | 90 |
82 m_descriptor.programCount = m_programs.size(); | 91 m_descriptor.programCount = m_programs.size(); |
83 m_descriptor.programs = (const char **) | 92 m_descriptor.programs = (const char **) |
132 for (unsigned int i = 0; i < m_descriptor.parameterCount; ++i) { | 141 for (unsigned int i = 0; i < m_descriptor.parameterCount; ++i) { |
133 const VampParameterDescriptor *desc = m_descriptor.parameters[i]; | 142 const VampParameterDescriptor *desc = m_descriptor.parameters[i]; |
134 free((void *)desc->name); | 143 free((void *)desc->name); |
135 free((void *)desc->description); | 144 free((void *)desc->description); |
136 free((void *)desc->unit); | 145 free((void *)desc->unit); |
146 if (desc->valueNames) { | |
147 for (unsigned int j = 0; desc->valueNames[j]; ++j) { | |
148 free((void *)desc->valueNames[j]); | |
149 } | |
150 free((void *)desc->valueNames); | |
151 } | |
137 } | 152 } |
138 free((void *)m_descriptor.parameters); | 153 free((void *)m_descriptor.parameters); |
139 | 154 |
140 for (unsigned int i = 0; i < m_descriptor.programCount; ++i) { | 155 for (unsigned int i = 0; i < m_descriptor.programCount; ++i) { |
141 free((void *)m_descriptor.programs[i]); | 156 free((void *)m_descriptor.programs[i]); |
285 PluginAdapterBase::vampReleaseOutputDescriptor(VampOutputDescriptor *desc) | 300 PluginAdapterBase::vampReleaseOutputDescriptor(VampOutputDescriptor *desc) |
286 { | 301 { |
287 if (desc->name) free((void *)desc->name); | 302 if (desc->name) free((void *)desc->name); |
288 if (desc->description) free((void *)desc->description); | 303 if (desc->description) free((void *)desc->description); |
289 if (desc->unit) free((void *)desc->unit); | 304 if (desc->unit) free((void *)desc->unit); |
290 for (unsigned int i = 0; i < desc->valueCount; ++i) { | 305 for (unsigned int i = 0; i < desc->binCount; ++i) { |
291 free((void *)desc->valueNames[i]); | 306 free((void *)desc->binNames[i]); |
292 } | 307 } |
293 if (desc->valueNames) free((void *)desc->valueNames); | 308 if (desc->binNames) free((void *)desc->binNames); |
294 free((void *)desc); | 309 free((void *)desc); |
295 } | 310 } |
296 | 311 |
297 VampFeatureList ** | 312 VampFeatureList ** |
298 PluginAdapterBase::vampProcess(VampPluginHandle handle, | 313 PluginAdapterBase::vampProcess(VampPluginHandle handle, |
373 malloc(sizeof(VampOutputDescriptor)); | 388 malloc(sizeof(VampOutputDescriptor)); |
374 | 389 |
375 desc->name = strdup(od.name.c_str()); | 390 desc->name = strdup(od.name.c_str()); |
376 desc->description = strdup(od.description.c_str()); | 391 desc->description = strdup(od.description.c_str()); |
377 desc->unit = strdup(od.unit.c_str()); | 392 desc->unit = strdup(od.unit.c_str()); |
378 desc->hasFixedValueCount = od.hasFixedValueCount; | 393 desc->hasFixedBinCount = od.hasFixedBinCount; |
379 desc->valueCount = od.valueCount; | 394 desc->binCount = od.binCount; |
380 | 395 |
381 if (od.valueCount > 0) { | 396 if (od.hasFixedBinCount && od.binCount > 0) { |
382 desc->valueNames = (const char **) | 397 desc->binNames = (const char **) |
383 malloc(od.valueCount * sizeof(const char *)); | 398 malloc(od.binCount * sizeof(const char *)); |
384 | 399 |
385 for (unsigned int i = 0; i < od.valueCount; ++i) { | 400 for (unsigned int i = 0; i < od.binCount; ++i) { |
386 if (i < od.valueNames.size()) { | 401 if (i < od.binNames.size()) { |
387 desc->valueNames[i] = strdup(od.valueNames[i].c_str()); | 402 desc->binNames[i] = strdup(od.binNames[i].c_str()); |
388 } else { | 403 } else { |
389 desc->valueNames[i] = 0; | 404 desc->binNames[i] = 0; |
390 } | 405 } |
391 } | 406 } |
392 } else { | 407 } else { |
393 desc->valueNames = 0; | 408 desc->binNames = 0; |
394 } | 409 } |
395 | 410 |
396 desc->hasKnownExtents = od.hasKnownExtents; | 411 desc->hasKnownExtents = od.hasKnownExtents; |
397 desc->minValue = od.minValue; | 412 desc->minValue = od.minValue; |
398 desc->maxValue = od.maxValue; | 413 desc->maxValue = od.maxValue; |