comparison host/vamp-simple-host.cpp @ 47:be8fdfe25693

* Change input buffers arg to process from float ** to const float *const * to avoid plugins modifying their input data * Some improvements to comments * Fix stupidity in frequency-domain input passing (there are n/2+1 values, not n/2)
author cannam
date Fri, 08 Dec 2006 17:39:32 +0000
parents 2858c897d90f
children aa64a46320d4
comparison
equal deleted inserted replaced
46:2858c897d90f 47:be8fdfe25693
247 247
248 int channels = sfinfo.channels; 248 int channels = sfinfo.channels;
249 249
250 float *filebuf = new float[blockSize * channels]; 250 float *filebuf = new float[blockSize * channels];
251 float **plugbuf = new float*[channels]; 251 float **plugbuf = new float*[channels];
252 for (int c = 0; c < channels; ++c) plugbuf[c] = new float[blockSize]; 252 for (int c = 0; c < channels; ++c) plugbuf[c] = new float[blockSize + 2];
253 253
254 cerr << "Using block size = " << blockSize << ", step size = " 254 cerr << "Using block size = " << blockSize << ", step size = "
255 << stepSize << endl; 255 << stepSize << endl;
256 256
257 int minch = plugin->getMinChannelCount(); 257 int minch = plugin->getMinChannelCount();
375 perror("Failed to open directory"); 375 perror("Failed to open directory");
376 continue; 376 continue;
377 } 377 }
378 struct dirent *e = 0; 378 struct dirent *e = 0;
379 while ((e = readdir(d))) { 379 while ((e = readdir(d))) {
380 if (!(e->d_type & DT_REG)) continue; 380 // cerr << "reading: " << e->d_name << endl;
381 if (!(e->d_type & DT_REG)) {
382 // cerr << e->d_name << ": not a regular file" << endl;
383 continue;
384 }
381 int len = strlen(e->d_name); 385 int len = strlen(e->d_name);
382 if (len < int(strlen(PLUGIN_SUFFIX) + 2) || 386 if (len < int(strlen(PLUGIN_SUFFIX) + 2) ||
383 e->d_name[len - strlen(PLUGIN_SUFFIX) - 1] != '.' || 387 e->d_name[len - strlen(PLUGIN_SUFFIX) - 1] != '.' ||
384 strcmp(e->d_name + len - strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX)) { 388 strcmp(e->d_name + len - strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX)) {
389 // cerr << e->d_name << ": not a library file" << endl;
385 continue; 390 continue;
386 } 391 }
387 char *fp = new char[path[i].length() + len + 3]; 392 char *fp = new char[path[i].length() + len + 3];
388 sprintf(fp, "%s/%s", path[i].c_str(), e->d_name); 393 sprintf(fp, "%s/%s", path[i].c_str(), e->d_name);
389 void *handle = DLOPEN(string(fp), RTLD_LAZY); 394 void *handle = DLOPEN(string(fp), RTLD_LAZY);
395 cerr << "\n " << e->d_name << ":" << endl; 400 cerr << "\n " << e->d_name << ":" << endl;
396 int index = 0; 401 int index = 0;
397 const VampPluginDescriptor *descriptor = 0; 402 const VampPluginDescriptor *descriptor = 0;
398 while ((descriptor = fn(index))) { 403 while ((descriptor = fn(index))) {
399 Vamp::PluginHostAdapter plugin(descriptor, 48000); 404 Vamp::PluginHostAdapter plugin(descriptor, 48000);
400 cerr << " [" << char('A' + index) << "] " 405 char c = char('A' + index);
406 if (c > 'Z') c = char('a' + (index - 26));
407 cerr << " [" << c << "] "
401 << plugin.getDescription() 408 << plugin.getDescription()
402 << ", \"" << plugin.getName() << "\"" 409 << ", \"" << plugin.getName() << "\""
403 << " [" << plugin.getMaker() 410 << " [" << plugin.getMaker()
404 << "]" << std::endl; 411 << "]" << std::endl;
405 Vamp::Plugin::OutputList outputs = 412 Vamp::Plugin::OutputList outputs =
412 << endl; 419 << endl;
413 } 420 }
414 } 421 }
415 ++index; 422 ++index;
416 } 423 }
424 } else {
425 // cerr << e->d_name << ": no Vamp descriptor function" << endl;
417 } 426 }
418 DLCLOSE(handle); 427 DLCLOSE(handle);
419 } 428 } else {
429 cerr << "\n" << e->d_name << ": unable to load library (" << DLERROR() << ")" << endl;
430 }
420 } 431 }
421 closedir(d); 432 closedir(d);
422 } 433 }
423 cerr << endl; 434 cerr << endl;
424 } 435 }
460 inbuf[i + size/2] = temp; 471 inbuf[i + size/2] = temp;
461 } 472 }
462 473
463 fft(size, false, inbuf, inbuf + size, outbuf, outbuf + size); 474 fft(size, false, inbuf, inbuf + size, outbuf, outbuf + size);
464 475
465 for (size_t i = 0; i < size/2; ++i) { 476 for (size_t i = 0; i <= size/2; ++i) {
466 buffer[i * 2] = outbuf[i]; 477 buffer[i * 2] = outbuf[i];
467 buffer[i * 2 + 1] = outbuf[i + size]; 478 buffer[i * 2 + 1] = outbuf[i + size];
468 } 479 }
469 480
470 delete[] inbuf; 481 delete[] inbuf;