本文整理汇总了C++中MarSystem::setControl方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::setControl方法的具体用法?C++ MarSystem::setControl怎么用?C++ MarSystem::setControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarSystem
的用法示例。
在下文中一共展示了MarSystem::setControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int run( const string system_filename, const CommandLineOptions & opt )
{
int ticks = 0;
if (opt.has("count"))
{
ticks = opt.value<int>("count");
if (ticks < 1)
{
cerr << "Invalid value for option 'count' (must be > 0)." << endl;
return 1;
}
}
ifstream system_istream(system_filename);
MarSystemManager mng;
MarSystem* system = mng.getMarSystem(system_istream);
if (!system) {
cerr << "Could not load filesystem file:" << system;
return 1;
}
bool realtime = opt.value<bool>("realtime");
mrs_real sr = opt.value<mrs_real>("samplerate");
mrs_natural block = opt.value<mrs_natural>("block");
if (sr > 0)
system->setControl("mrs_real/israte", sr);
if (block > 0)
system->setControl("mrs_natural/inSamples", block);
system->update();
RealTime::Runner runner(system);
runner.setRtPriorityEnabled(realtime);
runner.start((unsigned int)ticks);
runner.wait();
return 0;
}
示例2: sfplay
// Play a collection l of soundfiles
void sfplay(vector<string> soundfiles)
{
MRSDIAG("sfplay.cpp - sfplay");
MarSystemManager mng;
string sfName;
// Output destination is either audio or soundfile
MarSystem* dest;
if (fileName == EMPTYSTRING) // audio output
{
dest = mng.create("AudioSink", "dest");
string backend = cmd_options.getStringOption("audio-backend");
if (!backend.empty())
dest->setControl("mrs_string/backend", backend);
}
else // filename output
{
dest = mng.create("SoundFileSink", "dest");
}
// create playback network with source-gain-dest
MarSystem* playbacknet = mng.create("Series", "playbacknet");
playbacknet->addMarSystem(mng.create("SoundFileSource", "src"));
playbacknet->addMarSystem(mng.create("Gain", "gt"));
playbacknet->addMarSystem(dest);
// playback offset
// update controls
playbacknet->updControl("mrs_natural/inSamples", windowsize);
playbacknet->updControl("Gain/gt/mrs_real/gain", gain);
// link top-level controls
playbacknet->linkControl("mrs_string/filename","SoundFileSource/src/mrs_string/filename");
playbacknet->linkControl("mrs_real/israte", "SoundFileSource/src/mrs_real/israte");
playbacknet->linkControl("mrs_natural/pos", "SoundFileSource/src/mrs_natural/pos");
playbacknet->linkControl("mrs_natural/loopPos", "SoundFileSource/src/mrs_natural/loopPos");
playbacknet->linkControl("mrs_bool/hasData", "SoundFileSource/src/mrs_bool/hasData");
if (fileName == EMPTYSTRING) // audio output
playbacknet->linkControl("mrs_bool/initAudio", "AudioSink/dest/mrs_bool/initAudio");
// play each collection or soundfile
vector<string>::iterator sfi;
for (sfi = soundfiles.begin(); sfi != soundfiles.end(); ++sfi)
{
string fname = *sfi;
playbacknet->updControl("mrs_string/filename", fname);
mrs_natural nChannels = playbacknet->getctrl("mrs_natural/onObservations")->to<mrs_natural>();
mrs_real srate = playbacknet->getctrl("mrs_real/israte")->to<mrs_real>();
;
offset = (mrs_natural) (start * srate * nChannels);
playbacknet->updControl("mrs_natural/loopPos", offset);
playbacknet->updControl("mrs_natural/pos", offset);
playbacknet->updControl("SoundFileSource/src/mrs_real/repetitions", repetitions);
playbacknet->updControl("SoundFileSource/src/mrs_real/duration", length);
if (fileName != EMPTYSTRING) // soundfile output instead of audio output
playbacknet->updControl("SoundFileSink/dest/mrs_string/filename", fileName);
if (fileName == EMPTYSTRING) // audio output
{
playbacknet->updControl("AudioSink/dest/mrs_natural/bufferSize", 256);
playbacknet->updControl("AudioSink/dest/mrs_bool/initAudio", true);
}
MarControlPtr hasDataPtr_ =
playbacknet->getctrl("mrs_bool/hasData");
while (hasDataPtr_->isTrue())
{
playbacknet->tick();
}
//cout << *playbacknet << endl;
}
// output network description to cout
if ((pluginName == EMPTYSTRING) && (verboseopt)) // output to stdout
{
cout << (*playbacknet) << endl;
}
else if (pluginName != EMPTYSTRING) // output to plugin
{
ofstream oss(pluginName.c_str());
oss << (*playbacknet) << endl;
}
delete playbacknet;
}