本文整理汇总了C++中MarSystem::linkControl方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::linkControl方法的具体用法?C++ MarSystem::linkControl怎么用?C++ MarSystem::linkControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarSystem
的用法示例。
在下文中一共展示了MarSystem::linkControl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: value
void
distance_matrix()
{
if (!wekafname_Set()) return;
cout << "Distance matrix calculation using " << wekafname_ << endl;
wekafname_ = inputdir_ + wekafname_;
MarSystemManager mng;
MarSystem* net = mng.create("Series", "net");
MarSystem* wsrc = mng.create("WekaSource", "wsrc");
net->addMarSystem(wsrc);
//!!!: mode control
net->updControl("WekaSource/wsrc/mrs_string/validationMode", "OutputInstancePair");
net->updControl("WekaSource/wsrc/mrs_bool/normMaxMin", true);
net->updControl("WekaSource/wsrc/mrs_string/filename", wekafname_);
MarSystem* dmatrix = mng.create("SelfSimilarityMatrix", "dmatrix");
dmatrix->addMarSystem(mng.create("Metric", "dmetric"));
dmatrix->updControl("Metric/dmetric/mrs_string/metric", "euclideanDistance");
//!!!: lmartins: normalization can only be applied when we have all feature vectors in memory...
//... which is what we are trying to avoid here (having big realvecs in memory)...
//dmatrix->updControl("mrs_string/normalize", "MinMax");
net->addMarSystem(dmatrix);
//!!!: mode control
net->updControl("SelfSimilarityMatrix/dmatrix/mrs_natural/mode", 1); //FIXME: replace use of enum for strings?
//link controls between WekaSource and SelfSimilarityMatrix
net->linkControl("SelfSimilarityMatrix/dmatrix/mrs_natural/nInstances",
"WekaSource/wsrc/mrs_natural/nInstances");
net->linkControl("WekaSource/wsrc/mrs_realvec/instanceIndexes",
"SelfSimilarityMatrix/dmatrix/mrs_realvec/instanceIndexes");
ofstream oss;
oss.open(distancematrix_.c_str());
oss << "Marsyas-kea distance matrix" << endl;
while(!net->getctrl("SelfSimilarityMatrix/dmatrix/mrs_bool/done")->to<bool>())
{
const mrs_realvec& idxs = net->getctrl("SelfSimilarityMatrix/dmatrix/mrs_realvec/instanceIndexes")->to<mrs_realvec>();
oss << "(" << mrs_natural(idxs(0)) << "," << mrs_natural(idxs(1)) << ") = ";
net->tick();
const mrs_realvec& value = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
oss << value(0) << endl;
}
oss << endl;
}
示例2: while
int
isClose(string infile1, string infile2)
{
MarSystemManager mng;
MarSystem* pnet = mng.create("Series", "pnet");
MarSystem* invnet = mng.create("Series", "invnet");
invnet->addMarSystem(mng.create("SoundFileSource", "src2"));
invnet->updControl("SoundFileSource/src2/mrs_string/filename", infile2);
invnet->addMarSystem(mng.create("Negative", "neg"));
MarSystem* fanout = mng.create("Fanout", "fanout");
fanout->addMarSystem(mng.create("SoundFileSource", "src1"));
fanout->updControl("SoundFileSource/src1/mrs_string/filename", infile1);
fanout->addMarSystem(invnet);
pnet->addMarSystem(fanout);
pnet->addMarSystem(mng.create("Sum", "sum"));
pnet->linkControl("mrs_bool/hasData",
"Fanout/fanout/SoundFileSource/src1/mrs_bool/hasData");
mrs_natural i;
mrs_natural samples =
pnet->getctrl("mrs_natural/inSamples")->to<mrs_natural>();
while ( pnet->getctrl("mrs_bool/hasData")->to<mrs_bool>() )
{
pnet->tick();
const realvec& processedData =
pnet->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
for (i=0; i<samples; ++i)
{
// useful for tweaking CLOSE_ENOUGH
//cout<<processedData(i)<<" ";
if ( abs(processedData(i)) > CLOSE_ENOUGH )
{
delete pnet;
return(1);
}
}
}
delete pnet;
return 0;
}
示例3: if
//.........这里部分代码省略.........
MarSystem* LRnet = mng.create("Parallel","LRnet");
//
MarSystem* spkL = mng.create("Series","spkL");
spkL->addMarSystem(mng.create("Windowing","win"));
spkL->addMarSystem(mng.create("Spectrum","spk"));
LRnet->addMarSystem(spkL);
//
MarSystem* spkR = mng.create("Series","spkR");
spkR->addMarSystem(mng.create("Windowing","win"));
spkR->addMarSystem(mng.create("Spectrum","spk"));
LRnet->addMarSystem(spkR);
//
//add it to the stereo spectrum net series
stereoSpkNet->addMarSystem(LRnet);
//
//add stereo spectrum object to stereo spectrum net
//stereoSpkNet->addMarSystem(mng.create("StereoSpectrum","stereoSpk")); //AVENDANO
stereoSpkNet->addMarSystem(mng.create("EnhADRess","ADRess"));//enhADRess_1
stereoSpkNet->addMarSystem(mng.create("EnhADRessStereoSpectrum","stereoSpk")); //enhADRess_2
//
// add the stereo Spectrum net to the Fanout
stereoFo->addMarSystem(stereoSpkNet);
//
// add the fanout to the peakExtract net
peakExtract->addMarSystem(stereoFo);
//
//add peakExtract net to analysis net
analysisNet->addMarSystem(peakExtract);
//***************************************************************
//add PeakConvert to main SERIES for processing texture windows
//***************************************************************
mainNet->addMarSystem(mng.create("PeakConvert", "conv"));
mainNet->linkControl("Accumulator/textWinNet/Series/analysisNet/FanOutIn/mixer/Series/oriNet/MidiFileSynthSource/src/mrs_natural/winSize",
"Accumulator/textWinNet/Series/analysisNet/Series/peakExtract/ShiftInput/si/mrs_natural/winSize");
//***************************************************************
//create a FlowThru for the Clustering Network and add to main net
//***************************************************************
MarSystem* clustNet = mng.create("FlowThru", "clustNet");
mainNet->addMarSystem(clustNet);
//***************************************************************
// create Similarities Network and add it to ClustNet
//***************************************************************
MarSystem* simNet = mng.create("FanOutIn", "simNet");
simNet->updControl("mrs_string/combinator", "*");
//
//create Frequency similarity net and add it to simNet
//
MarSystem* freqSim = mng.create("Series","freqSim");
//--------
freqSim->addMarSystem(mng.create("PeakFeatureSelect","FREQfeatSelect"));
freqSim->updControl("PeakFeatureSelect/FREQfeatSelect/mrs_natural/selectedFeatures",
PeakFeatureSelect::pkFrequency | PeakFeatureSelect::barkPkFreq);
//--------
MarSystem* fsimMat = mng.create("SelfSimilarityMatrix","FREQsimMat");
fsimMat->addMarSystem(mng.create("Metric","FreqL2Norm"));
fsimMat->updControl("Metric/FreqL2Norm/mrs_string/metric","euclideanDistance");
fsimMat->updControl("mrs_natural/calcCovMatrix", SelfSimilarityMatrix::diagCovMatrix);
//fsimMat->updControl("mrs_string/normalize", "MinMax");
//fsimMat->linkControl("mrs_realvec/covMatrix", "Metric/FreqL2Norm/mrs_realvec/covMatrix");
freqSim->addMarSystem(fsimMat);
//--------
freqSim->addMarSystem(mng.create("RBF","FREQrbf"));
freqSim->updControl("RBF/FREQrbf/mrs_string/RBFtype","Gaussian");
示例4: tags
void tags() {
if (!wekafname_Set()) return;
if (!twekafname_Set()) return;
// The file paths we will be reading/writing to.
string testing_arff = inputdir_ + twekafname_;
string training_arff = inputdir_ + wekafname_;
string testing_predictions = outputdir_ + predictcollectionfname_;
string testing_predictions_arff = outputdir_ + twekafname_ + ".affinities.arff";
string training_predictions_arff = outputdir_ + wekafname_ + ".affinities.arff";
// Initialize the network, classifier, and weka source through which
// we will read our .arff files
MarSystemManager mng;
MarSystem* net = mng.create("Series", "series");
net->addMarSystem(mng.create("WekaSource", "wsrc"));
MarSystem* classifier = mng.create("Classifier", "cl");
net->addMarSystem(classifier);
net->addMarSystem(mng.create("Gain/gain"));
// Instantiate the correct classifier:
cout << "Selected classifier type = " << classifier_ << endl;
if (classifier_ == "GS") {
net->updControl("Classifier/cl/mrs_string/enableChild", "GaussianClassifier/gaussiancl");
} else if (classifier_ == "ZEROR") {
net->updControl("Classifier/cl/mrs_string/enableChild", "ZeroRClassifier/zerorcl");
} else if (classifier_ == "SVM") {
net->updControl("Classifier/cl/mrs_string/enableChild", "SVMClassifier/svmcl");
} else {
// TODO: ERROR CONDITION; ADD ERROR HANDLING HERE
}
/**
* TRAINING
*
* Read in the training arff data, and train the classifier.
**/
// Set up the weka source to read the training .arff
// and hook together some controls.
cout << "Training Filename = " << training_arff << endl;
net->updControl("WekaSource/wsrc/mrs_string/filename", training_arff);
net->updControl("mrs_natural/inSamples", 1);
net->updControl("Classifier/cl/mrs_natural/nClasses", net->getctrl("WekaSource/wsrc/mrs_natural/nClasses"));
net->linkControl("Classifier/cl/mrs_string/mode", "mrs_string/train");
// Tick over the training WekaSource until all lines in the training file have been read.
// FIXME: Remove the mode updates, unless someone can justify their existence.
// The mode is not switched to 'predict' until further down.
cout << "Reading features" << endl;
while (!net->getctrl("WekaSource/wsrc/mrs_bool/done")->to<mrs_bool>())
{
string mode = net->getctrl("WekaSource/wsrc/mrs_string/mode")->to<mrs_string>();
net->tick();
net->updControl("Classifier/cl/mrs_string/mode", mode);
}
// Switch the Classifier's mode to predict:
// This causes the classifier to train itself on all input data so far.
cout << "Training" << endl;
net->updControl("Classifier/cl/mrs_string/mode", "predict");
// Collect information about the labels (classes) in this dataset
mrs_natural nLabels = net->getctrl("WekaSource/wsrc/mrs_natural/nClasses")->to<mrs_natural>();
mrs_string labelNames = net->getctrl("WekaSource/wsrc/mrs_string/classNames")->to<mrs_string>();
vector<string> classNames;
// TODO: you could probably replace "s = ..." with "s = labelNames"
string s = net->getctrl("WekaSource/wsrc/mrs_string/classNames")->to<mrs_string>();
for (int i=0; i < nLabels; ++i)
{
string className;
string temp;
className = s.substr(0, s.find(","));
temp = s.substr(s.find(",") + 1, s.length());
s = temp;
classNames.push_back(className);
}
/**
* PREDICT STEP 1
*
* Predictions for the testing arff data.
**/
// Initialize the weka sink that we will use to write an .arff file
// for the testing dataset, where the features are the predicted
// probabilities from our classifier
MarSystem* testpSink = mng.create("WekaSink/testpSink");
testpSink->updControl("mrs_natural/inSamples", 1);
testpSink->updControl("mrs_natural/inObservations", nLabels+1);
testpSink->updControl("mrs_natural/nLabels", nLabels);
testpSink->updControl("mrs_string/labelNames", labelNames);
testpSink->updControl("mrs_string/inObsNames", labelNames);
testpSink->updControl("mrs_string/filename", testing_predictions_arff);
// Set up the weka source to read the testing data
cout << "Testing Filename = " << testing_arff << endl;
net->updControl("WekaSource/wsrc/mrs_string/filename", testing_arff);
cout << "Starting Prediction for Testing Collection" << endl;
//.........这里部分代码省略.........
示例5: while
void
train_evaluate()
{
if (!wekafname_Set()) return;
wekafname_ = inputdir_ + wekafname_;
cout << "Training classifier using .arff file: " << wekafname_ << endl;
cout << "Classifier type : " << classifier_ << endl;
MarSystemManager mng;
MarSystem* net;
net = mng.create("Series", "net");
net->addMarSystem(mng.create("WekaSource", "wsrc"));
net->addMarSystem(mng.create("Classifier", "cl"));
net->addMarSystem(mng.create("ClassificationReport", "summary"));
if (classifier_ == "GS")
net->updControl("Classifier/cl/mrs_string/enableChild", "GaussianClassifier/gaussiancl");
if (classifier_ == "ZEROR")
net->updControl("Classifier/cl/mrs_string/enableChild", "ZeroRClassifier/zerorcl");
if (classifier_ == "SVM")
net->updControl("Classifier/cl/mrs_string/enableChild", "SVMClassifier/svmcl");
// net->updControl("WekaSource/wsrc/mrs_string/attributesToInclude", "1,2,3");
// net->updControl("WekaSource/wsrc/mrs_string/validationMode", "PercentageSplit,50%");
net->updControl("WekaSource/wsrc/mrs_string/validationMode", "kFold,NS,10");
// net->updControl("WekaSource/wsrc/mrs_string/validationMode", "UseTestSet,lg.arff");
net->updControl("WekaSource/wsrc/mrs_string/filename", wekafname_);
net->updControl("mrs_natural/inSamples", 1);
if (classifier_ == "SVM") {
if (svm_svm_ != EMPTYSTRING) {
net->updControl("Classifier/cl/SVMClassifier/svmcl/mrs_string/svm",
svm_svm_);
}
if (svm_kernel_ != EMPTYSTRING) {
net->updControl("Classifier/cl/SVMClassifier/svmcl/mrs_string/kernel",
svm_kernel_);
}
}
if (net->getctrl("WekaSource/wsrc/mrs_bool/regression")->isTrue()) {
// TODO: enable regression for ZeroRClassifier and GaussianClassifier,
// and don't assume we're only dealing with svm
net->updControl("Classifier/cl/SVMClassifier/svmcl/mrs_bool/output_classPerms", false);
net->updControl("Classifier/cl/mrs_natural/nClasses", 1);
net->updControl("ClassificationReport/summary/mrs_natural/nClasses", 1);
net->updControl("ClassificationReport/summary/mrs_bool/regression", true);
} else {
net->updControl("ClassificationReport/summary/mrs_natural/nClasses", net->getctrl("WekaSource/wsrc/mrs_natural/nClasses"));
net->updControl("ClassificationReport/summary/mrs_string/classNames",
net->getctrl("WekaSource/wsrc/mrs_string/classNames"));
net->updControl("Classifier/cl/mrs_natural/nClasses", net->getctrl("WekaSource/wsrc/mrs_natural/nClasses"));
}
net->linkControl("Classifier/cl/mrs_string/mode", "ClassificationReport/summary/mrs_string/mode");
int i = 0;
while(net->getctrl("WekaSource/wsrc/mrs_bool/done")->to<mrs_bool>() == false)
{
net->tick();
// cout << net->getControl("WekaSource/wsrc/mrs_realvec/processedData")->to<mrs_realvec>() << endl;
string mode = net->getctrl("WekaSource/wsrc/mrs_string/mode")->to<mrs_string>();
net->updControl("Classifier/cl/mrs_string/mode", mode);
++i;
}
net->updControl("Classifier/cl/mrs_string/mode", "predict");
net->updControl("ClassificationReport/summary/mrs_bool/done", true);
net->tick();
delete net;
}
示例6: bcoeffs
//.........这里部分代码省略.........
HWPSsimMat->updControl("HWPS/hwps/mrs_bool/calcDistance", true);
HWPSim->addMarSystem(HWPSsimMat);
//--------
HWPSim->addMarSystem(mng.create("RBF","HWPSrbf"));
HWPSim->updControl("RBF/HWPSrbf/mrs_string/RBFtype","Gaussian");
HWPSim->updControl("RBF/HWPSrbf/mrs_bool/symmetricIn",true);
//--------
simNet->addMarSystem(HWPSim);
//
//create Panning similarity net and add it to simNet
//
MarSystem* panSim = mng.create("Series","panSim");
//--------
panSim->addMarSystem(mng.create("PeakFeatureSelect","PANfeatSelect"));
panSim->updControl("PeakFeatureSelect/PANfeatSelect/mrs_natural/selectedFeatures",
PeakFeatureSelect::pkPan);
//--------
MarSystem* psimMat = mng.create("SelfSimilarityMatrix","PANsimMat");
psimMat->addMarSystem(mng.create("Metric","PanL2Norm"));
psimMat->updControl("Metric/PanL2Norm/mrs_string/metric","euclideanDistance");
psimMat->updControl("mrs_natural/calcCovMatrix", SelfSimilarityMatrix::diagCovMatrix);
//psimMat->updControl("mrs_string/normalize", "MinMax");
//psimMat->linkControl("mrs_realvec/covMatrix", "Metric/PanL2Norm/mrs_realvec/covMatrix");
panSim->addMarSystem(psimMat);
//--------
panSim->addMarSystem(mng.create("RBF","PANrbf"));
panSim->updControl("RBF/PANrbf/mrs_string/RBFtype","Gaussian");
panSim->updControl("RBF/PANrbf/mrs_bool/symmetricIn",true);
//--------
simNet->addMarSystem(panSim);
//
// LINK controls of PeakFeatureSelects in each similarity branch
//
simNet->linkControl("Series/ampSim/PeakFeatureSelect/AMPfeatSelect/mrs_natural/totalNumPeaks",
"Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/totalNumPeaks");
simNet->linkControl("Series/HWPSim/PeakFeatureSelect/HWPSfeatSelect/mrs_natural/totalNumPeaks",
"Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/totalNumPeaks");
simNet->linkControl("Series/panSim/PeakFeatureSelect/PANfeatSelect/mrs_natural/totalNumPeaks",
"Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/totalNumPeaks");
//------
simNet->linkControl("Series/ampSim/PeakFeatureSelect/AMPfeatSelect/mrs_natural/frameMaxNumPeaks",
"Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/frameMaxNumPeaks");
simNet->linkControl("Series/HWPSim/PeakFeatureSelect/HWPSfeatSelect/mrs_natural/frameMaxNumPeaks",
"Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/frameMaxNumPeaks");
simNet->linkControl("Series/panSim/PeakFeatureSelect/PANfeatSelect/mrs_natural/frameMaxNumPeaks",
"Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/frameMaxNumPeaks");
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
//add simNet to clustNet
clustNet->addMarSystem(simNet);
//
// LINK controls related to variable number of peak from PeakConvert to simNet
//
if (!disableClustering)
{
mainNet->linkControl("FlowThru/clustNet/FanOutIn/simNet/Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/totalNumPeaks",
"PeakConvert/conv/mrs_natural/totalNumPeaks");
mainNet->linkControl("FlowThru/clustNet/FanOutIn/simNet/Series/freqSim/PeakFeatureSelect/FREQfeatSelect/mrs_natural/frameMaxNumPeaks",
"PeakConvert/conv/mrs_natural/frameMaxNumPeaks");
}
//***************************************************************
// create NCutNet MarSystem and add it to clustNet
//***************************************************************
MarSystem* NCutNet = mng.create("Series","NCutNet");
clustNet->addMarSystem(NCutNet);
//---add NCutNet components
示例7: speakerSeg
//.........这里部分代码省略.........
mfccSeries->updControl("mrs_natural/inObservations",16);
lspSeries->updControl("mrs_natural/inObservations",10);
// lspSeries->updControl("Memory/mem/mrs_natural/memSize", 5); //see above for an explanation why we use memSize = 5
// mfccSeries->updControl("Memory/mem2/mrs_natural/memSize", 5); //see above for an explanation why we use memSize = 5
//add a BIC change detector
lspSeries->addMarSystem(mng.create("BICchangeDetector", "BICdet"));
mfccSeries->addMarSystem(mng.create("BICchangeDetector", "BICdet2"));
// link top-level controls
// parallel->addMarSystem(lspSeries);
// parallel->addMarSystem(mfccSeries);
//create feature extraction network for calculating LSP-10
MarSystem* featExtractor = mng.create("Series", "featExtractor");
featExtractor->addMarSystem(mng.create("SoundFileSource", "src"));
featExtractor->addMarSystem(features);
accum->addMarSystem(featExtractor);
accum->updControl("mrs_natural/nTimes", minSegFrames/2);
pnet->addMarSystem(accum);
// pnet->addMarSystem(parallel);
pnet->addMarSystem(mng.create("ShiftInput", "si"));
pnet->updControl("ShiftInput/si/mrs_natural/winSize", 135);
pnet->linkControl("mrs_string/filename","Accumulator/accum/Series/featExtractor/SoundFileSource/src/mrs_string/filename");
pnet->linkControl("Accumulator/accum/mrs_natural/inSamples","mrs_natural/inSamples");
pnet->linkControl("Accumulator/accum/Series/featExtractor/mrs_natural/inSamples","mrs_natural/inSamples");
pnet->linkControl("Accumulator/accum/Series/featExtractor/SoundFileSource/src/mrs_natural/inSamples","mrs_natural/inSamples");
pnet->linkControl("Accumulator/accum/Series/featExtractor/Fanout/features/Series/lspFeatSeries/LPCnet/lpc/mrs_natural/inSamples","mrs_natural/inSamples");
pnet->linkControl("mrs_real/israte", "Accumulator/accum/Series/featExtractor/SoundFileSource/src/mrs_real/israte");
pnet->linkControl("mrs_natural/pos", "Accumulator/accum/Series/featExtractor/SoundFileSource/src/mrs_natural/pos");
// pnet->linkControl("mrs_bool/hasData", "Accumulator/accum/Series/featExtractor/SoundFileSource/src/mrs_bool/hasData");
pnet->linkControl("Accumulator/accum/Series/featExtractor/SoundFileSource/src/mrs_bool/hasData","mrs_bool/hasData");
pnet->linkControl("mrs_bool/MFCCMemreset", "Parallel/parallel/Series/mfccSeries/Memory/mem2/mrs_bool/reset");
pnet->linkControl("mrs_bool/LSPMemreset", "Parallel/parallel/Series/lspSeries/Memory/mem/mrs_bool/reset");
pnet->linkControl("mrs_bool/MFCCBICreset", "Parallel/parallel/Series/mfccSeries/BICchangeDetector/BICdet2/mrs_bool/reset");
pnet->linkControl("mrs_bool/LSPBICreset", "Parallel/parallel/Series/lspSeries/BICchangeDetector/BICdet/mrs_bool/reset");
//featExtractor->updControl("mrs_natural/inSamples", 125); //hardcoded for fs=8khz [!]
// play each collection or soundfile
vector<string>::iterator sfi;
for (sfi = soundfiles.begin(); sfi != soundfiles.end(); ++sfi)
{
string fname = *sfi;
//clear any memory data and any stored models
pnet->updControl("mrs_bool/LSPMemreset", true);
pnet->updControl("mrs_bool/LSPBICreset", true);
pnet->updControl("mrs_bool/MFCCMemreset", true);
pnet->updControl("mrs_bool/MFCCBICreset", true);
//set new file name
pnet->updControl("mrs_string/filename", fname);
// need to override the control to be 25 ms every time the file is read in.
示例8: 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");
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;
}
示例9: outputFile
void
detect_onsets(string sfName)
{
// cout << "toying with onsets" << endl;
MarSystemManager mng;
// assemble the processing network
MarSystem* onsetnet = mng.create("Series", "onsetnet");
MarSystem* onsetaccum = mng.create("Accumulator", "onsetaccum");
MarSystem* onsetseries= mng.create("Series","onsetseries");
onsetseries->addMarSystem(mng.create("SoundFileSource", "src"));
onsetseries->addMarSystem(mng.create("Stereo2Mono", "src")); //replace by a "Monofier" MarSystem (to be created) [!]
//onsetseries->addMarSystem(mng.create("ShiftInput", "si"));
//onsetseries->addMarSystem(mng.create("Windowing", "win"));
MarSystem* onsetdetector = mng.create("FlowThru", "onsetdetector");
onsetdetector->addMarSystem(mng.create("ShiftInput", "si")); //<---
onsetdetector->addMarSystem(mng.create("Windowing", "win")); //<---
onsetdetector->addMarSystem(mng.create("Spectrum","spk"));
onsetdetector->addMarSystem(mng.create("PowerSpectrum", "pspk"));
onsetdetector->addMarSystem(mng.create("Flux", "flux"));
//onsetdetector->addMarSystem(mng.create("Memory","mem"));
onsetdetector->addMarSystem(mng.create("ShiftInput","sif"));
onsetdetector->addMarSystem(mng.create("Filter","filt1"));
onsetdetector->addMarSystem(mng.create("Reverse","rev1"));
onsetdetector->addMarSystem(mng.create("Filter","filt2"));
onsetdetector->addMarSystem(mng.create("Reverse","rev2"));
onsetdetector->addMarSystem(mng.create("PeakerOnset","peaker"));
onsetseries->addMarSystem(onsetdetector);
onsetaccum->addMarSystem(onsetseries);
onsetnet->addMarSystem(onsetaccum);
//onsetnet->addMarSystem(mng.create("ShiftOutput","so"));
if(audiosynthopt)
{
//Audio synthesis
MarSystem* onsetmix = mng.create("Fanout","onsetmix");
onsetmix->addMarSystem(mng.create("Gain","gainaudio"));
MarSystem* onsetsynth = mng.create("Series","onsetsynth");
onsetsynth->addMarSystem(mng.create("NoiseSource","noisesrc"));
onsetsynth->addMarSystem(mng.create("ADSR","env"));
onsetsynth->addMarSystem(mng.create("Gain", "gainonsets"));
onsetmix->addMarSystem(onsetsynth);
onsetnet->addMarSystem(onsetmix);
//onsetnet->addMarSystem(mng.create("AudioSink", "dest"));
onsetnet->addMarSystem(mng.create("SoundFileSink", "fdest"));
}
///////////////////////////////////////////////////////////////////////////////////////
//link controls
///////////////////////////////////////////////////////////////////////////////////////
onsetnet->linkControl("mrs_bool/hasData",
"Accumulator/onsetaccum/Series/onsetseries/SoundFileSource/src/mrs_bool/hasData");
//onsetnet->linkControl("ShiftOutput/so/mrs_natural/Interpolation","mrs_natural/inSamples");
onsetnet->linkControl("Accumulator/onsetaccum/mrs_bool/flush",
"Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/PeakerOnset/peaker/mrs_bool/onsetDetected");
if (confidenceopt) {
onsetnet->linkControl("Fanout/onsetmix/Series/onsetsynth/Gain/gainonsets/mrs_real/gain",
"Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/PeakerOnset/peaker/mrs_real/confidence");
}
//onsetnet->linkControl("Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/Memory/mem/mrs_bool/reset",
// "Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/PeakerOnset/peaker/mrs_bool/onsetDetected");
//link FILTERS coeffs
onsetnet->linkControl("Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/Filter/filt2/mrs_realvec/ncoeffs",
"Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/Filter/filt1/mrs_realvec/ncoeffs");
onsetnet->linkControl("Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/Filter/filt2/mrs_realvec/dcoeffs",
"Accumulator/onsetaccum/Series/onsetseries/FlowThru/onsetdetector/Filter/filt1/mrs_realvec/dcoeffs");
///////////////////////////////////////////////////////////////////////////////////////
// update controls
///////////////////////////////////////////////////////////////////////////////////////
FileName outputFile(sfName);
onsetnet->updControl("Accumulator/onsetaccum/Series/onsetseries/SoundFileSource/src/mrs_string/filename", sfName);
if(audiosynthopt)
onsetnet->updControl("SoundFileSink/fdest/mrs_string/filename", outputFile.nameNoExt() + "_onsets.wav");
mrs_real fs = onsetnet->getctrl("mrs_real/osrate")->to<mrs_real>();
mrs_natural winSize = 2048;//2048;
mrs_natural hopSize = 512;//411;
// mrs_natural winSize = 4096;//2048;
// mrs_natural hopSize = 1024;//411;
mrs_natural lookAheadSamples = 6;
mrs_real thres = thresholdopt;
mrs_real textureWinMinLen = 0.050; //secs
mrs_natural minTimes = (mrs_natural) (textureWinMinLen*fs/hopSize); //12;//onsetWinSize+1;//15;
// cout << "MinTimes = " << minTimes << " (i.e. " << textureWinMinLen << " secs)" << endl;
mrs_real textureWinMaxLen = 60.000; //secs
mrs_natural maxTimes = (mrs_natural) (textureWinMaxLen*fs/hopSize);//1000; //whatever... just a big number for now...
// cout << "MaxTimes = " << maxTimes << " (i.e. " << textureWinMaxLen << " secs)" << endl;
// best result till now are using dB power Spectrum!
//.........这里部分代码省略.........
示例10: extractBpm
mrs_real extractBpm (string sfName) {
cout << "Onsets function calculation: " << sfName << endl;
MarSystemManager mng;
/*
* ONSET FUNCTION: Estrazione del flusso dell'energia spettrale del segnale audio
* La catena è composta da una sorgente sonora, una funzione di finestratura,
* due blocchi per computare la potenza spettrale ed in fine il blocco per calcolare
* il flusso.
*/
MarSystem* beatextractor = mng.create("Series", "beatextractor");
MarSystem* onset_strength = mng.create ("Series", "ostrenght");
MarSystem* acc = mng.create("Accumulator", "acc");
MarSystem* onsets = mng.create("Series", "onsets");
MarSystem* src = mng.create("SoundFileSource", "src");
MarSystem* s2m = mng.create("Stereo2Mono", "s2m");
MarSystem* si1 = mng.create("ShiftInput", "si");
MarSystem* windowing = mng.create("Windowing", "windows");
MarSystem* spectrum = mng.create("Spectrum", "spectrum");
MarSystem* powspec = mng.create("PowerSpectrum", "power");
MarSystem* flux = mng.create("Flux", "flux");
onsets->addMarSystem(src);
onsets->addMarSystem(s2m);
onsets->addMarSystem(si1);
onsets->addMarSystem(windowing);
onsets->addMarSystem(spectrum);
onsets->addMarSystem(powspec);
onsets->addMarSystem(flux);
//aggiunta della rete per il calcolo del flusso all'accumulatore
acc->addMarSystem(onsets);
//aggiunta del sistema flusso estrattore al blocco superiore
onset_strength->addMarSystem(acc);
onset_strength->addMarSystem(mng.create("ShiftInput", "si2"));
//aggiunta al componente principale
beatextractor->addMarSystem(onset_strength);
/*
* SECONDO SOTTOSISTEMA: TEMPO INDUCTION
* Questa parte del sistema di occupa della tempo induction
*/
MarSystem* timeind = mng.create("FlowThru", "timeind" );
timeind->addMarSystem(mng.create("Filter", "filt1"));
timeind->addMarSystem(mng.create("Reverse", "reverse"));
timeind->addMarSystem(mng.create("Filter", "filt2"));
timeind->addMarSystem(mng.create("Reverse", "reverse"));
timeind->addMarSystem(mng.create("AutoCorrelation", "acr"));
timeind->addMarSystem(mng.create("BeatHistogram", "histo"));
MarSystem* hfanout = mng.create("Fanout", "hfanout");
hfanout->addMarSystem(mng.create("Gain", "id1"));
hfanout->addMarSystem(mng.create("TimeStretch", "tsc1"));
timeind->addMarSystem(hfanout);
timeind->addMarSystem(mng.create("Sum", "hsum"));
timeind->addMarSystem(mng.create("Peaker", "peaker1"));
timeind->addMarSystem(mng.create("MaxArgMax", "mxr1"));
//aggiunta al beatextractor
beatextractor->addMarSystem(timeind);
beatextractor->addMarSystem(mng.create("BeatPhase","beatphase"));
beatextractor->addMarSystem(mng.create("Gain", "id"));
/*
* DEFINIZIONE ED ASSEGNAMENTO DEI PARAMETRI
*/
//Sorgente sonora
onsets->updControl("SoundFileSource/src/mrs_string/filename", sfName);
onsets->linkControl("mrs_bool/hasData", "SoundFileSource/src/mrs_bool/hasData");
//parametri per le finestrature e per l'accumulatore
mrs_natural winSize = 256;
mrs_natural hopSize = 128;
mrs_natural bwinSize = 2048;
mrs_natural bhopSize = 128;
onset_strength->updControl("Accumulator/acc/mrs_natural/nTimes", bhopSize);
onset_strength->updControl("ShiftInput/si2/mrs_natural/winSize",bwinSize);
//Coefficienti per il filtro
mrs_realvec bcoeffs (1,3);
bcoeffs(0) = 0.0564;
bcoeffs(1) = 0.1129;
bcoeffs(2) = 0.0564;
mrs_realvec acoeffs (1,3);
acoeffs(0) = 1.0000;
acoeffs(1) = -1.2247;
acoeffs(2) = 0.4504;
//.........这里部分代码省略.........