diff options
Diffstat (limited to 'vamphost/src/ofxVamphost.cpp')
| -rw-r--r-- | vamphost/src/ofxVamphost.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/vamphost/src/ofxVamphost.cpp b/vamphost/src/ofxVamphost.cpp index 3da842b..fc8bbf0 100644 --- a/vamphost/src/ofxVamphost.cpp +++ b/vamphost/src/ofxVamphost.cpp @@ -2,22 +2,18 @@ using namespace std; -bool Vamphost::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){ +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 channels =_channels; - samples=_samples; rate=_rate; - 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)); - features[0.0f]=0; loader = PluginLoader::getInstance(); @@ -26,7 +22,7 @@ bool Vamphost::init(const string &soname,const string &id,const int &_channels,c if (!plugin) { cerr << ": ERROR: Failed to load plugin \"" << id << "\" from library \"" << soname << "\"" << endl; - return false; + return -1; } cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl; @@ -84,7 +80,7 @@ bool Vamphost::init(const string &soname,const string &id,const int &_channels,c if (outputs.empty()) { cerr << "ERROR: Plugin has no outputs!" << endl; - return false; + return -1; } if (outputNo < 0) { @@ -96,13 +92,13 @@ bool Vamphost::init(const string &soname,const string &id,const int &_channels,c } if (outputNo < 0) { cerr << "ERROR: Non-existent output \"" << output << "\" requested" << endl; - return false; + return -1; } } else { if (int(outputs.size()) <= outputNo) { cerr << "ERROR: Output " << outputNo << " requested, but plugin has only " << outputs.size() << " output(s)" << endl; - return false; + return -1; } } od = outputs[outputNo]; @@ -112,7 +108,7 @@ bool Vamphost::init(const string &soname,const string &id,const int &_channels,c cerr << "ERROR: Plugin initialise (channels = " << channels << ", stepSize = " << stepSize << ", blockSize = " << blockSize << ") failed." << endl; - return false; + return -1; } wrapper = dynamic_cast<PluginWrapper *>(plugin); @@ -131,21 +127,24 @@ bool Vamphost::init(const string &soname,const string &id,const int &_channels,c featureNo=1; - return true; + return blockSize; } -void Vamphost::process_frame(unsigned char *data,int samples_in_frame){ +void Vamphost::process_frame(float *data,int samples_in_frame){ + // + // + + //plugbuf[0]=data; + // + // + int sample=0; //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) { while(sample<samples_in_frame&&in_block<blockSize) { - for (int i=0;i<channels;i++) { - unsigned int this_val=0; - for (int j=0;j<bytes;j++) { - this_val+=data[(sample*stride)+(i*bytes)+j]<<(j*8); - } - plugbuf[i][in_block]=((float)((short)this_val))*scale; + for (int i=0;i<channels;i++) {} + plugbuf[i][in_block]=data[0]; //sample]; } in_block++; sample++; @@ -175,7 +174,7 @@ void Vamphost::process_frame(unsigned char *data,int samples_in_frame){ currentStep++; } } -} + void Vamphost::cleanup(){ //process final block |
