diff options
Diffstat (limited to 'rotord/src/vampHost.cpp')
| -rw-r--r-- | rotord/src/vampHost.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/rotord/src/vampHost.cpp b/rotord/src/vampHost.cpp index c1340f2..2ddc62f 100644 --- a/rotord/src/vampHost.cpp +++ b/rotord/src/vampHost.cpp @@ -275,6 +275,10 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_ return false; } + cerr << "Vamphost Plugin initialised: (channels = " << channels + << ", stepSize = " << stepSize << ", blockSize = " + << blockSize << ")" << endl; + wrapper = dynamic_cast<PluginWrapper *>(plugin); if (wrapper) { // See documentation for @@ -294,6 +298,7 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_ return true; } void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){ + int sample=0; uint16_t *_data=(uint16_t*)data; @@ -317,17 +322,25 @@ void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){ //I /think/ that the vamp plugin keeps processing through the plugbuf until it encounters 0s rt = RealTime::frame2RealTime(currentStep * stepSize, rate); //48000); //setting different rate doesn't affect it + Plugin::FeatureSet feat=plugin->process(plugbuf, rt); + float t; + for (unsigned int i = 0; i < feat[outputNo].size(); ++i) { feature f; f.number=featureNo; f.values=feat[outputNo][i].values; - features[((float)feat[outputNo][i].timestamp.sec)+(((float)feat[outputNo][i].timestamp.nsec)*.000000001)]=f; + //fix for plugins that don't set timestamp properly + t=((float)feat[outputNo][i].timestamp.sec)+(((float)feat[outputNo][i].timestamp.nsec)*.000000001); + if (t<.01) t=((rt.sec)+(rt.nsec)*.000000001); + features[t]=f; featureNo++; } + //if (feat[outputNo].size()>0) cerr<<"vamphost: "<<t<<":"<<features.size()<<" features"<<endl; + //shunt it down for (int i=0;i<blockSize-stepSize;i++){ for (int j=0;j<channels;j++){ @@ -335,13 +348,14 @@ void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){ } } + //if (feat[outputNo].size()>0) cerr<<plugin->getIdentifier()<<" step:"<<currentStep<<" sample:"<<currentStep * stepSize<<" features:"<<features.size()<<endl; + in_block-=stepSize; - currentStep++; + currentStep++; //WTF this number does not increase when called the 2nd way } } } void vampHost::Analyser::cleanup(){ - //process final block while(in_block<blockSize) { for (int i=0;i<channels;i++) { @@ -386,3 +400,21 @@ void vampHost::Analyser::cleanup(){ delete[] plugbuf; delete plugin; } +float vampHost::Analyser::get_value(const float &time) { + if (features.size()) { + auto i=features.upper_bound(time); //the first element in the container whose key is considered to go after k + if (i!=features.end()){ + float uk=i->first; + float v1,v2; + v1=v2=0.0f; + if (i->second.values.size()) v2=i->second.values[0]; + i--; + float lk=i->first; + int ln=i->second.number; + if (i->second.values.size()) v1=i->second.values[0]; + + return ((((time-lk)/(uk-lk))*(v2-v1))+v1); + } + } + return 0.0f; +} |
