diff options
| -rwxr-xr-x | vamphost/config.make | 2 | ||||
| -rw-r--r-- | vamphost/src/ofxVamphost.cpp | 42 | ||||
| -rw-r--r-- | vamphost/src/ofxVamphost.h | 10 | ||||
| -rw-r--r-- | vamphost/src/testApp.cpp | 34 | ||||
| -rw-r--r-- | vamphost/src/testApp.h | 2 |
5 files changed, 74 insertions, 16 deletions
diff --git a/vamphost/config.make b/vamphost/config.make index da65b3e..aff87ad 100755 --- a/vamphost/config.make +++ b/vamphost/config.make @@ -11,7 +11,7 @@ OF_ROOT = /home/tim/workspace/openFrameworks # for example search paths like: # USER_CFLAGS = -I src/objects -USER_CFLAGS = -fpermissive +USER_CFLAGS = -fpermissive -std=c++11 # USER_LDFLAGS allows to pass custom flags to the linker diff --git a/vamphost/src/ofxVamphost.cpp b/vamphost/src/ofxVamphost.cpp index 3844c60..4a8ade6 100644 --- a/vamphost/src/ofxVamphost.cpp +++ b/vamphost/src/ofxVamphost.cpp @@ -1,27 +1,53 @@ #include "ofxVamphost.h" using namespace std; +using namespace Vamp; int Vamphost::getRT(){ return rt.msec(); } -int Vamphost::init(const string &soname,const string &id,const int &_channels,const int &_rate,const int &_outputNo,const string &_output){ - //stuff that only happens once + +Vamphost::Vamphost(){ + loader = PluginLoader::getInstance(); + list=loader->listPlugins(); + for (auto p: list) { + cerr<<p<<endl; + } +} + +int Vamphost::init(int whichplugin,const int &_channels,const int &_rate,const int &_outputNo,const string &_output){ + key = list[whichplugin]; + init(_channels,_rate,_outputNo,_output); +} + + +int Vamphost::init(const string &soname,const string &id,const int &_channels,const int &_rate,const int &_outputNo,const string &_output){ + key = loader->composePluginKey(soname, id); + init(_channels,_rate,_outputNo,_output); +} +int Vamphost::init(const int &_channels,const int &_rate,const int &_outputNo,const string &_output){ channels =_channels; rate=_rate; outputNo=_outputNo; output=_output; +} +int Vamphost::init(int whichplugin){ + key = list[whichplugin]; + init(); +} +int Vamphost::init(){ + //stuff that only happens once + features[0.0f]=0; - loader = PluginLoader::getInstance(); - key = loader->composePluginKey(soname, id); - plugin = loader->loadPlugin(key, _rate, PluginLoader::ADAPT_ALL_SAFE); + + + plugin = loader->loadPlugin(key, rate, PluginLoader::ADAPT_ALL_SAFE); if (!plugin) { - cerr << ": ERROR: Failed to load plugin \"" << id - << "\" from library \"" << soname << "\"" << endl; + cerr << ": ERROR: Failed to load plugin \"" << key<< "\"" << endl; return -1; } @@ -165,7 +191,7 @@ void Vamphost::process_frame(float *data,int samples_in_frame){ Plugin::FeatureSet feat=plugin->process(plugbuf, rt); - if (feat[outputNo].size()>0) cerr<<"BEAT"<<endl; + //if (feat[outputNo].size()>0) cerr<<"BEAT"<<endl; for (unsigned int i = 0; i < feat[outputNo].size(); ++i) { features[((float)feat[outputNo][i].timestamp.sec)+(((float)feat[outputNo][i].timestamp.nsec)*.000000001)]=featureNo; diff --git a/vamphost/src/ofxVamphost.h b/vamphost/src/ofxVamphost.h index 2c618eb..245b7ff 100644 --- a/vamphost/src/ofxVamphost.h +++ b/vamphost/src/ofxVamphost.h @@ -21,7 +21,12 @@ using Vamp::HostExt::PluginInputDomainAdapter; class Vamphost{ //can load any vamp analysis plugin and present its data with a unified interface public: + Vamphost(); int init(const std::string &soname,const std::string &id,const int &_channels,const int &_rate,const int &_outputNo=0,const std::string &_output=""); + int init(int whichplugin,const int &_channels,const int &_rate,const int &_outputNo=0,const std::string &_output=""); + int init(const int &_channels,const int &_rate,const int &_outputNo=0,const std::string &_output=""); + int init(int whichplugin); + int init(); void process_frame(float *data,int samples_in_frame); void cleanup(); @@ -33,10 +38,13 @@ class Vamphost{ float avg; int num; int numFeat; + + PluginLoader::PluginKey key; + PluginLoader::PluginKeyList list; private: + PluginLoader *loader; - PluginLoader::PluginKey key; Plugin *plugin; RealTime rt; int channels,bits,samples,rate; diff --git a/vamphost/src/testApp.cpp b/vamphost/src/testApp.cpp index 659ed35..5435f80 100644 --- a/vamphost/src/testApp.cpp +++ b/vamphost/src/testApp.cpp @@ -29,7 +29,9 @@ void testApp::setup() { string soname="vamp-example-plugins.so"; string id="percussiononsets"; - int bufferSize = vamphost.init(soname,id,channels,rate,outputNo); + whichplugin=0; + + int bufferSize = vamphost.init(whichplugin,channels,rate,outputNo); left.assign(bufferSize, 0.0); @@ -48,6 +50,10 @@ void testApp::setup() { ofSetFrameRate(25); + + + + } @@ -154,6 +160,7 @@ ofSetColor(225); ofSetColor(225); string reportString = "buffers received: "+ofToString(bufferCounter)+"\ndraw routines called: "+ofToString(drawCounter)+"\nticks: " + ofToString(soundStream.getTickCount()); reportString +="\nfeatures found: "+ofToString(vamphost.numFeat)+" average signal: "+ofToString(vamphost.avg)+" samples: "+ofToString(vamphost.num); + reportString +=vamphost.key; ofDrawBitmapString(reportString, 32, 589); } @@ -200,12 +207,27 @@ void testApp::exit(){ //-------------------------------------------------------------- void testApp::keyPressed(int key){ - if( key == 's' ){ - soundStream.start(); - } - if( key == 'e' ){ - soundStream.stop(); + switch (key) { + case 's': + case 'S': + soundStream.start(); + break; + case 'e': + case 'E': + soundStream.stop(); + break; + case OF_KEY_UP: + whichplugin=((whichplugin+1)%vamphost.list.size()); + vamphost.cleanup(); + vamphost.init(whichplugin); + break; + case OF_KEY_DOWN: + whichplugin=whichplugin>0?whichplugin-1:vamphost.list.size()-1; + vamphost.cleanup(); + vamphost.init(whichplugin); + break; + } } diff --git a/vamphost/src/testApp.h b/vamphost/src/testApp.h index ad24233..112f697 100644 --- a/vamphost/src/testApp.h +++ b/vamphost/src/testApp.h @@ -35,6 +35,8 @@ public: ofSoundStream soundStream; Vamphost vamphost; + + int whichplugin; }; |
