summaryrefslogtreecommitdiff
path: root/rotord/vampHost.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-02-18 17:12:27 +0000
committerTim Redfern <tim@herge.(none)>2013-02-18 17:12:27 +0000
commitb5ac1eb4bc06e6ae3cd2a908270640bc5181257b (patch)
tree7e5a0501e08aaa6efc386227a4873033a2c997f2 /rotord/vampHost.cpp
parent42a67a912a283f9012828660f07bc5743527317a (diff)
plugins loading and failing
Diffstat (limited to 'rotord/vampHost.cpp')
-rw-r--r--rotord/vampHost.cpp54
1 files changed, 18 insertions, 36 deletions
diff --git a/rotord/vampHost.cpp b/rotord/vampHost.cpp
index 8423c54..54ce77b 100644
--- a/rotord/vampHost.cpp
+++ b/rotord/vampHost.cpp
@@ -1,8 +1,8 @@
#include "vampHost.h"
-int vampHost::runPlugin(string myname, string soname, string id,
- string output, int outputNo, string wavname,
- string outfilename, bool useFrames)
+int vampHost::runPlugin(string myname, string soname, string id, string output,
+ int outputNo, string inputFile, ostream& out, bool useFrames)
+
{
PluginLoader *loader = PluginLoader::getInstance();
@@ -12,34 +12,19 @@ int vampHost::runPlugin(string myname, string soname, string id,
SF_INFO sfinfo;
memset(&sfinfo, 0, sizeof(SF_INFO));
- sndfile = sf_open(wavname.c_str(), SFM_READ, &sfinfo);
+ sndfile = sf_open(inputFile.c_str(), SFM_READ, &sfinfo);
if (!sndfile) {
cerr << myname << ": ERROR: Failed to open input file \""
- << wavname << "\": " << sf_strerror(sndfile) << endl;
+ << inputFile << "\": " << sf_strerror(sndfile) << endl;
return 1;
}
- ofstream *out = 0;
- if (outfilename != "") {
- out = new ofstream(outfilename.c_str(), ios::out);
- if (!*out) {
- cerr << myname << ": ERROR: Failed to open output file \""
- << outfilename << "\" for writing" << endl;
- delete out;
- return 1;
- }
- }
-
Plugin *plugin = loader->loadPlugin
(key, sfinfo.samplerate, PluginLoader::ADAPT_ALL_SAFE);
if (!plugin) {
cerr << myname << ": ERROR: Failed to load plugin \"" << id
<< "\" from library \"" << soname << "\"" << endl;
sf_close(sndfile);
- if (out) {
- out->close();
- delete out;
- }
return 1;
}
@@ -192,7 +177,7 @@ int vampHost::runPlugin(string myname, string soname, string id,
rt = RealTime::frame2RealTime(currentStep * stepSize, sfinfo.samplerate);
- printFeatures
+ vampHost::printFeatures
(RealTime::realTime2Frame(rt + adjustment, sfinfo.samplerate),
sfinfo.samplerate, outputNo, plugin->process(plugbuf, rt),
out, useFrames);
@@ -213,7 +198,7 @@ int vampHost::runPlugin(string myname, string soname, string id,
rt = RealTime::frame2RealTime(currentStep * stepSize, sfinfo.samplerate);
- printFeatures(RealTime::realTime2Frame(rt + adjustment, sfinfo.samplerate),
+ vampHost::printFeatures(RealTime::realTime2Frame(rt + adjustment, sfinfo.samplerate),
sfinfo.samplerate, outputNo,
plugin->getRemainingFeatures(), out, useFrames);
@@ -221,16 +206,12 @@ int vampHost::runPlugin(string myname, string soname, string id,
done:
delete plugin;
- if (out) {
- out->close();
- delete out;
- }
sf_close(sndfile);
return returnValue;
}
void vampHost::printFeatures(int frame, int sr, int output,
- Plugin::FeatureSet features, ofstream *out, bool useFrames)
+ Plugin::FeatureSet features, ostream& out, bool useFrames)
{
for (unsigned int i = 0; i < features[output].size(); ++i) {
@@ -243,15 +224,15 @@ void vampHost::printFeatures(int frame, int sr, int output,
(features[output][i].timestamp, sr);
}
- (out ? *out : cout) << displayFrame;
+ out << displayFrame;
if (features[output][i].hasDuration) {
displayFrame = RealTime::realTime2Frame
(features[output][i].duration, sr);
- (out ? *out : cout) << "," << displayFrame;
+ out << "," << displayFrame;
}
- (out ? *out : cout) << ":";
+ out << ":";
} else {
@@ -261,21 +242,22 @@ void vampHost::printFeatures(int frame, int sr, int output,
rt = features[output][i].timestamp;
}
- (out ? *out : cout) << rt.toString();
+ out << rt.toString();
if (features[output][i].hasDuration) {
rt = features[output][i].duration;
- (out ? *out : cout) << "," << rt.toString();
+ out<< "," << rt.toString();
}
- (out ? *out : cout) << ":";
+ out << ":";
}
for (unsigned int j = 0; j < features[output][i].values.size(); ++j) {
- (out ? *out : cout) << " " << features[output][i].values[j];
+ out<< " " << features[output][i].values[j];
}
- (out ? *out : cout) << " " << features[output][i].label;
+ out << " " << features[output][i].label;
- (out ? *out : cout) << endl;
+ out << endl;
}
+
} \ No newline at end of file