本文整理汇总了C++中MarSystem::update方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::update方法的具体用法?C++ MarSystem::update怎么用?C++ MarSystem::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarSystem
的用法示例。
在下文中一共展示了MarSystem::update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
MarControl::callMarSystemUpdate()
{
if (state_ && msys_)
{
MarSystem* msys = msys_;
msys->update(this);
return;
}
}
示例2: 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;
}
示例3: if
//.........这里部分代码省略.........
//
if(C > 0) //use fixed and manually set number of clusters
{
cout << ">> Using fixed number of clusters: " << C << " clusters." << endl;
mainNet->updControl("FlowThru/clustNet/NormCut/NCut/mrs_natural/numClusters", C); //[!]
}
else if(C==0) //use GT number of clusters
{
cout << "** Using GT number of clusters." << endl;
mainNet->linkControl("FlowThru/clustNet/NormCut/NCut/mrs_natural/numClusters",
"Accumulator/textWinNet/Series/analysisNet/FanOutIn/mixer/Series/oriNet/MidiFileSynthSource/src/mrs_natural/numActiveNotes");
}
else if(C==-1) //automatically estimate number of clusters
{
cout << "Automatic Estimation of number of clusters: NOT YET IMPLEMENTED! Exiting...";
exit(0);
}
// //[TODO]
// mainNet->setctrl("PeClust/peClust/mrs_natural/selectedClusters", nbSelectedClusters_);
// mainNet->setctrl("PeClust/peClust/mrs_natural/hopSize", D);
// mainNet->setctrl("PeClust/peClust/mrs_natural/storePeaks", (mrs_natural) peakStore_);
// mainNet->updControl("PeClust/peClust/mrs_string/similarityType", T);
//
// similarityWeight_.stretch(3);
// similarityWeight_(0) = 1;
// similarityWeight_(1) = 10; //[WTF]
// similarityWeight_(2) = 1;
// mainNet->updControl("PeClust/peClust/mrs_realvec/similarityWeight", similarityWeight_);
if(noiseName != EMPTYSTRING)
mainNet->updControl("Accumulator/textWinNet/Series/analysisNet/SoundFileSink/mixSink/mrs_string/filename", mixName);
mainNet->update();
//check if input is a stereo signal
if(mainNet->getctrl("Accumulator/textWinNet/Series/analysisNet/FanOutIn/mixer/mrs_natural/onObservations")->to<mrs_natural>() == 1)
{
//if a not a stereo signal, we must set the Stereo2Mono weight to 1.0 (i.e. do no mixing)!
mainNet->updControl("Accumulator/textWinNet/Series/analysisNet/Series/peakExtract/Fanout/stereoFo/Series/spectrumNet/Stereo2Mono/s2m/mrs_real/weight", 1.0);
}
//------------------------------------------------------------------------
//check which similarity computations should be disabled (if any)
//------------------------------------------------------------------------
// Frequency Similarity
if(ignoreFrequency)
{
cout << "** Frequency Similarity Computation disabled!" << endl;
mainNet->updControl("FlowThru/clustNet/FanOutIn/simNet/mrs_string/disableChild",
"Series/freqSim");
}
else
cout << "** Frequency Similarity Computation enabled!" << endl;
// amplitude similarity
if(ignoreAmplitude)
{
cout << "** Amplitude Similarity Computation disabled!" << endl;
mainNet->updControl("FlowThru/clustNet/FanOutIn/simNet/mrs_string/disableChild",
"Series/ampSim");
}
else
cout << "** Amplitude Similarity Computation enabled!" << endl;
// HWPS similarity
if(ignoreHWPS)
{
示例4: bcoeffs
//.........这里部分代码省略.........
if(unprecise_)
mainNet->updControl("PeakConvert/conv/mrs_bool/improvedPrecision", false);
else
mainNet->updControl("PeakConvert/conv/mrs_bool/improvedPrecision", true);
if(noPeakPicking_)
mainNet->updControl("PeakConvert/conv/mrs_bool/picking", false);
mainNet->updControl("PeakConvert/conv/mrs_natural/frameMaxNumPeaks", S);
mainNet->updControl("PeakConvert/conv/mrs_string/frequencyInterval", intervalFrequency);
mainNet->updControl("PeakConvert/conv/mrs_natural/nbFramesSkipped", 0);//(N/D));
if (!disableClustering)
{
mainNet->updControl("FlowThru/clustNet/Series/NCutNet/Fanout/stack/NormCut/NCut/mrs_natural/numClusters", C);
mainNet->updControl("FlowThru/clustNet/Series/NCutNet/PeakClusterSelect/clusterSelect/mrs_natural/numClustersToKeep", nbSelectedClusters_);
}
// //[TODO]
// mainNet->setctrl("PeClust/peClust/mrs_natural/selectedClusters", nbSelectedClusters_);
// mainNet->setctrl("PeClust/peClust/mrs_natural/hopSize", D);
// mainNet->setctrl("PeClust/peClust/mrs_natural/storePeaks", (mrs_natural) peakStore_);
// mainNet->updControl("PeClust/peClust/mrs_string/similarityType", T);
//
// similarityWeight_.stretch(3);
// similarityWeight_(0) = 1;
// similarityWeight_(1) = 10; //[WTF]
// similarityWeight_(2) = 1;
// mainNet->updControl("PeClust/peClust/mrs_realvec/similarityWeight", similarityWeight_);
if(noiseName != EMPTYSTRING)
mainNet->updControl("Accumulator/textWinNet/Series/analysisNet/SoundFileSink/mixSink/mrs_string/filename", mixName);
mainNet->update();
//check if input is a stereo signal
if(mainNet->getctrl("Accumulator/textWinNet/Series/analysisNet/FanOutIn/mixer/mrs_natural/onObservations")->to<mrs_natural>() == 1)
{
//if a not a stereo signal, we must set the Stereo2Mono weight to 1.0 (i.e. do no mixing)!
mainNet->updControl("Accumulator/textWinNet/Series/analysisNet/Series/peakExtract/Fanout/stereoFo/Series/spectrumNet/Stereo2Mono/s2m/mrs_real/weight", 1.0);
}
//------------------------------------------------------------------------
//check which similarity computations should be disabled (if any)
//------------------------------------------------------------------------
if (!disableClustering)
{
// Frequency Similarity
if(ignoreFrequency)
{
cout << "** Frequency Similarity Computation disabled!" << endl;
mainNet->updControl("FlowThru/clustNet/FanOutIn/simNet/mrs_string/disableChild",
"Series/freqSim");
}
else
cout << "** Frequency Similarity Computation enabled!" << endl;
// amplitude similarity
if(ignoreAmplitude)
{
cout << "** Amplitude Similarity Computation disabled!" << endl;
mainNet->updControl("FlowThru/clustNet/FanOutIn/simNet/mrs_string/disableChild",
"Series/ampSim");
}
else
cout << "** Amplitude Similarity Computation enabled!" << endl;
// HWPS similarity
示例5: sftransform
// Play soundfile given by sfName, playbacknet contains the playback
// network of MarSystem objects
void sftransform(mrs_real gain, string outName)
{
MarSystemManager mng;
MarSystem* dest = mng.create("SoundFileSink", "dest");
dest->updctrl("mrs_string/filename", "sftransformOutput.au");
NetworkTCPSource* netSrc = new NetworkTCPSource("netSrc");
MarSystem* playbacknet = mng.create("Series", "playbacknet");
playbacknet->addMarSystem(netSrc);
playbacknet->addMarSystem(mng.create("InvSpectrum", "ispk"));
playbacknet->addMarSystem(mng.create("Gain", "gt"));
playbacknet->addMarSystem(dest);
// update controls if they are passed on cmd line...
if ( port != 0 ) {
netSrc->updctrl("mrs_natural/port", port);
}
playbacknet->update();
playbacknet->linkctrl("mrs_natural/nChannels", "NetworkTCPSource/netSrc/mrs_natural/nChannels");
playbacknet->linkctrl("mrs_natural/pos", "NetworkTCPSource/netSrc/mrs_natural/pos");
playbacknet->linkctrl("mrs_natural/nChannels", "SoundFileSink/dest/mrs_natural/nChannels");
playbacknet->linkctrl("mrs_bool/hasData", "NetworkTCPSource/netSrc/mrs_bool/hasData");
playbacknet->linkctrl("mrs_bool/mute", "Gain/gt/mrs_bool/mute");
// output network description to cout
cout << *playbacknet << endl;
// setup TCP Server and wait for connection...
netSrc->refresh();
cout << "Connection Established with: " << netSrc->getClientAddr() << endl;
// udpate controls
//playbacknet.updctrl("mrs_natural/inSamples", MRS_DEFAULT_SLICE_NSAMPLES);
playbacknet->updctrl("Gain/gt/mrs_real/gain", gain);
mrs_natural wc=0;
mrs_natural samplesPlayed = 0;
mrs_natural onSamples = playbacknet->getctrl("mrs_natural/onSamples")->to<mrs_natural>();
// mrs_natural repeatId = 1;
mrs_real* controls = 0;
while (true)
{
try {
controls = playbacknet->recvControls();
if ( controls != 0 ) {
// get some reference controls, so if they have changed we update them
mrs_natural inSamples = playbacknet->getctrl("mrs_natural/inSamples")->to<mrs_natural>();
mrs_natural inObservations = playbacknet->getctrl("mrs_natural/inObservations")->to<mrs_natural>();
mrs_real israte = playbacknet->getctrl("mrs_real/israte")->to<mrs_real>();
if ( (mrs_natural)controls[1] != inSamples || (mrs_natural)controls[2] != inObservations
|| controls[3] != israte ) {
playbacknet->updctrl("mrs_natural/inSamples", (mrs_natural)controls[1]);
playbacknet->updctrl("mrs_natural/inObservations", (mrs_natural)controls[2]);
playbacknet->updctrl("mrs_real/israte", controls[3]);
}
}
playbacknet->tick();
}
catch( SocketException e ) {
cerr << "Played " << wc << " slices of " << onSamples << " samples" << endl;
exit(1);
}
wc ++;
samplesPlayed += onSamples;
}
}
示例6: 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;
}
示例7: recognize
//.........这里部分代码省略.........
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));
dtw->updControl("mrs_realvec/sizes",sizes);
dtw->setctrl("mrs_realvec/delta", delta);
dtw->setctrl("mrs_real/deltaWeight", 10.0);
dtw->updControl("mrs_natural/inSamples",simOutput.getCols());
示例8: 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 ++;
//.........这里部分代码省略.........
示例9: PluckLive
//Pluck Karplus Strong Model Plucked.cpp outputs to DAC
void PluckLive(string deviceopt, mrs_real pos, mrs_real fre, mrs_real loz, mrs_real stret)
{
#ifdef MARSYAS_MIDIIO
RtMidiIn *midiin = 0;
std::vector<unsigned char> message;
double stamp;
int nBytes;
int i;
// initialize RtMidi
try {
midiin = new RtMidiIn();
}
catch (RtError3 &error) {
error.printMessage();
exit(1);
}
// find input midi port
try {
midiin->openPort(portopt);
}
catch (RtError3 &error) {
error.printMessage();
exit(1);
}
MarSystemManager mng;
MarSystem* series = mng.create("Series", "series");
// create 16 plucked Karplus-Strong strings
MarSystem* mix = mng.create("Fanout", "mix");
for (mrs_natural i = 0; i < 16; i++)
{
ostringstream oss;
oss << "src" << i;
mix->addMarSystem(mng.create("Plucked", oss.str()));
}
series->addMarSystem(mix);
series->addMarSystem(mng.create("Sum", "sum"));
series->addMarSystem(mng.create("Gain", "gain"));
series->addMarSystem(mng.create("AudioSink", "dest"));
series->update();
series->updctrl("Gain/gain/mrs_real/gain", 0.10);
series->updctrl("AudioSink/dest/mrs_real/israte",
series->getctrl("Fanout/mix/Plucked/src0/mrs_real/osrate"));
series->updctrl("AudioSink/dest/mrs_natural/bufferSize", 128);
series->updctrl("Fanout/mix/Plucked/src0/mrs_real/frequency",fre);
series->updctrl("Fanout/mix/Plucked/src0/mrs_real/pluckpos",pos);
series->updctrl("Fanout/mix/Plucked/src0/mrs_real/loss",loz);
series->updctrl("mrs_natural/inSamples", 64);
series->update();
// initially only play one string
for (int i=1; i < 16; i++)
{
ostringstream oss1;
oss1 << "Fanout/mix/Plucked/src"
<< i << "/mrs_real/nton";
series->updctrl(oss1.str(), 0.0);
}
mrs_natural t=0;
int channel, type, byte2, byte3;
int mes_count = 0;
mrs_real freq;
int p0byte3, p1byte3, p2byte3;
// used to keep track of polyphony
vector<int> voices;
for (int i=0; i < 16; i++)
{
voices.push_back(0);
}
while(1)
{
// for (int i=0; i < 4; i++)
// {
stamp = midiin->getMessage( &message );
// }
//.........这里部分代码省略.........