本文整理汇总了C++中PluginLoader::loadPlugin方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginLoader::loadPlugin方法的具体用法?C++ PluginLoader::loadPlugin怎么用?C++ PluginLoader::loadPlugin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginLoader
的用法示例。
在下文中一共展示了PluginLoader::loadPlugin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
printPluginCategoryList()
{
PluginLoader *loader = PluginLoader::getInstance();
vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
set<string> printedcats;
for (size_t i = 0; i < plugins.size(); ++i) {
PluginLoader::PluginKey key = plugins[i];
PluginLoader::PluginCategoryHierarchy category =
loader->getPluginCategory(key);
Plugin *plugin = loader->loadPlugin(key, 48000);
if (!plugin) continue;
string catstr = "";
if (category.empty()) catstr = '|';
else {
for (size_t j = 0; j < category.size(); ++j) {
catstr += category[j];
catstr += '|';
if (printedcats.find(catstr) == printedcats.end()) {
std::cout << catstr << std::endl;
printedcats.insert(catstr);
}
}
}
std::cout << catstr << key << ":::" << plugin->getName() << ":::" << plugin->getMaker() << ":::" << plugin->getDescription() << std::endl;
}
}
示例2: if
void
enumeratePlugins(Verbosity verbosity)
{
PluginLoader *loader = PluginLoader::getInstance();
if (verbosity == PluginInformation) {
cout << "\nVamp plugin libraries found in search path:" << endl;
}
vector<PluginLoader::PluginKey> plugins = loader->listPlugins();
typedef multimap<string, PluginLoader::PluginKey>
LibraryMap;
LibraryMap libraryMap;
for (size_t i = 0; i < plugins.size(); ++i) {
string path = loader->getLibraryPathForPlugin(plugins[i]);
libraryMap.insert(LibraryMap::value_type(path, plugins[i]));
}
string prevPath = "";
int index = 0;
for (LibraryMap::iterator i = libraryMap.begin();
i != libraryMap.end(); ++i) {
string path = i->first;
PluginLoader::PluginKey key = i->second;
if (path != prevPath) {
prevPath = path;
index = 0;
if (verbosity == PluginInformation) {
cout << "\n " << path << ":" << endl;
} else if (verbosity == PluginInformationDetailed) {
string::size_type ki = i->second.find(':');
string text = "Library \"" + i->second.substr(0, ki) + "\"";
cout << "\n" << header(text, 1);
}
}
Plugin *plugin = loader->loadPlugin(key, 48000);
if (plugin) {
char c = char('A' + index);
if (c > 'Z') c = char('a' + (index - 26));
PluginLoader::PluginCategoryHierarchy category =
loader->getPluginCategory(key);
string catstr;
if (!category.empty()) {
for (size_t ci = 0; ci < category.size(); ++ci) {
if (ci > 0) catstr += " > ";
catstr += category[ci];
}
}
if (verbosity == PluginInformation) {
cout << " [" << c << "] [v"
<< plugin->getVampApiVersion() << "] "
<< plugin->getName() << ", \""
<< plugin->getIdentifier() << "\"" << " ["
<< plugin->getMaker() << "]" << endl;
if (catstr != "") {
cout << " > " << catstr << endl;
}
if (plugin->getDescription() != "") {
cout << " - " << plugin->getDescription() << endl;
}
} else if (verbosity == PluginInformationDetailed) {
cout << header(plugin->getName(), 2);
cout << " - Identifier: "
<< key << endl;
cout << " - Plugin Version: "
<< plugin->getPluginVersion() << endl;
cout << " - Vamp API Version: "
<< plugin->getVampApiVersion() << endl;
cout << " - Maker: \""
<< plugin->getMaker() << "\"" << endl;
cout << " - Copyright: \""
<< plugin->getCopyright() << "\"" << endl;
cout << " - Description: \""
<< plugin->getDescription() << "\"" << endl;
cout << " - Input Domain: "
<< (plugin->getInputDomain() == Vamp::Plugin::TimeDomain ?
"Time Domain" : "Frequency Domain") << endl;
cout << " - Default Step Size: "
<< plugin->getPreferredStepSize() << endl;
cout << " - Default Block Size: "
<< plugin->getPreferredBlockSize() << endl;
cout << " - Minimum Channels: "
<< plugin->getMinChannelCount() << endl;
cout << " - Maximum Channels: "
<< plugin->getMaxChannelCount() << endl;
} else if (verbosity == PluginIds) {
//.........这里部分代码省略.........
示例3: runPlugin
int runPlugin(string myname, string soname, string id,
string output, int outputNo, bool useFrames, PaStreamParameters inputParameters)
{
float *recordedSamples;
float *fifo;
PaStream* stream;
PaError err = paNoError;
int elapsed = 0;
int returnValue = 1;
RealTime rt;
PluginWrapper *wrapper = 0;
RealTime adjustment = RealTime::zeroTime;
PluginLoader *loader = PluginLoader::getInstance();
PluginLoader::PluginKey key = loader->composePluginKey(soname, id);
// load plugin
Plugin *plugin = loader->loadPlugin(key, SAMPLE_RATE, PluginLoader::ADAPT_ALL_SAFE);
if (!plugin) {
cerr << myname << ": ERROR: Failed to load plugin \"" << id
<< "\" from library \"" << soname << "\"" << endl;
return 1;
}
// Find block/step size
int blockSize = plugin->getPreferredBlockSize();
int stepSize = plugin->getPreferredStepSize();
if (blockSize == 0) {
blockSize = 1024;
}
if (stepSize == 0) {
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
stepSize = blockSize/2;
} else {
stepSize = blockSize;
}
} else if (stepSize > blockSize) {
cerr << "WARNING: stepSize " << stepSize << " > blockSize " << blockSize << ", resetting blockSize to ";
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
blockSize = stepSize * 2;
} else {
blockSize = stepSize;
}
cerr << blockSize << endl;
}
// set up port audio
fifo = new float[blockSize]();
recordedSamples = new float[stepSize]();
ofstream *out = 0;
cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl;
cerr << "Using block size = " << blockSize << ", step size = " << stepSize << endl;
// display output name
Plugin::OutputList outputs = plugin->getOutputDescriptors();
Plugin::OutputDescriptor od;
if (outputs.empty()) {
cerr << "ERROR: Plugin has no outputs!" << endl;
goto done;
}
if (outputNo < 0) {
for (size_t oi = 0; oi < outputs.size(); ++oi) {
if (outputs[oi].identifier == output) {
outputNo = oi;
break;
}
}
if (outputNo < 0) {
cerr << "ERROR: Non-existent output \"" << output << "\" requested" << endl;
goto done;
}
} else {
if (int(outputs.size()) <= outputNo) {
cerr << "ERROR: Output " << outputNo << " requested, but plugin has only " << outputs.size() << " output(s)" << endl;
goto done;
}
}
od = outputs[outputNo];
cerr << "Output is: \"" << od.identifier << "\"" << endl;
// Initialise plugin
if (!plugin->initialise(1, stepSize, blockSize)) {
cerr << "ERROR: Plugin initialise (stepSize = " << stepSize << ", blockSize = "
<< blockSize << ") failed." << endl;
goto done;
}
// Compensate timestamp if in freq domain
wrapper = dynamic_cast<PluginWrapper *>(plugin);
if (wrapper) {
PluginInputDomainAdapter *ida = wrapper->getWrapper<PluginInputDomainAdapter>();
if (ida) adjustment = ida->getTimestampAdjustment();
//.........这里部分代码省略.........
示例4: main
int main(int argc, char* argv[]) {
if (argc < 4) {
cerr << "Invalid number of arguments." << endl;
cout << "Usage: " << argv[0] << " <input_video_file_path> <analytic_plugin_dir_path> <analytic_plugin_filename>" << endl;
cout << "Example: " << argv[0] << "input.mp4 ~/analytic/ analytic_plugin.so" << endl;
return -1;
}
string input_video_file_path = argv[1];
string analytic_plugin_dir_path = argv[2];
string analytic_plugin_filename = argv[3];
ConcurrentQueue<api::Image_t>* pImageInputQueue = new ConcurrentQueue<api::Image_t>(10);
ConcurrentQueue<api::Image_t>* pResultsOutputQueue = new ConcurrentQueue<api::Image_t>(10);
// Load Analytic
api::Analytic* pAnalytic = NULL;
PluginLoader<api::Analytic> loader;
string sPathToAnalyticPlugin = analytic_plugin_dir_path;
if(*sPathToAnalyticPlugin.rbegin() != '/') // last char
{
sPathToAnalyticPlugin.append("/");
}
sPathToAnalyticPlugin.append(analytic_plugin_filename);
try
{
loader.loadPlugin(sPathToAnalyticPlugin);
pAnalytic = loader.createPluginInstance();
}
catch(opencctv::Exception &e)
{
cerr << "Failed to load the Analytic plugin: " << sPathToAnalyticPlugin << endl;
return -1;
}
// Create Consumer thread to write results into a txt file
string sOutputFilename = analytic_plugin_dir_path;
if(*sOutputFilename.rbegin() != '/') // last char
{
sOutputFilename.append("/");
}
sOutputFilename.append(currentDateTime());
sOutputFilename.append(".txt");
ConsumerThread resultsConsumer(sOutputFilename, pResultsOutputQueue);
boost::thread* pConsumerThread = new boost::thread(resultsConsumer);
// Create Producer thread to read frames from input video files
ProducerThread imageProducer(input_video_file_path, pImageInputQueue);
boost::thread* pProducerThread = new boost::thread(imageProducer);
// Run analytic
try
{
if(pAnalytic->init(analytic_plugin_dir_path))
{
pAnalytic->process(pImageInputQueue, pResultsOutputQueue);
}
else
{
cerr << "Failed to initialize the Analytic. init() failed.";
}
}
catch(exception &e)
{
cerr << "Exception in Analytic: " << e.what() << endl;
}
return 0;
}
示例5: runPlugin
int runPlugin(string myname, string soname, string id,
string output, int outputNo, string wavname,
string outfilename, bool useFrames,
map<string,float> parameters)
{
PluginLoader *loader = PluginLoader::getInstance();
PluginLoader::PluginKey key = loader->composePluginKey(soname, id);
SNDFILE *sndfile;
SF_INFO sfinfo;
memset(&sfinfo, 0, sizeof(SF_INFO));
if (wavname == "")
sndfile = sf_open_fd(0, SFM_READ, &sfinfo, true);
else
sndfile = sf_open(wavname.c_str(), SFM_READ, &sfinfo);
if (!sndfile) {
cerr << myname << ": ERROR: Failed to open input file \""
<< wavname << "\": " << 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;
}
cerr << "Running plugin: \"" << plugin->getIdentifier() << "\"..." << endl;
// parameters
for (map<string,float>::iterator iter = parameters.begin(); iter!=parameters.end(); iter++) {
plugin->setParameter(iter->first, iter->second);
cerr << "Set parameter " << iter->first << " = " << iter->second << endl;
}
// Note that the following would be much simpler if we used a
// PluginBufferingAdapter as well -- i.e. if we had passed
// PluginLoader::ADAPT_ALL to loader->loadPlugin() above, instead
// of ADAPT_ALL_SAFE. Then we could simply specify our own block
// size, keep the step size equal to the block size, and ignore
// the plugin's bleatings. However, there are some issues with
// using a PluginBufferingAdapter that make the results sometimes
// technically different from (if effectively the same as) the
// un-adapted plugin, so we aren't doing that here. See the
// PluginBufferingAdapter documentation for details.
int blockSize = plugin->getPreferredBlockSize();
int stepSize = plugin->getPreferredStepSize();
if (blockSize == 0) {
blockSize = 1024;
}
if (stepSize == 0) {
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
stepSize = blockSize/2;
} else {
stepSize = blockSize;
}
} else if (stepSize > blockSize) {
cerr << "WARNING: stepSize " << stepSize << " > blockSize " << blockSize << ", resetting blockSize to ";
if (plugin->getInputDomain() == Plugin::FrequencyDomain) {
blockSize = stepSize * 2;
} else {
blockSize = stepSize;
}
cerr << blockSize << endl;
}
int overlapSize = blockSize - stepSize;
sf_count_t currentStep = 0;
int finalStepsRemaining = max(1, (blockSize / stepSize) - 1); // at end of file, this many part-silent frames needed after we hit EOF
int channels = sfinfo.channels;
float *filebuf = new float[blockSize * channels];
float **plugbuf = new float*[channels];
for (int c = 0; c < channels; ++c) plugbuf[c] = new float[blockSize + 2];
cerr << "Using block size = " << blockSize << ", step size = "
<< stepSize << endl;
//.........这里部分代码省略.........
示例6: AutoRegisterPlugins
bool VampEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
#ifdef EFFECT_CATEGORIES
InitCategoryMap();
#endif
PluginLoader *loader = PluginLoader::getInstance();
EffectManager& em = EffectManager::Get();
PluginLoader::PluginKeyList keys = loader->listPlugins();
for (PluginLoader::PluginKeyList::iterator i = keys.begin();
i != keys.end(); ++i) {
Plugin *vp = loader->loadPlugin(*i, 48000); // rate doesn't matter here
if (!vp) continue;
#ifdef EFFECT_CATEGORIES
PluginLoader::PluginCategoryHierarchy category =
loader->getPluginCategory(*i);
wxString vampCategory = VampHierarchyToUri(category);
#endif
// We limit the listed plugin outputs to those whose results can
// readily be displayed in an Audacity label track.
//
// - Any output whose features have no values (time instants only),
// with or without duration, is fine
//
// - Any output whose features have more than one value, or an
// unknown or variable number of values, is right out
//
// - Any output whose features have exactly one value, with
// variable sample rate or with duration, should be OK --
// this implies a sparse feature, of which the time and/or
// duration are significant aspects worth displaying
//
// - An output whose features have exactly one value, with
// fixed sample rate and no duration, cannot be usefully
// displayed -- the value is the only significant piece of
// data there and we have no good value plot
Plugin::OutputList outputs = vp->getOutputDescriptors();
int n = 0;
bool hasParameters = !vp->getParameterDescriptors().empty();
for (Plugin::OutputList::iterator j = outputs.begin();
j != outputs.end(); ++j) {
if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate ||
j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep ||
!j->hasFixedBinCount ||
(j->hasFixedBinCount && j->binCount > 1)) {
// All of these qualities disqualify (see notes above)
++n;
continue;
}
wxString name = LAT1CTOWX(vp->getName().c_str());
if (outputs.size() > 1) {
// This is not the plugin's only output.
// Use "plugin name: output name" as the effect name,
// unless the output name is the same as the plugin name
wxString outputName = LAT1CTOWX(j->name.c_str());
if (outputName != name) {
name = wxString::Format(wxT("%s: %s"),
name.c_str(), outputName.c_str());
}
}
#ifdef EFFECT_CATEGORIES
VampEffect *effect = new VampEffect(*i, n, hasParameters, name,
vampCategory);
#else
VampEffect *effect = new VampEffect(*i, n, hasParameters, name);
#endif
em.RegisterEffect(this, effect);
++n;
}
delete vp;
}
return true;
}