本文整理汇总了C++中MarSystem::remoteSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::remoteSystem方法的具体用法?C++ MarSystem::remoteSystem怎么用?C++ MarSystem::remoteSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarSystem
的用法示例。
在下文中一共展示了MarSystem::remoteSystem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
if (argc < 3)
{
cerr << "Usage: <input file> <output file>" << endl;
return 1;
}
char *input_filename = argv[1];
char *output_filename = argv[2];
detector::registerScripts();
ScriptTranslator translator;
MarSystem *system = translator.translateRegistered("detector.mrs");
if (!system)
{
cerr << "Failure loading script!" << endl;
return 1;
}
MarControlPtr input_control = system->control("input");
MarControlPtr output_control = system->control("output");
MarControlPtr done_control = system->control("done");
if ( input_control.isInvalid() ||
output_control.isInvalid() ||
done_control.isInvalid() )
{
cerr << "Failure: Invalid script!" << endl;
delete system;
return 1;
}
input_control->setValue(string(input_filename));
//output_control->setValue(string("features.out"));
mrs_real sample_rate = system->remoteControl("sndfile/osrate")->to<mrs_real>();
mrs_natural block_size = system->remoteControl("sndfile/onSamples")->to<mrs_natural>();
mrs_real block_duration = block_size / sample_rate;
MarControlPtr output = system->getControl("mrs_realvec/processedData");
MarControlPtr confidence_ctl = system->remoteControl("onsets/confidence");
assert(!output.isInvalid());
assert(!confidence_ctl.isInvalid());
MarSystem *rms_sys = system->remoteSystem("rms");
assert(rms_sys);
MarControlPtr rms_out = rms_sys->getControl("mrs_real/value");
assert(!rms_out.isInvalid());
std::vector<onset> onsets;
int block = 0;
const int block_offset = 5;
while(!done_control->to<bool>())
{
system->tick();
const realvec & data = output->to<realvec>();
assert(data.getSize() == 2);
mrs_real confidence = confidence_ctl->to<mrs_real>();
if (!(data(0) > 0.0) || confidence < 10.0 / 100.0)
{
++block;
continue;
}
mrs_real centroid = data(1);
double rms = rms_out->to<mrs_real>();
onset o;
o.time = (block - block_offset + 0.5) * block_duration;
if (centroid < 0.04)
o.type = 0;
else if (centroid < 0.3)
o.type = 1;
else
o.type = 2;
o.strength = rms;
onsets.push_back(o);
++block;
}
string separator(",");
ofstream out_file(output_filename);
if (!out_file.is_open())
{
cerr << "Failed to open output file for writing: " << output_filename << endl;
return 1;
}
//.........这里部分代码省略.........