本文整理汇总了C++中MarSystem::getControl方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::getControl方法的具体用法?C++ MarSystem::getControl怎么用?C++ MarSystem::getControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarSystem
的用法示例。
在下文中一共展示了MarSystem::getControl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
toy_with_arff_in_out(mrs_string in_name, mrs_string out_name)
{
MarSystemManager mng;
MarSystem *net = mng.create("Series", "net");
net->addMarSystem(mng.create("WekaSource", "src"));
net->addMarSystem(mng.create("WekaSink", "dest"));
net->updControl("WekaSource/src/mrs_string/filename", in_name);
net->updControl("WekaSink/dest/mrs_natural/nLabels",
net->getControl("WekaSource/src/mrs_natural/nClasses"));
net->updControl("WekaSink/dest/mrs_string/labelNames",
net->getControl("WekaSource/src/mrs_string/classNames"));
net->updControl("WekaSink/dest/mrs_bool/regression",
net->getControl("WekaSource/src/mrs_bool/regression"));
// must happen after setting the above controls
net->updControl("WekaSink/dest/mrs_string/filename", out_name);
while ( !net->getctrl("WekaSource/src/mrs_bool/done")->to<mrs_bool>() )
{
net->tick();
}
delete net;
}
示例2: processedData
// Variation that outputs RMS and Flux
void
output_rmsflux(string inFileName)
{
MarSystemManager mng;
MarSystem* net = mng.create("Series", "net");
net->addMarSystem(mng.create("SoundFileSource", "src"));
net->addMarSystem(mng.create("Stereo2Mono", "s2m"));
// A fanout that will do both RMS and Flux calculations
MarSystem* fanout = mng.create("Fanout","fanout");
net->addMarSystem(fanout);
// The branch to do the RMS
MarSystem* rms_series = mng.create("Series","rms_series");
rms_series->addMarSystem(mng.create("Rms", "rms"));
fanout->addMarSystem(rms_series);
// The branch to do the Flux
MarSystem* flux_series = mng.create("Series","flux_series");
flux_series->addMarSystem(mng.create("ShiftInput", "si"));
flux_series->addMarSystem(mng.create("Windowing", "win"));
flux_series->addMarSystem(mng.create("Spectrum","spk"));
flux_series->addMarSystem(mng.create("PowerSpectrum", "pspk"));
flux_series->addMarSystem(mng.create("Flux", "flux"));
fanout->addMarSystem(flux_series);
// Update the controls with required values
net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);
realvec processedData;
float time = 0;
mrs_natural samples_per_tick = net->getControl("SoundFileSource/src/mrs_natural/onSamples")->to<mrs_natural>();
mrs_real rate = net->getControl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
mrs_real sec_per_tick = samples_per_tick / rate;
while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()) {
net->tick();
processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
cout << time << "," << processedData(0,0) << "," << processedData(1,0) << endl;
time += sec_per_tick;
}
delete net;
}
示例3: getFileLengthForWaveform
int getFileLengthForWaveform(string inFileName, int windowSize_, double& min, double& max) {
MarSystemManager mng;
// A series to contain everything
MarSystem* net = mng.create("Series", "net");
// The sound file
net->addMarSystem(mng.create("SoundFileSource", "src"));
net->addMarSystem(mng.create("Stereo2Mono", "s2m"));
net->addMarSystem(mng.create("ShiftInput", "si"));
net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);
mrs_real srate = net->getControl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
if ((position_ == 0) && (start_ != 0.0))
position_ = (mrs_natural) (srate * start_);
if ((ticks_ == -1) && (length_ != -1.0))
ticks_ = (mrs_natural) ((length_ * srate) / windowSize_);
net->updControl("SoundFileSource/src/mrs_natural/pos", position_);
net->updControl("SoundFileSource/src/mrs_natural/inSamples", hopSize_);
net->updControl("ShiftInput/si/mrs_natural/winSize", windowSize_);
// Compute the AbsMax of this window
net->addMarSystem(mng.create("AbsMax","absmax"));
realvec processedData;
int length = 0;
while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()
&& (ticks_ == -1 || length < ticks_)) {
net->tick();
length++;
processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
if (processedData(0) < min)
min = processedData(0);
if (processedData(0) > max)
max = processedData(0);
}
delete net;
if (verboseopt_) {
cout << "length=" << length << endl;
cout << "max=" << max << endl;
cout << "min=" << min << endl;
}
return length;
}
示例4: getFileLengthForSummaryITD
int getFileLengthForSummaryITD(string inFileName, double& min, double& max, double& average) {
realvec processedData;
double dataLength = 0;
double dataTotal = 0.0;
MarSystemManager mng;
MarSystem* net = mng.create("Series", "net");
net->addMarSystem(mng.create("SoundFileSource", "src"));
net->addMarSystem(mng.create("Stereo2Mono", "s2m"));
net->addMarSystem(mng.create("ShiftInput", "si"));
net->addMarSystem(mng.create("Spectrum","spk"));
net->addMarSystem(mng.create("PowerSpectrum","pspk"));
net->updControl("PowerSpectrum/pspk/mrs_string/spectrumType", "decibels");
net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);
mrs_real srate = net->getControl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
if ((position_ == 0) && (start_ != 0.0))
position_ = (mrs_natural) (srate * start_);
if ((ticks_ == -1) && (length_ != -1.0))
ticks_ = (mrs_natural) ((length_ * srate) / windowSize_);
net->updControl("SoundFileSource/src/mrs_natural/pos", position_);
net->updControl("SoundFileSource/src/mrs_natural/inSamples", hopSize_);
net->updControl("ShiftInput/si/mrs_natural/winSize", windowSize_);
net->updControl("mrs_natural/inSamples", int(hopSize_));
mrs_real frequency = net->getctrl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
double fftBins = windowSize_ / 2.0 + 1; // N/2 + 1
mrs_natural nChannels = net->getctrl("SoundFileSource/src/mrs_natural/onObservations")->to<mrs_natural>();
double maxBin = fftBins * (highFreq_ / (frequency / nChannels));
double minBin = fftBins * (lowFreq_ / (frequency / nChannels));
// cout << "maxBin = " << maxBin << endl;
int length = 0;
while ( net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()
&& (ticks_ == -1 || length < ticks_)) {
net->tick();
length++;
processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
for (int i = minBin; i < maxBin; ++i) {
for (int j = 0; j < processedData.getCols(); j++) {
if (processedData(i,j) < min)
min = processedData(i,j);
if (processedData(i,j) > max)
max = processedData(i,j);
dataLength += 1;
dataTotal += processedData(i,j);
}
}
}
delete net;
average = dataTotal / dataLength;
if (verboseopt_) {
cout << "length=" << length << endl;
cout << "max=" << max << endl;
cout << "min=" << min << endl;
cout << "average=" << average << endl;
}
return length;
}
示例5: 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;
}
//.........这里部分代码省略.........
示例6: pitches
//.........这里部分代码省略.........
cerr << "Enter any character to continue" << endl;
getchar();
MATLAB_EVAL("a = pitches .* pitches;");
MATLAB_GET("a", foo);
MATLAB_EVAL("plot(a)");
getchar();
MATLAB_EVAL("plot(pitches)");
cerr << "Enter any character to continue" << endl;
getchar();
MATLAB_CLOSE();
#endif
// extract chords
MarSystem* chordExtract = mng.create("Series/chordExtract");
chordExtract->addMarSystem(mng.create("SoundFileSource/src"));
chordExtract->addMarSystem(mng.create("Windowing/win"));
chordExtract->addMarSystem(mng.create("Spectrum/spk"));
chordExtract->addMarSystem(mng.create("PowerSpectrum/pspk"));
chordExtract->addMarSystem(mng.create("Spectrum2Chroma/s2c"));
chordExtract->addMarSystem(mng.create("Memory/mem"));
chordExtract->addMarSystem(mng.create("Mean/mean"));
chordExtract->addMarSystem(mng.create("Krumhansl_key_finder/kkf"));
chordExtract->updControl("mrs_natural/inSamples", hopSize);
chordExtract->updControl("Memory/mem/mrs_natural/memSize", 200);
chordExtract->updControl("SoundFileSource/src/mrs_string/filename", sfName);
for (int i=0; i < contourSize; ++i)
{
chordExtract->tick();
chords(i) = chordExtract->getControl("Krumhansl_key_finder/kkf/mrs_natural/key")->to<mrs_natural>();
cout << "chords(i) = " << chords(i) << endl;
chord_names.push_back(chordExtract->getControl("Krumhansl_key_finder/kkf/mrs_string/key_name")->to<mrs_string>());
}
// extra boom-chick pattern
// high and low bandpass filters
MarSystem *filters = mng.create("Fanout", "filters");
realvec al(5),bl(5);
al(0) = 1.0;
al(1) = -3.9680;
al(2) = 5.9062;
al(3) = -3.9084;
al(4) = 0.9702;
bl(0) = 0.0001125;
bl(1) = 0.0;
bl(2) = -0.0002250;
bl(3) = 0.0;
bl(4) = 0.0001125;
MarSystem *lfilter = mng.create("Series", "lfilter");
lfilter->addMarSystem(mng.create("Filter", "llfilter"));
lfilter->updControl("Filter/llfilter/mrs_realvec/ncoeffs", bl);
lfilter->updControl("Filter/llfilter/mrs_realvec/dcoeffs", al);
MarSystem *lowpkr = mng.create("PeakerAdaptive","lowpkr");
示例7: chords
int
pitchextract_key(mrs_string sfName, mrs_natural winSize, mrs_natural hopSize,
mrs_real lowPitch, mrs_real highPitch, mrs_real threshold,
mrs_bool playPitches, mrs_string ofName)
{
(void) lowPitch;
(void) highPitch;
(void) threshold;
(void) playPitches;
(void) ofName;
MRSDIAG("pitchextract.cpp - pitchextract");
MarSystemManager mng;
// Build pitch contour extraction network
//MarSystem* pitchContour = mng.create("Series", "pitchContour");
MarSystem* pitchExtractor = mng.create("Series", "pitchExtractor");
pitchExtractor->addMarSystem(mng.create("SoundFileSource", "src"));
pitchExtractor->addMarSystem(mng.create("Stereo2Mono", "s2m"));
if (mode == "praat") {
pitchExtractor->addMarSystem(mng.create("PitchPraat", "pitchPraat"));
} else {
pitchExtractor->addMarSystem(mng.create("PitchSACF", "pitchSACF"));
}
pitchExtractor->updControl("SoundFileSource/src/mrs_string/filename", sfName);
mrs_natural fileSize;
fileSize= pitchExtractor->getctrl("SoundFileSource/src/mrs_natural/size")->to<mrs_natural>();
mrs_natural contourSize = fileSize / hopSize;
cout << "\ncontourSize = " << contourSize << endl;
mrs_natural len = contourSize;
vector<mrs_string> chord_names;
mrs_realvec chords(len);
// extract chords
MarSystem* chordExtract = mng.create("Series/chordExtract");
chordExtract->addMarSystem(mng.create("SoundFileSource/src"));
chordExtract->addMarSystem(mng.create("ShiftInput/si"));
chordExtract->addMarSystem(mng.create("Windowing/win"));
chordExtract->addMarSystem(mng.create("Spectrum/spk"));
chordExtract->addMarSystem(mng.create("PowerSpectrum/pspk"));
chordExtract->addMarSystem(mng.create("Spectrum2Chroma/s2c"));
chordExtract->addMarSystem(mng.create("Memory/mem"));
chordExtract->addMarSystem(mng.create("Mean/mean"));
chordExtract->addMarSystem(mng.create("Krumhansl_key_finder/kkf"));
chordExtract->updControl("mrs_natural/inSamples", hopSize);
chordExtract->updControl("ShiftInput/si/mrs_natural/winSize", winSize);
chordExtract->updControl("Memory/mem/mrs_natural/memSize", 120);
chordExtract->updControl("SoundFileSource/src/mrs_string/filename", sfName);
for (int i=0; i < contourSize; ++i)
{
chordExtract->tick();
chords(i) = chordExtract->getControl("Krumhansl_key_finder/kkf/mrs_natural/key")->to<mrs_natural>();
// cout << "chords(i) = " << chords(i) << endl;
chord_names.push_back(chordExtract->getControl("Krumhansl_key_finder/kkf/mrs_string/key_name")->to<mrs_string>());
}
delete pitchExtractor;
delete chordExtract;
// return chords.median();
return chords(contourSize-1-40);
}