Mercurial > hg > vamp-live-host
view host/host.cpp @ 1:4342352b8ef3
* run more than one plugin, etc
author | cannam |
---|---|
date | Fri, 20 Oct 2006 15:31:00 +0000 |
parents | a6020bf991cd |
children | 86914ea77b7b |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ #include <vamp-sdk/PluginHostAdapter.h> #include "audioio/BufferingAudioCallbackRecordTarget.h" #include "audioio/AudioRecordSourceFactory.h" #include <iostream> #include <sndfile.h> #include "system/System.h" #include "Processor.h" #include <cmath> #include <cassert> #include <QApplication> #include <QFont> #include <QPushButton> using std::cout; using std::cerr; using std::endl; using std::string; using std::vector; static bool loadPlugin(Processor &processor, QString id); int main(int argc, char **argv) { QApplication application(argc, argv); QFont fn = application.font(); fn.setPointSize(fn.pointSize() + 3); application.setFont(fn); QPushButton *button = new QPushButton("Quit"); QObject::connect(button, SIGNAL(clicked()), &application, SLOT(closeAllWindows())); BufferingAudioCallbackRecordTarget *target = new BufferingAudioCallbackRecordTarget(); AudioCallbackRecordSource *source = AudioRecordSourceFactory::createCallbackRecordSource(target); if (!source) { std::cerr << "ERROR: Failed to create audio record source" << std::endl; return 1; } Processor processor(target); int count = 0; if (loadPlugin(processor, "vamp:vamp-aubio:aubiotempo")) ++count; if (loadPlugin(processor, "vamp:vamp-example-plugins:percussiononsets")) ++count; if (loadPlugin(processor, "vamp:qm-vamp-plugins:qm-tempotracker")) ++count; if (loadPlugin(processor, "vamp:qm-vamp-plugins:qm-chromagram")) ++count; if (loadPlugin(processor, "vamp:vamp-example-plugins:zerocrossing")) ++count; std::cerr << count << " plugin(s) loaded" << std::endl; button->show(); processor.start(); application.exec(); } bool loadPlugin(Processor &processor, QString id) { int n = processor.addPlugin(id); if (n) { std::cerr << "Plugin \"" << id.toStdString() << "\" successfully loaded (index " << n << ")" << std::endl; return true; } else { std::cerr << "Failed to load plugin \"" << id.toStdString() << "\"" << std::endl; return false; } }