comparison vamp-server/simple-server.cpp @ 271:776175b737ad

When the input domain is FrequencyDomain, the caller is expected to pass in the frequency-domain input - which means they need the additional values for DC and Nyquist. So check this and refuse if absent
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 17 Oct 2018 15:18:42 +0100
parents 853aeab95acf
children 50e3c02c11cc
comparison
equal deleted inserted replaced
270:60ff32818c30 271:776175b737ad
518 if (channels != mapper.getChannelCount(h)) { 518 if (channels != mapper.getChannelCount(h)) {
519 throw runtime_error("wrong number of channels supplied to process"); 519 throw runtime_error("wrong number of channels supplied to process");
520 } 520 }
521 521
522 const float **fbuffers = new const float *[channels]; 522 const float **fbuffers = new const float *[channels];
523
524 bool frequencyDomain =
525 (preq.plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain);
526 int blockSize = mapper.getBlockSize(h);
527 int inputBufferSize;
528 if (frequencyDomain) {
529 inputBufferSize = 2 * (blockSize / 2) + 2;
530 } else {
531 inputBufferSize = blockSize;
532 }
533
523 for (int i = 0; i < channels; ++i) { 534 for (int i = 0; i < channels; ++i) {
524 if (int(preq.inputBuffers[i].size()) != mapper.getBlockSize(h)) { 535 if (int(preq.inputBuffers[i].size()) != inputBufferSize) {
525 ostringstream os; 536 ostringstream os;
526 os << "wrong block size supplied to process (" 537 os << "wrong buffer size passed to process call as "
527 << preq.inputBuffers[i].size() 538 << (frequencyDomain ? "frequency" : "time")
528 << ", expecting " << mapper.getBlockSize(h) << ")" << ends; 539 << "-domain input on channel " << i << " with block size "
540 << blockSize << " (expected " << inputBufferSize
541 << " values, obtained " << preq.inputBuffers[i].size()
542 << ")" << ends;
529 delete[] fbuffers; 543 delete[] fbuffers;
530 throw runtime_error(os.str()); 544 throw runtime_error(os.str());
531 } 545 }
532 fbuffers[i] = preq.inputBuffers[i].data(); 546 fbuffers[i] = preq.inputBuffers[i].data();
533 } 547 }