本文整理汇总了C++中plugin::OutputList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputList::empty方法的具体用法?C++ OutputList::empty怎么用?C++ OutputList::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin::OutputList
的用法示例。
在下文中一共展示了OutputList::empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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) {
//.........这里部分代码省略.........
示例2: runPlugin
//.........这里部分代码省略.........
}
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;
// The channel queries here are for informational purposes only --
// a PluginChannelAdapter is being used automatically behind the
// scenes, and it will take case of any channel mismatch
int minch = plugin->getMinChannelCount();
int maxch = plugin->getMaxChannelCount();
cerr << "Plugin accepts " << minch << " -> " << maxch << " channel(s)" << endl;
cerr << "Sound file has " << channels << " (will mix/augment if necessary)" << endl;
Plugin::OutputList outputs = plugin->getOutputDescriptors();
Plugin::OutputDescriptor od;
int returnValue = 1;
int progress = 0;
RealTime rt;
PluginWrapper *wrapper = 0;
RealTime adjustment = RealTime::zeroTime;
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;
if (!plugin->initialise(channels, stepSize, blockSize)) {
cerr << "ERROR: Plugin initialise (channels = " << channels
<< ", stepSize = " << stepSize << ", blockSize = "
示例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: Init
bool VampAnalyser::Init(const QString pluginlibrary, const QString pluginid,
const int samplerate, const int TotalSamples, bool bFastAnalysis) {
m_iRemainingSamples = TotalSamples;
m_rate = samplerate;
if (samplerate <= 0.0) {
qDebug() << "VampAnalyser: Track has non-positive samplerate";
return false;
}
if (TotalSamples <= 0) {
qDebug() << "VampAnalyser: Track has non-positive # of samples";
return false;
}
if (m_plugin != NULL) {
delete m_plugin;
m_plugin = NULL;
qDebug() << "VampAnalyser: kill plugin";
}
VampPluginLoader *loader = VampPluginLoader::getInstance();
QStringList pluginlist = pluginid.split(":");
if (pluginlist.size() != 2) {
qDebug() << "VampAnalyser: got malformed pluginid: " << pluginid;
return false;
}
bool isNumber = false;
int outputnumber = (pluginlist.at(1)).toInt(&isNumber);
if (!isNumber) {
qDebug() << "VampAnalyser: got malformed pluginid: " << pluginid;
return false;
}
QString plugin = pluginlist.at(0);
m_key = loader->composePluginKey(pluginlibrary.toStdString(),
plugin.toStdString());
m_plugin = loader->loadPlugin(m_key, m_rate,
Vamp::HostExt::PluginLoader::ADAPT_ALL_SAFE);
if (!m_plugin) {
qDebug() << "VampAnalyser: Cannot load Vamp Plug-in.";
qDebug() << "Please copy libmixxxminimal.so from build dir to one of the following:";
std::vector<std::string> path = PluginHostAdapter::getPluginPath();
for (unsigned int i = 0; i < path.size(); i++) {
qDebug() << QString::fromStdString(path[i]);
}
return false;
}
Plugin::OutputList outputs = m_plugin->getOutputDescriptors();
if (outputs.empty()) {
qDebug() << "VampAnalyser: Plugin has no outputs!";
return false;
}
SelectOutput(outputnumber);
m_iBlockSize = m_plugin->getPreferredBlockSize();
qDebug() << "Vampanalyser BlockSize: " << m_iBlockSize;
if (m_iBlockSize == 0) {
// A plugin that can handle any block size may return 0. The final block
// size will be set in the initialise() call. Since 0 means it is
// accepting any size, 1024 should be good
m_iBlockSize = 1024;
qDebug() << "Vampanalyser: setting m_iBlockSize to 1024";
}
m_iStepSize = m_plugin->getPreferredStepSize();
qDebug() << "Vampanalyser StepSize: " << m_iStepSize;
if (m_iStepSize == 0 || m_iStepSize > m_iBlockSize) {
// A plugin may return 0 if it has no particular interest in the step
// size. In this case, the host should make the step size equal to the
// block size if the plugin is accepting input in the time domain. If
// the plugin is accepting input in the frequency domain, the host may
// use any step size. The final step size will be set in the
// initialise() call.
m_iStepSize = m_iBlockSize;
qDebug() << "Vampanalyser: setting m_iStepSize to" << m_iStepSize;
}
if (!m_plugin->initialise(2, m_iStepSize, m_iBlockSize)) {
qDebug() << "VampAnalyser: Cannot initialise plugin";
return false;
}
// Here we are using m_iBlockSize: it cannot be 0
m_pluginbuf[0] = new CSAMPLE[m_iBlockSize];
m_pluginbuf[1] = new CSAMPLE[m_iBlockSize];
m_FastAnalysisEnabled = bFastAnalysis;
if (m_FastAnalysisEnabled) {
qDebug() << "Using fast analysis methods for BPM and Replay Gain.";
m_iMaxSamplesToAnalyse = 120 * m_rate; //only consider the first minute
}
return true;
}