本文整理汇总了C++中MarSystem::setctrl方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::setctrl方法的具体用法?C++ MarSystem::setctrl怎么用?C++ MarSystem::setctrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarSystem
的用法示例。
在下文中一共展示了MarSystem::setctrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recognize
void recognize(string sfName, string outName)
{
MarSystemManager mng;
mrs_realvec out, tmpvec;
mrs_natural inputsize, wsize;
mrs_real samplingFreq;
Collection inputs;
MarSystem* all = mng.create("Series", "all");
MarSystem* acc = mng.create("Accumulator", "acc");
MarSystem* net = mng.create("Series", "net");
MarSystem* total = mng.create("Series", "total");
MarSystem* src = mng.create("SoundFileSource", "src");
MarSystem* spc = mng.create("Spectrum", "spc");
MarSystem* pws = mng.create("PowerSpectrum", "pws");
MarSystem* crm = mng.create("Chroma","crm");
MarSystem* csl = mng.create("ChromaScale","csl");
MarSystem* ff = mng.create("Fanout", "ff");
MarSystem* ss = mng.create("Fanout", "ss");
MarSystem* mn = mng.create("Mean", "mn");
MarSystem* std = mng.create("StandardDeviation", "std");
MarSystem* mfccnet = mng.create("Series", "mfccnet");
MarSystem* ant = mng.create("Annotator", "ant");
MarSystem* wks = mng.create("WekaSink", "wks");
MarSystem* wksnet = mng.create("Series", "wksnet");
inputs.read(sfName);
mfccnet->addMarSystem(mng.create("Spectrum","spc2"));
mfccnet->addMarSystem(mng.create("PowerSpectrum","psc2"));
mfccnet->addMarSystem(mng.create("MFCC", "mfcc"));
total->addMarSystem(src);
total->addMarSystem(ff);
net->addMarSystem(spc);
net->addMarSystem(pws);
net->addMarSystem(crm);
net->addMarSystem(csl);
ff->addMarSystem(mfccnet);
ff->addMarSystem(net);
acc->addMarSystem(total);
all->addMarSystem(acc);
ss->addMarSystem(mn);
ss->addMarSystem(std);
all->addMarSystem(ss);
wksnet->addMarSystem(ant);
wksnet->addMarSystem(wks);
wksnet->updControl("mrs_natural/inSamples", 1);
wksnet->updControl("mrs_natural/inObservations", all->getctrl("mrs_natural/onObservations")->to<mrs_natural>());
wksnet->updControl("WekaSink/wks/mrs_string/labelNames", inputs.getLabelNames()); // change to just sfName
wksnet->updControl("WekaSink/wks/mrs_natural/nLabels", (mrs_natural)inputs.getNumLabels()); // change to just 1
wksnet->updControl("WekaSink/wks/mrs_natural/downsample", 1);
wksnet->updControl("WekaSink/wks/mrs_string/filename", outName);
tmpvec.create(all->getctrl("mrs_natural/onObservations")->to<mrs_natural>()+1,1);
for(mrs_natural i=0; i<inputs.size(); ++i) {
cout << "Now processing: " << inputs.entry(i) << endl;
src->updControl("mrs_string/filename", inputs.entry(i));
//spc->updControl("mrs_natural/inSamples", 1024);
inputsize = src->getctrl("mrs_natural/size")->to<mrs_natural>();
wsize = src->getctrl("mrs_natural/onSamples")->to<mrs_natural>();
inputsize /= wsize;
acc->updControl("mrs_natural/nTimes", inputsize);
samplingFreq = src->getctrl("mrs_real/israte")->to<mrs_real>();
all->update();
crm->setctrl("mrs_real/samplingFreq", samplingFreq);
crm->setctrl("mrs_natural/lowOctNum", 2);
crm->setctrl("mrs_natural/highOctNum", 5);
crm->setctrl("mrs_natural/inObservations", wsize/2);
crm->update();
csl->setctrl("mrs_natural/inObservations", 12);
csl->update();
all->tick();
out = all->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
wksnet->updControl("Annotator/ant/mrs_natural/label", (mrs_natural)inputs.labelNum(inputs.labelEntry(i))); // change to just 0
wksnet->updControl("WekaSink/wks/mrs_string/currentlyPlaying", inputs.entry(i));
wksnet->process(out, tmpvec);
}
delete all;
delete wksnet;
}
示例2: recognize
//.........这里部分代码省略.........
/*** calculate input feature vector of input ***/
featuresInp.stretch(BIN,dataInp.getCols());
for(i=0; i<featuresInp.getRows(); ++i){
for(j=0; j<featuresInp.getCols(); j++){
featuresInp(i,j) = 0;
}
}
sfrq = netInp->getctrl("SoundFileSource/inpsrc/mrs_real/osrate")->to<mrs_real>();
obs = netInp->getctrl("mrs_natural/onObservations")->to<mrs_natural>();
for(i=0; i<BIN+2; ++i){
b(i) = wsize*700/sfrq*(pow(10, (log10(1.0+sfrq/1400))*i/(BIN+1))-1);
}
for(j=0; j<BIN; j++){
for(k=0; k<obs; k++){
if(b(j) < k && k < b(j+1)){
for(i=0; i<dataInp.getCols(); ++i){
featuresInp(j,i) += dataInp(k,i)*(k-b(j))/(b(j+1)-b(j));
}
} else if(b(j+1) <= k && k <= b(j+2)){
for(i=0; i<dataInp.getCols(); ++i){
featuresInp(j,i) += dataInp(k,i)*(b(j+2)-k)/(b(j+2)-b(j+1));
}
}
}
for(i=0; i<featuresInp.getCols(); ++i){
featuresInp(j,i) /= (b(j+2)-b(j))/2;
featuresInp(j,i) = log(100000*featuresInp(j,i)+1);
}
}
dataInp.stretch(0,0);
// calculate input chroma delta
crm->setctrl("mrs_real/samplingFreq", sfrq);
crm->setctrl("mrs_natural/lowOctNum", 0);
crm->setctrl("mrs_natural/highOctNum", 8);
crm->setctrl("mrs_natural/inObservations", wsize/2);
crm->update();
dlt->setctrl("mrs_bool/sum", true);
dlt->setctrl("mrs_bool/absolute", true);
dlt->setctrl("mrs_bool/normalize", true);
dlt->setctrl("mrs_natural/normSize", 40);
dlt->update();
Inp2->tick();
delta = Inp2->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
/*** calculate input of SimilarityMatrix ***/
simInput.stretch(featuresInp.getRows()+featuresTpl.getRows(),featuresInp.getCols());
for(i=0; i<featuresInp.getCols(); ++i){
for(j=0; j<featuresInp.getRows(); j++){
simInput(j,i) = featuresInp(j,i);
}
}
for(i=0; i<featuresTpl.getCols(); ++i){
for(j=0; j<featuresTpl.getRows(); j++){
simInput(j+featuresInp.getRows(),i) = featuresTpl(j,i);
}
}
/*** update control of rhythm map ***/
sizes(0) = featuresInp.getCols();
sim->updControl("mrs_realvec/sizes",sizes);
sim->updControl("mrs_natural/inSamples",simInput.getCols());
sim->updControl("mrs_natural/inObservations",simInput.getRows());
simOutput.stretch(outsize,sizes(0));
示例3: record_orcas
void record_orcas(mrs_real length, mrs_natural year,
string id1, string id2, string id3, string id4)
{
copt = 8;
sropt = 44100.0;
int bufferSize = 6144;
MarSystemManager mng;
MarSystem* asrc = mng.create("AudioSource", "asrc");
MarSystem* dest1 = mng.create("SoundFileSink", "dest1");
MarSystem* dest2 = mng.create("SoundFileSink", "dest2");
MarSystem* dest3 = mng.create("SoundFileSink", "dest3");
MarSystem* dest4 = mng.create("SoundFileSink", "dest4");
ostringstream oss1;
oss1 << "/Users/orcalab/orcaArchive/" << year << "/" << id1 << ".wav";
ostringstream oss2;
oss2 << "/Users/orcalab/orcaArchive/" << year << "/" << id2 << ".wav";
ostringstream oss3;
oss3 << "/Users/orcalab/orcaArchive/" << year << "/" << id3 << ".wav";
ostringstream oss4;
oss4 << "/Users/orcalab/orcaArchive/" << year << "/" << id4 << ".wav";
string fname1 = oss1.str();
string fname2 = oss2.str();
string fname3 = oss3.str();
string fname4 = oss4.str();
dest1->updControl("mrs_natural/inObservations", 2);
dest1->updControl("mrs_natural/inSamples", bufferSize);
dest1->updControl("mrs_real/israte", sropt);
dest1->updControl("mrs_string/filename", fname1);
dest2->updControl("mrs_natural/inObservations", 2);
dest2->updControl("mrs_natural/inSamples", bufferSize);
dest2->updControl("mrs_real/israte", sropt);
dest2->updControl("mrs_string/filename", fname2);
dest3->updControl("mrs_natural/inObservations", 2);
dest3->updControl("mrs_natural/inSamples", bufferSize);
dest3->updControl("mrs_real/israte", sropt);
dest3->updControl("mrs_string/filename", fname3);
dest4->updControl("mrs_natural/inObservations", 2);
dest4->updControl("mrs_natural/inSamples", bufferSize);
dest4->updControl("mrs_real/israte", sropt);
dest4->updControl("mrs_string/filename", fname4);
asrc->setctrl("mrs_natural/nChannels", copt);
asrc->setctrl("mrs_natural/inSamples", bufferSize);
asrc->setctrl("mrs_real/israte", sropt);
asrc->update();
// asrc->updControl("mrs_real/gain", gain);
mrs_real srate = asrc->getctrl("mrs_real/israte")->to<mrs_real>();
mrs_natural inSamples = asrc->getctrl("mrs_natural/inSamples")->to<mrs_natural>();
mrs_natural iterations = (mrs_natural)((srate * length * 60.0) / inSamples);
realvec rin;
realvec rout;
realvec orca1;
realvec orca2;
realvec orca3;
realvec orca4;
rin.create(copt, bufferSize);
rout.create(copt, bufferSize);
orca1.create(2, bufferSize);
orca2.create(2, bufferSize);
orca3.create(2, bufferSize);
orca4.create(2, bufferSize);
mrs_natural t;
cout << "Recording " << length << " minutes to files: " << endl;
cout << fname1 << endl;
cout << fname2 << endl;
cout << fname3 << endl;
cout << fname4 << endl;
mrs_natural minutes =0;
for (mrs_natural i = 0; i < iterations; ++i)
{
if (((i % 430)==0)&&(i != 0))
{
minutes ++;
//.........这里部分代码省略.........
示例4: outputWaveformPNG
void outputWaveformPNG(string inFileName, string outFileName)
{
#ifdef MARSYAS_PNG
int length;
int height = 150;
int middle_right;
int middle_left;
double min = 99999999999.9;
double max = -99999999999.9;
length = getFileLengthForWaveform(inFileName,windowSize_,min,max);
double pngLength = length;
double pngHeight = height;
pngwriter png(length,height,0,outFileName.c_str());
MarSystemManager mng;
// A series to contain everything
MarSystem* net = mng.create("Series", "net");
// The sound file
net->addMarSystem(mng.create("SoundFileSource", "src"));
net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);
net->updControl("SoundFileSource/src/mrs_natural/pos", position_);
net->setctrl("mrs_natural/inSamples", windowSize_);
net->addMarSystem(mng.create("MaxMin","maxmin"));
mrs_natural channels = net->getctrl("mrs_natural/onObservations")->to<mrs_natural>();
if (verboseopt_) {
cout << "channels=" << channels << endl;
}
if (channels == 2) {
middle_right = (height/4);
middle_left = (height/2)+(height/4);
} else {
middle_left = (height/2);
}
realvec processedData;
// Give it a white background
png.invert();
// A line across the middle of the plot
png.line(0,middle_left,length,middle_left,0,0,0);
if (channels == 2) {
png.line(0,middle_right,length,middle_right,0,0,0);
}
double x = 0;
double y_max_right = 0;
double y_min_right = 0;
double y_max_right_prev = 0;
double y_min_right_prev = 0;
double y_max_left = 0;
double y_min_left = 0;
double y_max_left_prev = 0;
double y_min_left_prev = 0;
double draw_color;
// If we are just displaying individual samples, make the line dark blue.
if (windowSize_ == 1) {
draw_color = 0.0;
} else {
draw_color = 0.2;
}
while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()
&& (ticks_ == -1 || x < ticks_)) {
net->tick();
processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
if (channels == 2) {
y_max_right = processedData(1,0) / 2.0 * height;
y_min_right = processedData(1,1) / 2.0 * height;
}
y_max_left = processedData(0,0) / 2.0 * height;
y_min_left = processedData(0,1) / 2.0 * height;
//
// Draw the right waveform
//
if (channels == 2) {
// Draw a line from the maximum to the minimum value
png.line(x,middle_right+y_min_right,x,middle_right+y_max_right,0.0,0.0,1.0);
// Shade the middle part of the line lighter blue
double right_height = (y_max_right - y_min_right) / 4.0;
png.line(x,(middle_right+y_min_right)+right_height,x,(middle_right+y_max_right)-right_height,0.5,0.5,1.0);
//.........这里部分代码省略.........
示例5: correlogramPNGs
void correlogramPNGs(string inFileName, string outFilePrefix)
{
#ifdef MARSYAS_PNG
MarSystemManager mng;
MarSystem* net = mng.create("Series", "net");
net->addMarSystem(mng.create("SoundFileSource", "src"));
net->addMarSystem(mng.create("Stereo2Mono", "stereo2mono"));
net->addMarSystem(mng.create("AudioSink", "dest"));
net->addMarSystem(mng.create("Windowing", "ham"));
net->addMarSystem(mng.create("Spectrum", "spk"));
net->addMarSystem(mng.create("PowerSpectrum", "pspk"));
net->addMarSystem(mng.create("Memory", "mem"));
MarSystem* parallel = mng.create("Parallel", "parallel");
net->addMarSystem(parallel);
int powerSpectrumSize = (windowSize_/2)+1;
for (int i = 0; i < powerSpectrumSize; ++i) {
std::stringstream ss;
ss << "auto" << i;
parallel->addMarSystem(mng.create("AutoCorrelation", ss.str()));
}
net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);
net->setctrl("mrs_natural/inSamples", windowSize_);
net->updControl("Memory/mem/mrs_natural/memSize", memorySize_);
net->updControl("mrs_real/israte", 44100.0);
net->updControl("AudioSink/dest/mrs_bool/initAudio", true);
realvec data;
int counter = 0;
realvec max_data(powerSpectrumSize);
while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()) {
cout << "Processing tick " << counter << endl;
net->tick();
data = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
// cout << "data" << data << endl;
// Create the png we are going to write into
std::stringstream outFileName;
outFileName << outFilePrefix << std::setfill('0') << std::setw(5) << counter << ".png";
pngwriter png(int(windowSize_),int(powerSpectrumSize),0,outFileName.str().c_str());
// Find the maximum value of the data
max_data.setval(-999.9);
for (int x = 0; x < memorySize_; x++) {
for (int y = 0; y < powerSpectrumSize; y++) {
if (data(y,x) > max_data(y)) {
max_data(y) = data(y,x);
}
}
}
// for (int x = 0; x < memorySize; x++) {
// cout << "max_data(" << x << ")" << max_data(x) << endl;
// }
// Plot all the data points
for (int x = 0; x < memorySize_; x++) {
for (int y = 0; y < powerSpectrumSize; y++) {
double color = 1.0 - (double(data(y,x)) * (1.0 / max_data(y)));
// cout << "x=" << x << " y=" << y << " data(y,x)=" << data(y,x) << " color=" << color << endl;
png.plot(int(x),int(y),color,color,color);
}
}
png.close();
counter++;
}
#endif
}
示例6: channel
int
main(int argc, const char **argv)
{
string name = argv[1];
mrs_natural channel(atoi(argv[2]));
mrs_natural window(atoi(argv[3]));
mrs_real gain(atof(argv[4]));
MarSystemManager mng;
MarSystem* src = mng.create("SoundFileSource", "src");
MarSystem* erb = mng.create("ERB","ERBfilterBank");
MarSystem* dest = mng.create("AudioSink", "dest");
src->updctrl("mrs_natural/inSamples", window);
src->updctrl("mrs_string/filename", name);
// This core dumps. Need to check it out.
erb->setctrl("mrs_natural/inObservations", src->getctrl("mrs_natural/onObservations"));
cout << *src << endl;
cout << src->getctrl("mrs_natural/onObservations") << endl;
cout << src->getctrl("mrs_natural/onSamples") << endl;
erb->updctrl("mrs_natural/inObservations", 1);
erb->updctrl("mrs_natural/inSamples", src->getctrl("mrs_natural/onSamples"));
erb->updctrl("mrs_real/israte",src->getctrl("mrs_real/osrate"));
erb->updctrl("mrs_natural/numChannels",64);
erb->updctrl("mrs_real/lowFreq",100.0f);
dest->updctrl("mrs_natural/inObservations", src->getctrl("mrs_natural/onObservations"));
dest->updctrl("mrs_natural/inSamples", src->getctrl("mrs_natural/onSamples"));
dest->updctrl("mrs_real/israte", src->getctrl("mrs_real/osrate"));
dest->updctrl("mrs_natural/nChannels", 1);
dest->updctrl("mrs_bool/initAudio", true);
realvec src_in, dest_in;
realvec src_out, erb_out, dest_out;
src_in.create(src->getctrl("mrs_natural/inObservations")->to<mrs_natural>(), src->getctrl("mrs_natural/inSamples")->to<mrs_natural>());
src_out.create(src->getctrl("mrs_natural/onObservations")->to<mrs_natural>(), src->getctrl("mrs_natural/onSamples")->to<mrs_natural>());
erb_out.create(erb->getctrl("mrs_natural/onObservations")->to<mrs_natural>(), erb->getctrl("mrs_natural/onSamples")->to<mrs_natural>());
dest_in.create(dest->getctrl("mrs_natural/inObservations")->to<mrs_natural>(), dest->getctrl("mrs_natural/inSamples")->to<mrs_natural>());
dest_out.create(dest->getctrl("mrs_natural/onObservations")->to<mrs_natural>(), dest->getctrl("mrs_natural/onSamples")->to<mrs_natural>());
while (src->getctrl("mrs_bool/hasData")->to<mrs_bool>()){
src->process(src_in, src_out);
erb->process(src_out, erb_out);
for (mrs_natural i = 0; i < erb->getctrl("mrs_natural/onSamples")->to<mrs_natural>(); i++){
dest_in(i) = gain*erb_out(channel,i);
}
dest->process(dest_in, dest_out);
}
return 0;
}