summaryrefslogtreecommitdiff
path: root/rotord/vampHost.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/vampHost.cpp')
-rw-r--r--rotord/vampHost.cpp85
1 files changed, 52 insertions, 33 deletions
diff --git a/rotord/vampHost.cpp b/rotord/vampHost.cpp
index 2521f46..805481c 100644
--- a/rotord/vampHost.cpp
+++ b/rotord/vampHost.cpp
@@ -477,7 +477,7 @@ void vampHost::rotorGetFeatures(int frame, int sr, int output,Plugin::FeatureSet
}
for (unsigned int i = 0; i < features[output].size(); ++i) {
-
+
int displayFrame = frame;
@@ -501,15 +501,15 @@ int vampHost::QMAnalyser::process(const string inputFile){
//
//int runPlugin(string myname, string soname, string id, string output,int outputNo, string inputFile, ostream& out, bool frames);
-
+
//we want to run a specific plugin, outputting progress to a mutex-protected passed variable
//and ultimately passing the data back as a string?
//or capture it as an array of floats?
//get the progress as a float
//how to handle errors?
-
+
//debugger fucking up! program stalls after 1 request in debug!?
-
+
string soname="qm-vamp-plugins";
string id="qm-tempotracker";
string myname="";
@@ -521,18 +521,18 @@ int vampHost::QMAnalyser::process(const string inputFile){
}
void vampHost::getTimestamps(int output,Plugin::FeatureSet features, vector<float>& out){
-
+
/*
- vamp-simple-host qm-vamp-plugins:qm-tempotracker 01.wav
+ vamp-simple-host qm-vamp-plugins:qm-tempotracker 01.wav
0.046439908: 156.61 bpm
0.429569160: 156.61 bpm
0.812698412: 161.50 bpm
1.184217686: 152.00 bpm
-
-
+
+
vamp-simple-host qm-vamp-plugins:qm-segmenter 01.wav
-
+
0.000000000: 4 4
23.800000000: 6 6
44.600000000: 5 5
@@ -544,33 +544,33 @@ void vampHost::getTimestamps(int output,Plugin::FeatureSet features, vector<floa
143.800000000: 5 5
153.400000000: 3 3
163.000000000: 8 8
-
+
seems to be FP seconds then another metric
for now we can just take the first part
-
+
features[output][i].timestamp is of type RealTime: represents time values to nanosecond precision
int sec;
int nsec;
1 sec = 10^9 nanosec
-
+
actually maybe this would be the way to go for rotor- avoiding rounding errors etc
for now - ideally will get a float representation
-
+
features[output][i].values is a vector of floats + a description
WE DON'T CARE ABOUT ANYTHING <.01 seconds
-
+
static long realTime2Frame(const RealTime &r, unsigned int sampleRate);
-
+
get a vector of floats out, using frames, presuming data has a timestamp
-
-
+
+
this is crashing with "Aborted (core dumped)"
if we check for timestamp
-
+
*/
-
+
cout << "." << features[output].size();
-
+
//if (!features[output][0].hasTimestamp) {
// cerr << output << " channel, getTimestamps: error, featureset doesn't support timestamp" << endl;
//}_
@@ -589,7 +589,7 @@ float vampHost::QMAnalyser::get_progress(){
return p;
}
bool vampHost::Analyser::init(const string &soname,const string &id,const int &_channels,const int &_bits,const int &_samples,const int &_rate,const int &_outputNo,const string &_output){
-
+
//stuff that only happens once
channels =_channels;
samples=_samples;
@@ -597,18 +597,18 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
bits=_bits;
outputNo=_outputNo;
output=_output;
-
+
//http://www.mega-nerd.com/libsndfile/api.html#note1
//libsndfile returns -1..1 for fp data
bytes=(bits>>3);
stride=channels*bytes;
scale=(1.0f/pow(2.0f,bits));
-
-
+
+
loader = PluginLoader::getInstance();
key = loader->composePluginKey(soname, id);
- Plugin *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;
@@ -616,7 +616,7 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
}
cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl;
-
+
blockSize = plugin->getPreferredBlockSize();
stepSize = plugin->getPreferredStepSize();
@@ -629,7 +629,7 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
} else {
stepSize = blockSize;
}
- }
+ }
else if (stepSize > blockSize) {
cerr << "WARNING: stepSize " << stepSize << " > blockSize " << blockSize << ", resetting blockSize to ";
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
@@ -642,7 +642,7 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
overlapSize = blockSize - stepSize;
currentStep = 0;
finalStepsRemaining = max(1, (blockSize / stepSize) - 1); // at end of file, this many part-silent frames needed after we hit EOF
-
+
plugbuf = new float*[channels];
for (int c = 0; c < channels; ++c) plugbuf[c] = new float[blockSize + 2];
@@ -684,7 +684,7 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
cerr << "ERROR: Non-existent output \"" << output << "\" requested" << endl;
return false;
}
- }
+ }
else {
if (int(outputs.size()) <= outputNo) {
cerr << "ERROR: Output " << outputNo << " requested, but plugin has only " << outputs.size() << " output(s)" << endl;
@@ -700,7 +700,7 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
<< blockSize << ") failed." << endl;
return false;
}
-
+
wrapper = dynamic_cast<PluginWrapper *>(plugin);
if (wrapper) {
// See documentation for
@@ -708,16 +708,20 @@ bool vampHost::Analyser::init(const string &soname,const string &id,const int &_
PluginInputDomainAdapter *ida =wrapper->getWrapper<PluginInputDomainAdapter>();
if (ida) adjustment = ida->getTimestampAdjustment();
}
-
+
//everything is prepared to start consuming data in blocks
-
+
in_block=0;
blocks_processed=0;
+ currentStep=0;
+ featureNo=0;
+
return true;
}
void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){
int sample=0;
+ RealTime rt;
//process the whole frame which may be f>1<f blocks
//when the frame is finished leave the partial block for the next frame
while(sample<samples_in_frame) {
@@ -734,13 +738,28 @@ void vampHost::Analyser::process_frame(uint8_t *data,int samples_in_frame){
}
if (in_block==blockSize) {
//block is ready to be processed
- cerr<<"processing block "<<blocks_processed<<endl;
+ //cerr<<plugin->getIdentifier()<<" processed block "<<blocks_processed<<endl;
+
+ //I /think/ that the vamp plugin keeps processing through the plugbuf until it encounters 0s
+ rt = RealTime::frame2RealTime(in_block * stepSize, rate);
+
+ Plugin::FeatureSet feat=plugin->process(plugbuf, rt);
+
+ 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;
+ featureNo++;
+ }
+
+ //all good but no features! what gives?
+
in_block=0;
blocks_processed++;
}
}
}
void vampHost::Analyser::cleanup(){
+ cerr<<plugin->getIdentifier()<<" found "<<features.size()<<" features"<<endl;
+ //deal with left over data?
for (int c = 0; c < channels; ++c) {
delete[] plugbuf[c];
}