Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/system/MarSystemManager.cpp
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2010 George Tzanetakis <gtzan@cs.uvic.ca>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #include "../common_source.h"
00020 
00021 #include <marsyas/marsystems/ADRess.h>
00022 #include <marsyas/marsystems/ADRessSpectrum.h>
00023 #include <marsyas/marsystems/ADRessStereoSpectrum.h>
00024 #include <marsyas/marsystems/ADSR.h>
00025 #include <marsyas/marsystems/AMDF.h>
00026 #include <marsyas/marsystems/AbsMax.h>
00027 #include <marsyas/marsystems/AccentFilterBank.h>
00028 #include <marsyas/marsystems/Accumulator.h>
00029 #include <marsyas/marsystems/AdditiveOsc.h>
00030 #include <marsyas/marsystems/AimBoxes.h>
00031 #include <marsyas/marsystems/AimGammatone.h>
00032 #include <marsyas/marsystems/AimHCL.h>
00033 #include <marsyas/marsystems/AimHCL2.h>
00034 #include <marsyas/marsystems/AimLocalMax.h>
00035 #include <marsyas/marsystems/AimPZFC.h>
00036 #include <marsyas/marsystems/AimPZFC2.h>
00037 #include <marsyas/marsystems/AimSAI.h>
00038 #include <marsyas/marsystems/AimSSI.h>
00039 #include <marsyas/marsystems/AimVQ.h>
00040 #include <marsyas/marsystems/Annotator.h>
00041 #include <marsyas/marsystems/ArffFileSink.h>
00042 #include <marsyas/marsystems/AuFileSink.h>
00043 #include <marsyas/marsystems/AuFileSource.h>
00044 #include <marsyas/marsystems/AubioYin.h>
00045 #include <marsyas/marsystems/AutoCorrelation.h>
00046 #include <marsyas/marsystems/AutoCorrelationFFT.h>
00047 #include <marsyas/marsystems/BICchangeDetector.h>
00048 #include <marsyas/marsystems/BeatAgent.h>
00049 #include <marsyas/marsystems/BeatHistoFeatures.h>
00050 #include <marsyas/marsystems/BeatHistogram.h>
00051 #include <marsyas/marsystems/BeatHistogramFromPeaks.h>
00052 #include <marsyas/marsystems/BeatPhase.h>
00053 #include <marsyas/marsystems/BeatReferee.h>
00054 #include <marsyas/marsystems/BeatTimesSink.h>
00055 #include <marsyas/marsystems/Biquad.h>
00056 #include <marsyas/marsystems/BlitOsc.h>
00057 #include <marsyas/marsystems/CARFAC.h>
00058 #include <marsyas/marsystems/Cartesian2Polar.h>
00059 #include <marsyas/marsystems/Cascade.h>
00060 #include <marsyas/marsystems/Centroid.h>
00061 #include <marsyas/marsystems/Chroma.h>
00062 #include <marsyas/marsystems/ClassOutputSink.h>
00063 #include <marsyas/marsystems/ClassificationReport.h>
00064 #include <marsyas/marsystems/Clip.h>
00065 #include <marsyas/marsystems/Combinator.h>
00066 #include <marsyas/marsystems/CompExp.h>
00067 #include <marsyas/marsystems/Compressor.h>
00068 #include <marsyas/marsystems/Confidence.h>
00069 #include <marsyas/marsystems/ConstQFiltering.h>
00070 #include <marsyas/marsystems/CrossCorrelation.h>
00071 #include <marsyas/marsystems/DTW.h>
00072 #include <marsyas/marsystems/DeInterleaveSizecontrol.h>
00073 #include <marsyas/marsystems/Deinterleave.h>
00074 #include <marsyas/marsystems/Delay.h>
00075 #include <marsyas/marsystems/DelaySamples.h>
00076 #include <marsyas/marsystems/Delta.h>
00077 #include <marsyas/marsystems/DeltaFirstOrderRegression.h>
00078 #include <marsyas/marsystems/Differentiator.h>
00079 #include <marsyas/marsystems/DownSampler.h>
00080 #include <marsyas/marsystems/ERB.h>
00081 #include <marsyas/marsystems/EnhADRess.h>
00082 #include <marsyas/marsystems/EnhADRessStereoSpectrum.h>
00083 #include <marsyas/marsystems/FM.h>
00084 #include <marsyas/marsystems/FMeasure.h>
00085 #include <marsyas/marsystems/FanOutIn.h>
00086 #include <marsyas/marsystems/Fanin.h>
00087 #include <marsyas/marsystems/Fanout.h>
00088 #include <marsyas/marsystems/Filter.h>
00089 #include <marsyas/marsystems/FlowCutSource.h>
00090 #include <marsyas/marsystems/FlowThru.h>
00091 #include <marsyas/marsystems/FlowToControl.h>
00092 #include <marsyas/marsystems/Flux.h>
00093 #include <marsyas/marsystems/FullWaveRectifier.h>
00094 #include <marsyas/marsystems/GMMClassifier.h>
00095 #include <marsyas/marsystems/Gain.h>
00096 #include <marsyas/marsystems/GaussianClassifier.h>
00097 #include <marsyas/marsystems/HWPS.h>
00098 #include <marsyas/marsystems/HalfWaveRectifier.h>
00099 #include <marsyas/marsystems/HarmonicEnhancer.h>
00100 #include <marsyas/marsystems/Inject.h>
00101 #include <marsyas/marsystems/InvSpectrum.h>
00102 #include <marsyas/marsystems/KNNClassifier.h>
00103 #include <marsyas/marsystems/Kurtosis.h>
00104 #include <marsyas/marsystems/LPC.h>
00105 #include <marsyas/marsystems/LPCC.h>
00106 #include <marsyas/marsystems/LSP.h>
00107 #include <marsyas/marsystems/LyonPassiveEar.h>
00108 #include <marsyas/marsystems/MFCC.h>
00109 #include <marsyas/marsystems/Map.h>
00110 #include <marsyas/system/MarSystem.h>
00111 #include <marsyas/system/MarSystemManager.h>
00112 #include <marsyas/marsystems/MarSystemTemplateMedium.h>
00113 #include <marsyas/marsystems/MathPower.h>
00114 #include <marsyas/marsystems/MaxArgMax.h>
00115 #include <marsyas/marsystems/MaxMin.h>
00116 #include <marsyas/marsystems/McAulayQuatieri.h>
00117 #include <marsyas/marsystems/Mean.h>
00118 #include <marsyas/marsystems/MeanAbsoluteDeviation.h>
00119 #include <marsyas/marsystems/Median.h>
00120 #include <marsyas/marsystems/MedianFilter.h>
00121 #include <marsyas/marsystems/Memory.h>
00122 #include <marsyas/marsystems/Metric.h>
00123 #include <marsyas/marsystems/MidiFileSynthSource.h>
00124 #include <marsyas/marsystems/MidiInput.h>
00125 #include <marsyas/marsystems/MidiOutput.h>
00126 #include <marsyas/marsystems/MinArgMin.h>
00127 #include <marsyas/marsystems/MixToMono.h>
00128 #include <marsyas/marsystems/Mono2Stereo.h>
00129 #include <marsyas/marsystems/Negative.h>
00130 #include <marsyas/marsystems/NoiseGate.h>
00131 #include <marsyas/marsystems/NoiseSource.h>
00132 #include <marsyas/marsystems/Norm.h>
00133 #include <marsyas/marsystems/NormCut.h>
00134 #include <marsyas/marsystems/NormMatrix.h>
00135 #include <marsyas/marsystems/NormMaxMin.h>
00136 #include <marsyas/marsystems/Normalize.h>
00137 #include <marsyas/marsystems/NormalizeAbs.h>
00138 #include <marsyas/marsystems/OnePole.h>
00139 #include <marsyas/marsystems/OneRClassifier.h>
00140 #include <marsyas/marsystems/OnsetTimes.h>
00141 #include <marsyas/marsystems/OrcaSnip.h>
00142 #include <marsyas/marsystems/OverlapAdd.h>
00143 #include <marsyas/marsystems/PCA.h>
00144 #include <marsyas/marsystems/Panorama.h>
00145 #include <marsyas/marsystems/Parallel.h>
00146 #include <marsyas/marsystems/ParallelMatrixWeight.h>
00147 #include <marsyas/marsystems/PatchMatrix.h>
00148 #include <marsyas/marsystems/Peak2Rms.h>
00149 #include <marsyas/marsystems/PeakClusterSelect.h>
00150 #include <marsyas/marsystems/PeakConvert.h>
00151 #include <marsyas/marsystems/PeakConvert2.h>
00152 #include <marsyas/marsystems/PeakDistanceHorizontality.h>
00153 #include <marsyas/marsystems/PeakEnhancer.h>
00154 #include <marsyas/marsystems/PeakFeatureSelect.h>
00155 #include <marsyas/marsystems/PeakLabeler.h>
00156 #include <marsyas/marsystems/PeakPeriods2BPM.h>
00157 #include <marsyas/marsystems/PeakRatio.h>
00158 #include <marsyas/marsystems/PeakResidual.h>
00159 #include <marsyas/marsystems/PeakSynthFFT.h>
00160 #include <marsyas/marsystems/PeakSynthOsc.h>
00161 #include <marsyas/marsystems/PeakSynthOscBank.h>
00162 #include <marsyas/marsystems/PeakViewMerge.h>
00163 #include <marsyas/marsystems/PeakViewSink.h>
00164 #include <marsyas/marsystems/PeakViewSource.h>
00165 #include <marsyas/marsystems/Peaker.h>
00166 #include <marsyas/marsystems/PeakerAdaptive.h>
00167 #include <marsyas/marsystems/PeakerOnset.h>
00168 #include <marsyas/marsystems/PhaseLock.h>
00169 #include <marsyas/marsystems/PhiSEMFilter.h>
00170 #include <marsyas/marsystems/PhiSEMSource.h>
00171 #include <marsyas/marsystems/PitchDiff.h>
00172 #include <marsyas/marsystems/PlotSink.h>
00173 #include <marsyas/marsystems/Plucked.h>
00174 #include <marsyas/marsystems/Polar2Cartesian.h>
00175 #include <marsyas/marsystems/Power.h>
00176 #include <marsyas/marsystems/PowerSpectrum.h>
00177 #include <marsyas/marsystems/PowerToAverageRatio.h>
00178 #include <marsyas/marsystems/Product.h>
00179 #include <marsyas/marsystems/PvConvert.h>
00180 #include <marsyas/marsystems/PvConvolve.h>
00181 #include <marsyas/marsystems/PvFold.h>
00182 #include <marsyas/marsystems/PvOscBank.h>
00183 #include <marsyas/marsystems/PvOverlapadd.h>
00184 #include <marsyas/marsystems/PvUnconvert.h>
00185 #include <marsyas/marsystems/RBF.h>
00186 #include <marsyas/marsystems/RadioDrumInput.h>
00187 #include <marsyas/marsystems/RealvecSink.h>
00188 #include <marsyas/marsystems/RealvecSource.h>
00189 #include <marsyas/marsystems/Reassign.h>
00190 #include <marsyas/marsystems/Reciprocal.h>
00191 #include <marsyas/marsystems/RemoveObservations.h>
00192 #include <marsyas/marsystems/Resample.h>
00193 #include <marsyas/marsystems/ResampleBezier.h>
00194 #include <marsyas/marsystems/ResampleLinear.h>
00195 #include <marsyas/marsystems/ResampleNearestNeighbour.h>
00196 #include <marsyas/marsystems/ResampleSinc.h>
00197 #include <marsyas/marsystems/Reverse.h>
00198 #include <marsyas/marsystems/Rms.h>
00199 #include <marsyas/marsystems/Rolloff.h>
00200 #include <marsyas/marsystems/RunningAutocorrelation.h>
00201 #include <marsyas/marsystems/RunningStatistics.h>
00202 #include <marsyas/marsystems/SCF.h>
00203 #include <marsyas/marsystems/SFM.h>
00204 #include <marsyas/marsystems/SMO.h>
00205 #include <marsyas/marsystems/SNR.h>
00206 #include <marsyas/marsystems/SOM.h>
00207 #include <marsyas/marsystems/SVMClassifier.h>
00208 #include <marsyas/marsystems/SVMLinearClassifier.h>
00209 #include <marsyas/marsystems/Selector.h>
00210 #include <marsyas/marsystems/SelfSimilarityMatrix.h>
00211 #include <marsyas/marsystems/Series.h>
00212 #include <marsyas/marsystems/ShiftInput.h>
00213 #include <marsyas/marsystems/ShiftOutput.h>
00214 #include <marsyas/marsystems/Shifter.h>
00215 #include <marsyas/marsystems/Shredder.h>
00216 #include <marsyas/marsystems/SilenceRemove.h>
00217 #include <marsyas/marsystems/SimilarityMatrix.h>
00218 #include <marsyas/marsystems/SimulMaskingFft.h>
00219 #include <marsyas/marsystems/SineSource.h>
00220 #include <marsyas/marsystems/Skewness.h>
00221 #include <marsyas/marsystems/SliceDelta.h>
00222 #include <marsyas/marsystems/SliceShuffle.h>
00223 #include <marsyas/marsystems/SoundFileSink.h>
00224 #include <marsyas/marsystems/SoundFileSource.h>
00225 #include <marsyas/marsystems/SoundFileSource2.h>
00226 #include <marsyas/marsystems/SoundFileSourceHopper.h>
00227 #include <marsyas/marsystems/SpectralFlatnessAllBands.h>
00228 #include <marsyas/marsystems/SpectralSNR.h>
00229 #include <marsyas/marsystems/SpectralTransformations.h>
00230 #include <marsyas/marsystems/Spectrum.h>
00231 #include <marsyas/marsystems/Spectrum2Chroma.h>
00232 #include <marsyas/marsystems/Spectrum2Mel.h>
00233 #include <marsyas/marsystems/Square.h>
00234 #include <marsyas/marsystems/StandardDeviation.h>
00235 #include <marsyas/marsystems/StereoSpectrum.h>
00236 #include <marsyas/marsystems/StereoSpectrumFeatures.h>
00237 #include <marsyas/marsystems/StereoSpectrumSources.h>
00238 #include <marsyas/marsystems/StretchLinear.h>
00239 #include <marsyas/marsystems/Subtract.h>
00240 #include <marsyas/marsystems/SubtractMean.h>
00241 #include <marsyas/marsystems/Sum.h>
00242 #include <marsyas/marsystems/SVFilter.h>
00243 #include <marsyas/marsystems/TempoHypotheses.h>
00244 #include <marsyas/marsystems/TimeFreqPeakConnectivity.h>
00245 #include <marsyas/marsystems/TimeStretch.h>
00246 #include <marsyas/marsystems/Timer.h> 
00247 #include <marsyas/marsystems/TimelineLabeler.h>
00248 #include <marsyas/marsystems/Transposer.h>
00249 #include <marsyas/marsystems/TriangularFilterBank.h>
00250 #include <marsyas/marsystems/Unfold.h>
00251 #include <marsyas/marsystems/Vibrato.h>
00252 #include <marsyas/marsystems/ViconFileSource.h>
00253 #include <marsyas/marsystems/WHaSp.h>
00254 #include <marsyas/marsystems/WavFileSink.h>
00255 #include <marsyas/marsystems/WavFileSource.h>
00256 #include <marsyas/marsystems/WavFileSource2.h>
00257 #include <marsyas/marsystems/WaveletBands.h>
00258 #include <marsyas/marsystems/WaveletPyramid.h>
00259 #include <marsyas/marsystems/WaveguideOsc.h>
00260 #include <marsyas/WekaData.h>
00261 #include <marsyas/marsystems/WekaSink.h>
00262 #include <marsyas/marsystems/WekaSource.h>
00263 #include <marsyas/marsystems/Windowing.h>
00264 #include <marsyas/marsystems/Yin.h>
00265 #include <marsyas/marsystems/ZeroCrossings.h>
00266 #include <marsyas/marsystems/ZeroRClassifier.h>
00267 #include <marsyas/common_source.h>
00268 // #include <marsyas/marsystems/BinauralCARFAC.h>
00269 #include <marsyas/marsystems/HarmonicStrength.h>
00270 #include <marsyas/marsystems/CsvFileSource.h>
00271 #include <marsyas/marsystems/Krumhansl_key_finder.h>
00272 #include <marsyas/marsystems/PWMSource.h>
00273 #include <marsyas/marsystems/DCSource.h>
00274 #include <marsyas/marsystems/AliasingOsc.h>
00275 #include <marsyas/marsystems/APDelayOsc.h>
00276 #include <marsyas/marsystems/Upsample.h>
00277 #include <marsyas/marsystems/Whitening.h>
00278 #include <marsyas/marsystems/Energy.h>
00279 #include <marsyas/marsystems/DPWOsc.h>
00280 #include <marsyas/marsystems/SpectralCentroidBandNorm.h>
00281 #include <marsyas/marsystems/ChromaFilter.h>
00282 #include <marsyas/marsystems/Sidechain.h>
00283 #include <marsyas/marsystems/CsvSink.h>
00284 #include <marsyas/marsystems/Ratio.h>
00285 #include <marsyas/marsystems/Threshold.h>
00286 //modifyHeader
00287 
00288 #ifdef MARSYAS_AUDIOIO
00289 #include <marsyas/marsystems/AudioSource.h>
00290 #include <marsyas/marsystems/AudioSourceBlocking.h>
00291 #include <marsyas/marsystems/AudioSink.h>
00292 #include <marsyas/marsystems/AudioSinkBlocking.h>
00293 #endif
00294 #ifdef MARSYAS_GSTREAMER
00295 #include <marsyas/marsystems/GStreamerSource.h>
00296 #endif
00297 #ifdef MARSYAS_LAME
00298 #include <marsyas/marsystems/MP3FileSink.h>
00299 #endif
00300 
00301 using std::ostringstream;
00302 using std::map;
00303 using std::istream;
00304 using std::ostream;
00305 using std::vector;
00306 
00307 using namespace Marsyas;
00308 
00309 MarSystemManager::MarSystemManager()
00310 {
00311   // registerPrototype("BinauralCARFAC", new BinauralCARFAC("binauralcarfac"));
00312   registerPrototype("ADRess", new ADRess("adresspr"));
00313   registerPrototype("ADRessSpectrum", new ADRessSpectrum("adressspectrumpr"));
00314   registerPrototype("ADRessStereoSpectrum", new ADRessStereoSpectrum("adressstereospectrumpr"));
00315   registerPrototype("ADSR", new ADSR("adsrpr"));
00316   registerPrototype("AMDF", new AMDF("amdfpr"));
00317   registerPrototype("AbsMax", new AbsMax("absmaxpr"));
00318   registerPrototype("AccentFilterBank", new AccentFilterBank("afb"));
00319   registerPrototype("Accumulator", new Accumulator("acc"));
00320   registerPrototype("AdditiveOsc", new AdditiveOsc("additiveoscpr"));
00321   registerPrototype("AimBoxes", new AimBoxes("aimboxes"));
00322   registerPrototype("AimGammatone", new AimGammatone("aimgammatone"));
00323   registerPrototype("AimHCL", new AimHCL("aimhcl"));
00324   registerPrototype("AimHCL2", new AimHCL2("aimhcl2"));
00325   registerPrototype("AimLocalMax", new AimLocalMax("aimlocalmax"));
00326   registerPrototype("AimPZFC", new AimPZFC("aimpzfc"));
00327   registerPrototype("AimPZFC2", new AimPZFC2("aimpzfc2"));
00328   registerPrototype("AimSAI", new AimSAI("aimsai"));
00329   registerPrototype("AimSSI", new AimSSI("aimssi"));
00330   registerPrototype("AimVQ", new AimVQ("aimvq"));
00331   registerPrototype("AliasingOsc", new AliasingOsc("aliasingoscpr"));
00332   registerPrototype("Annotator", new Annotator("anonp"));
00333   registerPrototype("ArffFileSink", new ArffFileSink("arfffilesinkpr"));
00334   registerPrototype("AuFileSink", new AuFileSink("ausinkp"));
00335   registerPrototype("AuFileSource", new AuFileSource("aufp"));
00336   registerPrototype("AubioYin", new AubioYin("aubioyin"));
00337   registerPrototype("AutoCorrelation", new AutoCorrelation("acrp"));
00338   registerPrototype("AutoCorrelationFFT", new AutoCorrelationFFT("autocorfftpr"));
00339   registerPrototype("BICchangeDetector", new BICchangeDetector("bicchgdetpr"));
00340   registerPrototype("BeatAgent", new BeatAgent("beatagent"));
00341   registerPrototype("BeatHistoFeatures", new BeatHistoFeatures("bhfp"));
00342   registerPrototype("BeatHistogram", new BeatHistogram("beathistopr"));
00343   registerPrototype("BeatHistogramFromPeaks", new BeatHistogramFromPeaks("beathistofrompeakspr"));
00344   registerPrototype("BeatPhase", new BeatPhase("beatphase"));
00345   registerPrototype("BeatReferee", new BeatReferee("beatreferee"));
00346   registerPrototype("BeatTimesSink", new BeatTimesSink("beattimessink"));
00347   registerPrototype("Biquad", new Biquad("biquadp"));
00348   registerPrototype("BlitOsc", new BlitOsc("blitoscpr"));
00349   registerPrototype("CARFAC", new CARFAC("carfac"));
00350   registerPrototype("Cartesian2Polar", new Cartesian2Polar("c2p"));
00351   registerPrototype("Cascade", new Cascade("cascadep"));
00352   registerPrototype("Centroid", new Centroid("cntrp"));
00353   registerPrototype("Chroma", new Chroma("chromapr"));
00354   registerPrototype("ClassOutputSink", new ClassOutputSink("classoutputsinkp"));
00355   registerPrototype("ClassificationReport", new ClassificationReport("classificationreportpr"));
00356   registerPrototype("Clip", new Clip("clpr"));
00357   registerPrototype("Combinator", new Combinator("combinator"));
00358   registerPrototype("CompExp", new CompExp("compexppr"));
00359   registerPrototype("Compressor", new Compressor("compressor"));
00360   registerPrototype("Confidence", new Confidence("confp"));
00361   registerPrototype("ConstQFiltering", new ConstQFiltering("cqfpr"));
00362   registerPrototype("CrossCorrelation",new CrossCorrelation("crossCorrelationpr"));
00363   registerPrototype("CsvFileSource", new CsvFileSource("csvfilesourcepr"));
00364   registerPrototype("DCSource", new DCSource("dcsourcepr"));
00365   registerPrototype("DeInterleaveSizecontrol", new DeInterleaveSizecontrol("deintszctrlpr"));
00366   registerPrototype("Deinterleave", new Deinterleave("deintpr"));
00367   registerPrototype("Delay", new Delay("delaypr"));
00368   registerPrototype("DelaySamples", new DelaySamples("delay"));
00369   registerPrototype("Delta", new Delta("deltapr"));
00370   registerPrototype("DeltaFirstOrderRegression", new DeltaFirstOrderRegression("delta"));
00371   registerPrototype("Differentiator", new Differentiator("differentiator"));
00372   registerPrototype("DownSampler", new DownSampler("ds"));
00373   registerPrototype("ERB", new ERB("erbp"));
00374   registerPrototype("EnhADRess", new EnhADRess("Enhadresspr"));
00375   registerPrototype("EnhADRessStereoSpectrum", new EnhADRessStereoSpectrum("enhadressstereospectrumpr"));
00376   registerPrototype("FM", new FM("fmp"));
00377   registerPrototype("FMeasure", new FMeasure("F-Measure"));
00378   registerPrototype("FanOutIn", new FanOutIn("fanoutinpr"));
00379   registerPrototype("Fanin", new Fanin("finp"));
00380   registerPrototype("Fanout", new Fanout("fonp"));
00381   registerPrototype("Filter", new Filter("filterp"));
00382   registerPrototype("FlowCutSource", new FlowCutSource("fcs"));
00383   registerPrototype("FlowThru", new FlowThru("flowthrupr"));
00384   registerPrototype("FlowToControl", new FlowToControl("flowtocontrolpr"));
00385   registerPrototype("Flux", new Flux("fluxp"));
00386   registerPrototype("FullWaveRectifier", new FullWaveRectifier("fwr"));
00387   registerPrototype("GMMClassifier", new GMMClassifier("gmmsp"));
00388   registerPrototype("Gain", new Gain("gp"));
00389   registerPrototype("GaussianClassifier", new GaussianClassifier("gaussp"));
00390   registerPrototype("HWPS", new HWPS("hwpspr"));
00391   registerPrototype("HalfWaveRectifier", new HalfWaveRectifier("hwrp"));
00392   registerPrototype("HarmonicEnhancer", new HarmonicEnhancer("hepr"));
00393   registerPrototype("HarmonicStrength", new HarmonicStrength("harmonicstrengthpr"));
00394   registerPrototype("Inject", new Inject("injectpr"));
00395   registerPrototype("InvSpectrum", new InvSpectrum("ispkp"));
00396   registerPrototype("KNNClassifier", new KNNClassifier("knnp"));
00397   registerPrototype("Krumhansl_key_finder", new Krumhansl_key_finder("krumhansl_key_finderpr"));
00398   registerPrototype("Kurtosis", new Kurtosis("kurtosisp"));
00399   registerPrototype("LPC", new LPC("lpcwarppr"));
00400   registerPrototype("LPCC", new LPCC("lpccpr"));
00401   registerPrototype("LSP", new LSP("lsppr"));
00402   registerPrototype("LyonPassiveEar", new LyonPassiveEar("lyonp"));
00403   registerPrototype("MFCC", new MFCC("mfcc"));
00404   registerPrototype("Map", new Map("proto_map"));
00405   registerPrototype("MarSystemTemplateMedium", new MarSystemTemplateMedium("marsystemtemplatemediumpr"));
00406   registerPrototype("MathPower", new MathPower("mathpowerpr"));
00407   registerPrototype("MaxArgMax", new MaxArgMax("mxrp"));
00408   registerPrototype("MaxMin", new MaxMin("maxminpr"));
00409   registerPrototype("Mean", new Mean("meanp"));
00410   registerPrototype("MeanAbsoluteDeviation", new MeanAbsoluteDeviation("meanabsolutedeviationpr"));
00411   registerPrototype("Median", new Median("median"));
00412   registerPrototype("MedianFilter", new MedianFilter("medianfilterpr"));
00413   registerPrototype("Memory", new Memory("memp"));
00414   registerPrototype("Metric", new Metric("metricpr"));
00415   registerPrototype("MidiFileSynthSource", new MidiFileSynthSource("midifilesynthsourcepr"));
00416   registerPrototype("MidiInput", new MidiInput("midiinpr"));
00417   registerPrototype("MidiOutput", new MidiOutput("midioutpr"));
00418   registerPrototype("MinArgMin", new MinArgMin("mnrp"));
00419   registerPrototype("MixToMono", new MixToMono("mixtomono"));
00420   registerPrototype("Mono2Stereo", new Mono2Stereo("mono2stereop"));
00421   registerPrototype("Negative", new Negative("negp"));
00422   registerPrototype("NoiseGate", new NoiseGate("noisegatep"));
00423   registerPrototype("NoiseSource", new NoiseSource("noisesrcsp"));
00424   registerPrototype("Norm", new Norm("norm"));
00425   registerPrototype("NormCut", new NormCut("normcutpr"));
00426   registerPrototype("NormMatrix", new NormMatrix("normmatrixpr"));
00427   registerPrototype("NormMaxMin", new NormMaxMin("normmaxminpr"));
00428   registerPrototype("Normalize", new Normalize("normalizepr"));
00429   registerPrototype("NormalizeAbs", new NormalizeAbs("normalizeabspr"));
00430   registerPrototype("OnePole", new OnePole("lpf"));
00431   registerPrototype("OneRClassifier", new OneRClassifier("onerclassifierpr"));
00432   registerPrototype("OnsetTimes", new OnsetTimes("OnsetTimes"));
00433   registerPrototype("OrcaSnip", new OrcaSnip("GetSnipBounds"));
00434   registerPrototype("OverlapAdd", new OverlapAdd("oa"));
00435   registerPrototype("PCA", new PCA("pcapr"));
00436   registerPrototype("PWMSource", new PWMSource("pwmsourcepr"));
00437   registerPrototype("Panorama", new Panorama("panoramapr"));
00438   registerPrototype("Parallel", new Parallel("parallelp"));
00439   registerPrototype("ParallelMatrixWeight", new ParallelMatrixWeight("parallelmatrixweight"));
00440   registerPrototype("PatchMatrix", new PatchMatrix("patmatpr"));
00441   registerPrototype("Peak2Rms", new Peak2Rms("peakrms"));
00442   registerPrototype("PeakClusterSelect", new PeakClusterSelect("peclusterselectpr"));
00443   registerPrototype("PeakConvert", new PeakConvert("peconvp"));
00444   registerPrototype("PeakConvert2", new PeakConvert2("peconvp2"));
00445   registerPrototype("PeakDistanceHorizontality", new PeakDistanceHorizontality("horizontality"));
00446   registerPrototype("PeakEnhancer", new PeakEnhancer("peakenhpr"));
00447   registerPrototype("PeakFeatureSelect", new PeakFeatureSelect("pefeatselectpr"));
00448   registerPrototype("PeakLabeler", new PeakLabeler("pelabelerpr"));
00449   registerPrototype("PeakPeriods2BPM", new PeakPeriods2BPM("p2bpm"));
00450   registerPrototype("PeakRatio", new PeakRatio("perap"));
00451   registerPrototype("PeakResidual", new PeakResidual("peres"));
00452   registerPrototype("PeakSynthFFT", new PeakSynthFFT("pvfft"));
00453   registerPrototype("PeakSynthOsc", new PeakSynthOsc("pso"));
00454   registerPrototype("PeakSynthOscBank", new PeakSynthOscBank("pvoscp"));
00455   registerPrototype("PeakViewMerge", new PeakViewMerge("PeakViewMerge"));
00456   registerPrototype("PeakViewSink", new PeakViewSink("peakviewsinkpr"));
00457   registerPrototype("PeakViewSource", new PeakViewSource("peakviewsourcepr"));
00458   registerPrototype("Peaker", new Peaker("pkrp"));
00459   registerPrototype("PeakerAdaptive", new PeakerAdaptive("pkr1pr"));
00460   registerPrototype("PeakerOnset", new PeakerOnset("pkronsetpr"));
00461   registerPrototype("PhaseLock", new PhaseLock("phaselock"));
00462   registerPrototype("PhiSEMFilter", new PhiSEMFilter("phisemfilterpr"));
00463   registerPrototype("PhiSEMSource", new PhiSEMSource("phisemsourcepr"));
00464   registerPrototype("PitchDiff", new PitchDiff("pitchdiffpr"));
00465   registerPrototype("PlotSink", new PlotSink("plotsp"));
00466   registerPrototype("Plucked", new Plucked("pluckedpr"));
00467   registerPrototype("Polar2Cartesian", new Polar2Cartesian("p2c"));
00468   registerPrototype("Power", new Power("pow"));
00469   registerPrototype("PowerSpectrum", new PowerSpectrum("pspkp"));
00470   registerPrototype("PowerToAverageRatio", new PowerToAverageRatio("crestpr"));
00471   registerPrototype("Product", new Product("product"));
00472   registerPrototype("PvConvert", new PvConvert("pvconvp"));
00473   registerPrototype("PvConvolve", new PvConvolve("pvconvpr"));
00474   registerPrototype("PvFold", new PvFold("pvfp"));
00475   registerPrototype("PvOscBank", new PvOscBank("pvoscp"));
00476   registerPrototype("PvOverlapadd", new PvOverlapadd("pvovlfp"));
00477   registerPrototype("PvUnconvert", new PvUnconvert("pvuconvp"));
00478   registerPrototype("RBF", new RBF("rbfpr"));
00479   registerPrototype("RadioDrumInput", new RadioDrumInput("radiodrump"));
00480   registerPrototype("RealvecSink", new RealvecSink("realvecSink"));
00481   registerPrototype("RealvecSource", new RealvecSource("realvecSrc"));
00482   registerPrototype("Reassign", new Reassign("reassignpr"));
00483   registerPrototype("Reciprocal", new Reciprocal("reciprocal"));
00484   registerPrototype("RemoveObservations", new RemoveObservations("removeobservationspr"));
00485   registerPrototype("Resample", new Resample("resampabspr"));
00486   registerPrototype("ResampleBezier", new ResampleBezier("resampberpr"));
00487   registerPrototype("ResampleLinear", new ResampleLinear("resamplinpr"));
00488   registerPrototype("ResampleNearestNeighbour", new ResampleNearestNeighbour("resampnnpr"));
00489   registerPrototype("ResampleSinc", new ResampleSinc("resampsincpr"));
00490   registerPrototype("Reverse", new Reverse("reversepr"));
00491   registerPrototype("Rms", new Rms("rms"));
00492   registerPrototype("Rolloff", new Rolloff("rlfp"));
00493   registerPrototype("RunningAutocorrelation", new RunningAutocorrelation("runningautocorrelation"));
00494   registerPrototype("RunningStatistics", new RunningStatistics("runningstatisticspr"));
00495   registerPrototype("SCF", new SCF("scf"));
00496   registerPrototype("SFM", new SFM("sfm"));
00497   registerPrototype("SMO", new SMO("smopr"));
00498   registerPrototype("SNR", new SNR("snrpr"));
00499   registerPrototype("SOM", new SOM("sompr"));
00500   registerPrototype("SVMClassifier", new SVMClassifier("svmclassifierpr"));
00501   registerPrototype("SVMLinearClassifier", new SVMClassifier("svmlinearclassifierpr"));
00502   registerPrototype("Selector", new Selector("selectorpr"));
00503   registerPrototype("SelfSimilarityMatrix", new SelfSimilarityMatrix("selfsimilaritymatrixpr"));
00504   registerPrototype("Series", new Series("srp"));
00505   registerPrototype("ShiftInput", new ShiftInput("sip"));
00506   registerPrototype("ShiftOutput", new ShiftOutput("sop"));
00507   registerPrototype("Shifter", new Shifter("sp"));
00508   registerPrototype("Shredder", new Shredder("shred"));
00509   registerPrototype("SilenceRemove", new SilenceRemove("silenceremovepr"));
00510   registerPrototype("SimilarityMatrix", new SimilarityMatrix("similaritymatrixpr"));
00511   registerPrototype("SimulMaskingFft", new SimulMaskingFft("simulmask"));
00512   registerPrototype("SineSource", new SineSource("sinesp"));
00513   registerPrototype("Skewness", new Skewness("Skewnessp"));
00514   registerPrototype("SliceDelta", new SliceDelta("slicedeltapr"));
00515   registerPrototype("SliceShuffle", new SliceShuffle("sliceshuffle"));
00516   registerPrototype("SoundFileSink", new SoundFileSink("sfsp"));
00517   registerPrototype("SoundFileSource", new SoundFileSource("sfp"));
00518   registerPrototype("SoundFileSource2", new SoundFileSource2("sf2p"));
00519   registerPrototype("SoundFileSourceHopper", new SoundFileSourceHopper("soundfilesourcehopper"));
00520   registerPrototype("SpectralFlatnessAllBands", new SpectralFlatnessAllBands("spectralflatnessallbandspr"));
00521   registerPrototype("SpectralSNR", new SpectralSNR("ssnrpr"));
00522   registerPrototype("SpectralTransformations", new SpectralTransformations("spectraltransformationspr"));
00523   registerPrototype("Spectrum", new Spectrum("spkp"));
00524   registerPrototype("Spectrum2Chroma", new Spectrum2Chroma("spectrum2chromapr"));
00525   registerPrototype("Spectrum2Mel", new Spectrum2Mel("spectrum2melpr"));
00526   registerPrototype("Square", new Square("square"));
00527   registerPrototype("StandardDeviation", new StandardDeviation("stdp"));
00528   registerPrototype("StereoSpectrum", new StereoSpectrum("stereopr"));
00529   registerPrototype("StereoSpectrumFeatures", new StereoSpectrumFeatures("stereospkfpr"));
00530   registerPrototype("StereoSpectrumSources", new StereoSpectrumSources("stereospectrumsourcespr"));
00531   registerPrototype("StretchLinear", new StretchLinear("stretchlinearpr"));
00532   registerPrototype("Subtract", new Subtract("subtract"));
00533   registerPrototype("SubtractMean", new SubtractMean("subtractmean"));
00534   registerPrototype("Sum", new Sum("sum"));
00535   registerPrototype("SVFilter", new SVFilter("svfilter"));
00536   registerPrototype("TempoHypotheses", new TempoHypotheses("tempohyp"));
00537   registerPrototype("TimeFreqPeakConnectivity", new TimeFreqPeakConnectivity("tfpeakconn"));
00538   registerPrototype("TimeStretch", new TimeStretch("tscp"));
00539   registerPrototype("Timer", new Timer("timerp"));
00540   registerPrototype("TimelineLabeler", new TimelineLabeler("timelinelabelerpr"));
00541   registerPrototype("Transposer", new Transposer("transposer"));
00542   registerPrototype("TriangularFilterBank", new TriangularFilterBank("triangularfilterbank_pr"));
00543 
00544   registerPrototype("Unfold", new Unfold("unfold"));
00545   registerPrototype("Vibrato", new Vibrato("vibratopr"));
00546   registerPrototype("ViconFileSource", new ViconFileSource("viconfilesourcep"));
00547   registerPrototype("WHaSp", new WHaSp("whasppr"));
00548   registerPrototype("WavFileSink", new WavFileSink("wavsinkp"));
00549   registerPrototype("WavFileSource", new WavFileSource("wavfp"));
00550   registerPrototype("WavFileSource2", new WavFileSource2("wavf2p"));
00551   registerPrototype("WaveletBands",   new WaveletBands("wvbands"));
00552   registerPrototype("WaveletPyramid", new WaveletPyramid("wvpyramid"));
00553   registerPrototype("WaveguideOsc", new WaveguideOsc("waveguideoscpr"));
00554   registerPrototype("WekaSink", new WekaSink("wsink"));
00555   registerPrototype("WekaSource", new WekaSource("wsource"));
00556   registerPrototype("Windowing", new Windowing("win"));
00557   registerPrototype("Yin", new Yin("yin"));
00558   registerPrototype("ZeroCrossings", new ZeroCrossings("zcrsp"));
00559   registerPrototype("ZeroRClassifier", new ZeroRClassifier("zerorp"));
00560   registerPrototype("DTW", new DTW("dtwpr"));
00561   registerPrototype("APDelayOsc", new APDelayOsc("apdelayoscpr"));
00562   registerPrototype("Upsample", new Upsample("upsamplepr"));
00563   registerPrototype("Whitening", new Whitening("whiteningpr"));
00564   registerPrototype("Energy", new Energy("energypr"));
00565   registerPrototype("DPWOsc", new DPWOsc("dpwoscpr"));
00566   registerPrototype("SpectralCentroidBandNorm", new SpectralCentroidBandNorm("spectralcentroidbandnormpr"));
00567   registerPrototype("ChromaFilter", new ChromaFilter("chromafilterpr"));
00568   registerPrototype("Sidechain", new Sidechain("sidechain_prototype"));
00569   registerPrototype("CsvSink", new CsvSink("csvsink_prototype"));
00570   registerPrototype("Ratio", new Ratio("ratio_prototype"));
00571   registerPrototype("Threshold", new Threshold("threshold_prototype"));
00572   //modifyRegister
00573 
00574   // optional MarSystems
00575 #ifdef MARSYAS_AUDIOIO
00576   registerPrototype("AudioSink", new AudioSink("audiosinkp"));
00577   registerPrototype("AudioSinkBlocking", new AudioSinkBlocking("AudioSinkBlocking"));
00578   registerPrototype("AudioSource", new AudioSource("audiosourcepr"));
00579   registerPrototype("AudioSourceBlocking", new AudioSourceBlocking("audiosourceblockingpr"));
00580 #endif
00581 
00582 #ifdef MARSYAS_GSTREAMER
00583   registerPrototype("GStreamerSource", new GStreamerSource("gstp"));
00584 #endif
00585 #ifdef MARSYAS_LAME
00586   registerPrototype("MP3FileSink", new MP3FileSink("sfsp"));
00587 #endif
00588 
00589   //***************************************************************************************
00590   //                Composite MarSystem prototypes
00591   //***************************************************************************************
00592   // Delay instantiation
00593   compositesMap_["DeviBot"                      ] = DEVIBOT;
00594   compositesMap_["Stereo2Mono"                  ] = STEREO2MONO;
00595   compositesMap_["TextureStats"                 ] = TEXTURESTATS;
00596   compositesMap_["LPCnet"                       ] = LPCNET;
00597   compositesMap_["PowerSpectrumNet"             ] = POWERSPECTRUMNET;
00598   compositesMap_["PowerSpectrumNet1"            ] = POWERSPECTRUMNET1;
00599   compositesMap_["STFT_features"                ] = STFT_FEATURES;
00600   compositesMap_["TimbreFeatures"               ] = TIMBREFEATURES;
00601   compositesMap_["StereoPanningSpectrumFeatures"] = STEREOPANNINGSPECTRUMFEATURES;
00602   compositesMap_["StereoFeatures"               ] = STEREOFEATURES;
00603   compositesMap_["PhaseVocoder"                 ] = PHASEVOCODER;
00604   compositesMap_["PhaseVocoderOscBank"          ] = PHASEVOCODEROSCBANK;
00605   compositesMap_["PitchSACF"                    ] = PITCHSACF;
00606   compositesMap_["PitchPraat"                   ] = PITCHPRAAT;
00607   compositesMap_["PeakAnalyse"                  ] = PEAKANALYSE;
00608   compositesMap_["WHaSpnet"                     ] = WHASPNET;
00609   compositesMap_["StereoFeatures2"              ] = STEREOFEATURES2;
00610   compositesMap_["Classifier"                   ] = CLASSIFIER;
00611   compositesMap_["Pipe_Block"                   ] = PIPE_BLOCK;
00612   compositesMap_["AFB_Block_A"                  ] = AFB_BLOCK_A;
00613   compositesMap_["AFB_Block_B"                  ] = AFB_BLOCK_B;
00614   compositesMap_["AFB_Block_C"                  ] = AFB_BLOCK_C;
00615   compositesMap_["Decimating_QMF"               ] = DECIMATING_QMF;
00616   compositesMap_["MultiPitch"                   ] = MULTIPITCH;
00617 }
00618 
00619 void MarSystemManager::registerComposite(std::string prototype)
00620 {
00621   if (compositesMap_.find(prototype) == compositesMap_.end())
00622     return;
00623 
00624 
00625   switch (compositesMap_[prototype])
00626   {
00627   case STUB:
00628     break;
00629 
00630 
00631   case MULTIPITCH:
00632   {
00633 
00634     MarSystem* lpf1;
00635     MarSystem* lpf2;
00636     MarSystem* hpf1;
00637     MarSystem* hwr;
00638     MarSystem* hwr2;
00639     MarSystem* hwr3;
00640     MarSystem* autocorhi;
00641     MarSystem* autocorlo;
00642     MarSystem* sum;
00643     MarSystem* pe2;
00644     MarSystem* pe3;
00645     MarSystem* pe4;
00646 
00647     MarSystem* fan;
00648     MarSystem* hinet;
00649     MarSystem* lonet;
00650 
00651     MarSystem* multipitpr;
00652 
00653     realvec numlow, denomlow;
00654     realvec numhigh, denomhigh;
00655 
00656     numlow.create(3);
00657     denomlow.create(3);
00658     numhigh.create(3);
00659     denomhigh.create(3);
00660 
00661     //coefs are for butter(2,1000) and butter(2,1000,'high')
00662     numlow(0)=0.1207f; numlow(1)=0.2415f; numlow(2)=0.1207f;
00663     denomlow(0)=1.0f; denomlow(1)=-0.8058f; denomlow(2)=0.2888f;
00664 
00665     numhigh(0)=0.5236f; numhigh(1)=-1.0473f; numhigh(2)=0.5236f;
00666     denomhigh(0)=1.0f; denomhigh(1)=-0.8058f; denomhigh(2)=0.2888f;
00667 
00668     lpf1 = new Filter("lpf1");
00669     lpf1->updControl("mrs_realvec/ncoeffs", numlow);
00670     lpf1->updControl("mrs_realvec/dcoeffs", denomlow);
00671 
00672     lpf2 = new Filter("lpf2");
00673     lpf2->updControl("mrs_realvec/ncoeffs", numlow);
00674     lpf2->updControl("mrs_realvec/dcoeffs", denomlow);
00675 
00676     hpf1 = new Filter("hpf1");
00677     hpf1->updControl("mrs_realvec/ncoeffs", numhigh);
00678     hpf1->updControl("mrs_realvec/dcoeffs", denomhigh);
00679 
00680     hwr = new HalfWaveRectifier("hwr");
00681     hwr2 = new HalfWaveRectifier("hwr2");
00682     hwr3 = new HalfWaveRectifier("hwr3");
00683     autocorhi = new AutoCorrelationFFT("autocorhi");
00684     autocorlo = new AutoCorrelationFFT("autocorlo");
00685 
00686     pe2 = new PeakEnhancer("pe2");
00687     pe3 = new PeakEnhancer("pe3");
00688     pe4 = new PeakEnhancer("pe4");
00689 
00690     multipitpr = new Series("multipitpr");
00691     fan = new Fanout("fan");
00692     hinet = new Series("hinet");
00693     lonet = new Series("lonet");
00694     sum = new Sum("sum");
00695 
00696     lonet->addMarSystem(lpf1);
00697     lonet->addMarSystem(hwr);
00698     lonet->addMarSystem(autocorlo);
00699     hinet->addMarSystem(hpf1);
00700     hinet->addMarSystem(hwr2);
00701     hinet->addMarSystem(lpf2);
00702     hinet->addMarSystem(autocorhi);
00703 
00704     fan->addMarSystem(hinet);
00705     fan->addMarSystem(lonet);
00706 
00707     multipitpr->addMarSystem(fan);
00708     multipitpr->addMarSystem(sum);
00709     multipitpr->addMarSystem(pe2);
00710     multipitpr->addMarSystem(pe3);
00711     multipitpr->addMarSystem(pe4);
00712     multipitpr->addMarSystem(hwr3);
00713     registerPrototype("MultiPitch", multipitpr);
00714   }
00715   break;
00716 
00717   case DEVIBOT:
00718   {
00719     //--------------------------------------------------------------------------------
00720     // Making a prototype for a specific MidiOutput device
00721     //--------------------------------------------------------------------------------
00722     MarSystem* devibotpr = new MidiOutput("devibotpr");
00723     devibotpr->linkControl("mrs_natural/byte2", "mrs_natural/arm");
00724     devibotpr->linkControl("mrs_natural/byte3", "mrs_natural/velocity");
00725     devibotpr->linkControl("mrs_bool/sendMessage", "mrs_bool/strike");
00726     devibotpr->updControl("mrs_natural/byte1", 144);
00727     registerPrototype("DeviBot", devibotpr);
00728   }
00729   break;
00730 
00731   case STEREO2MONO:
00732   {
00733     //--------------------------------------------------------------------------------
00734     // Stereo2Mono MarSystem
00735     //--------------------------------------------------------------------------------
00736     MarSystem* stereo2monopr = new Sum("stereo2monopr");
00737     stereo2monopr->updControl("mrs_real/weight", 0.5);
00738     registerPrototype("Stereo2Mono", stereo2monopr);
00739   }
00740   break;
00741 
00742   case TEXTURESTATS:
00743   {
00744     //--------------------------------------------------------------------------------
00745     // texture window analysis composite prototype
00746     //--------------------------------------------------------------------------------
00747     MarSystem* textureStatspr = new Series("tstatspr");
00748     textureStatspr->addMarSystem(new Memory("mempr"));
00749 
00750     MarSystem* meanstdpr = new Fanout("meanstdpr");
00751     meanstdpr->addMarSystem(new Mean("meanpr"));
00752     meanstdpr->addMarSystem(new StandardDeviation("stdpr"));
00753     textureStatspr->addMarSystem(meanstdpr);
00754 
00755     textureStatspr->linkControl("Memory/mempr/mrs_natural/memSize", "mrs_natural/memSize");
00756     textureStatspr->linkControl("Memory/mempr/mrs_bool/reset", "mrs_bool/reset");
00757     registerPrototype("TextureStats", textureStatspr);
00758   }
00759   break;
00760 
00761   case POWERSPECTRUMNET:
00762   {
00763     //--------------------------------------------------------------------------------
00764     // Power spectrum composite prototype
00765     //--------------------------------------------------------------------------------
00766     MarSystem* pspectpr = create("Series", "pspectpr");
00767     pspectpr->addMarSystem(create("ShiftInput", "si"));
00768     pspectpr->addMarSystem(create("Windowing", "hamming"));
00769     pspectpr->addMarSystem(create("Spectrum","spk"));
00770     pspectpr->updControl("Spectrum/spk/mrs_real/cutoff", 1.0);
00771     pspectpr->addMarSystem(create("PowerSpectrum", "pspk"));
00772     pspectpr->updControl("PowerSpectrum/pspk/mrs_string/spectrumType","power");
00773     pspectpr->linkControl("Spectrum/spk/mrs_real/cutoff", "mrs_real/cutoff");
00774     pspectpr->linkControl("ShiftInput/si/mrs_natural/winSize", "mrs_natural/winSize");
00775     registerPrototype("PowerSpectrumNet", pspectpr);
00776   }
00777   break;
00778 
00779   case POWERSPECTRUMNET1:
00780   {
00781     MarSystem* pspectpr1 = create("Series", "pspectpr1");
00782     pspectpr1->addMarSystem(create("Spectrum","spk"));
00783     pspectpr1->updControl("Spectrum/spk/mrs_real/cutoff", 1.0);
00784     pspectpr1->addMarSystem(create("PowerSpectrum", "pspk"));
00785     pspectpr1->updControl("PowerSpectrum/pspk/mrs_string/spectrumType","power");
00786     pspectpr1->linkControl("Spectrum/spk/mrs_real/cutoff", "mrs_real/cutoff");
00787     registerPrototype("PowerSpectrumNet1", pspectpr1);
00788   }
00789   break;
00790 
00791   case STFT_FEATURES:
00792   {
00793     // STFT_features prototype
00794     MarSystem* stft_features_pr = create("Fanout", "stft_features_pr");
00795     stft_features_pr->addMarSystem(create("Centroid", "cntrd"));
00796     stft_features_pr->addMarSystem(create("Rolloff", "rlf"));
00797     stft_features_pr->addMarSystem(create("Flux", "flux"));
00798     stft_features_pr->addMarSystem(create("MFCC", "mfcc"));
00799 
00800     MarSystem* chromaPrSeries =  create("Series", "chromaPrSeries");
00801 
00802     chromaPrSeries->addMarSystem(create("Spectrum2Chroma", "chroma"));
00803     chromaPrSeries->addMarSystem(create("PeakRatio","pr"));
00804 
00805     stft_features_pr->addMarSystem(chromaPrSeries);
00806     stft_features_pr->addMarSystem(create("SCF", "scf"));
00807     stft_features_pr->addMarSystem(create("SFM", "sfm"));
00808     registerPrototype("STFT_features", stft_features_pr);
00809   }
00810   break;
00811 
00812   // Variables are shared, so instantiate together
00813   case LPCNET:
00814   case TIMBREFEATURES:
00815   {
00816     //--------------------------------------------------------------------------------
00817     // LPC composite prototype
00818     //--------------------------------------------------------------------------------
00819     MarSystem* LPCnetpr = new Series("lpcnetpr");
00820     // create and configure the pre-emphasis filter as a FIR:
00821     // H(z) = 1 + aZ-1 ; a = -0.97
00822     LPCnetpr->addMarSystem(create("Filter", "preEmph"));
00823     realvec ncoeffs(2);
00824     realvec dcoeffs(1);
00825     ncoeffs(0) = 1.0;
00826     ncoeffs(1) = -0.97;
00827     dcoeffs(0) = 1.0;
00828     LPCnetpr->updControl("Filter/preEmph/mrs_realvec/ncoeffs", ncoeffs);
00829     LPCnetpr->updControl("Filter/preEmph/mrs_realvec/dcoeffs", dcoeffs);
00830     LPCnetpr->addMarSystem(create("ShiftInput", "si"));
00831     LPCnetpr->addMarSystem(create("Windowing", "ham"));
00832     LPCnetpr->addMarSystem(create("LPC", "lpc"));
00833     LPCnetpr->linkControl("Filter/preEmph/mrs_realvec/ncoeffs", "mrs_realvec/preEmphFIR");
00834     LPCnetpr->linkControl("ShiftInput/si/mrs_natural/winSize","mrs_natural/winSize");
00835     LPCnetpr->linkControl("LPC/lpc/mrs_natural/order", "mrs_natural/order");
00836     LPCnetpr->linkControl("LPC/lpc/mrs_real/lambda", "mrs_real/lambda");
00837     LPCnetpr->linkControl("LPC/lpc/mrs_real/gamma", "mrs_real/gamma");
00838     registerPrototype("LPCnet", LPCnetpr);
00839 
00841     // timbre_features prototype
00843     MarSystem* timbre_features_pr = new Fanout("timbre_features_pr");
00844     // TD branch
00845     MarSystem* timeDomainFeatures = create("Series", "timeDomain");
00846     timeDomainFeatures->addMarSystem(create("ShiftInput", "si"));
00847     MarSystem* tdf = create("Fanout", "tdf");
00848     tdf->addMarSystem(create("ZeroCrossings", "zcrs"));
00849     timeDomainFeatures->addMarSystem(tdf);
00850     timbre_features_pr->addMarSystem(timeDomainFeatures);
00851     // FFT branch
00852     MarSystem* spectralShape = create("Series", "spectralShape");
00853     spectralShape->addMarSystem(create("ShiftInput", "si"));
00854     spectralShape->addMarSystem(create("Windowing", "hamming"));
00855     spectralShape->addMarSystem(create("PowerSpectrumNet1", "powerSpect1"));
00856     MarSystem* spectrumFeatures = create("STFT_features", "spectrumFeatures");
00857     spectralShape->addMarSystem(spectrumFeatures);
00858     timbre_features_pr->addMarSystem(spectralShape);
00859     // LPC branch
00860     MarSystem* lpcFeatures = create("Series", "lpcFeatures");
00861     lpcFeatures->addMarSystem(create("Filter", "preEmph"));
00862     lpcFeatures->updControl("Filter/preEmph/mrs_realvec/ncoeffs", ncoeffs);
00863     lpcFeatures->updControl("Filter/preEmph/mrs_realvec/dcoeffs", dcoeffs);
00864     lpcFeatures->addMarSystem(create("ShiftInput", "si"));
00865     lpcFeatures->addMarSystem(create("Windowing", "ham"));
00866     MarSystem* lpcf = create("Fanout", "lpcf");
00867     MarSystem* lspbranch = create("Series", "lspbranch");
00868     MarSystem* lpccbranch = create("Series","lpccbranch");
00869     lspbranch->addMarSystem(create("LPC", "lpc"));
00870     lspbranch->updControl("LPC/lpc/mrs_natural/order", 18);
00871     lspbranch->addMarSystem(create("LSP", "lsp"));
00872     lpccbranch->addMarSystem(create("LPC", "lpc"));
00873     lpccbranch->updControl("LPC/lpc/mrs_natural/order", 12);
00874     lpccbranch->addMarSystem(create("LPCC", "lpcc"));
00875     lpcf->addMarSystem(lspbranch);
00876     lpcf->addMarSystem(lpccbranch);
00877     lpcFeatures->addMarSystem(lpcf);
00878     timbre_features_pr->addMarSystem(lpcFeatures);
00879 
00880     timbre_features_pr->linkControl("Series/timeDomain/ShiftInput/si/mrs_natural/winSize", "mrs_natural/winSize");
00881     timbre_features_pr->linkControl("Series/spectralShape/ShiftInput/si/mrs_natural/winSize", "mrs_natural/winSize");
00882     timbre_features_pr->linkControl("Series/lpcFeatures/ShiftInput/si/mrs_natural/winSize", "mrs_natural/winSize");
00883 
00884     timbre_features_pr->linkControl("Series/spectralShape/STFT_features/spectrumFeatures/mrs_string/enableChild", "mrs_string/enableSPChild");
00885     timbre_features_pr->linkControl("Series/spectralShape/STFT_features/spectrumFeatures/mrs_string/disableChild","mrs_string/disableSPChild");
00886 
00887     timbre_features_pr->linkControl("Series/timeDomain/Fanout/tdf/mrs_string/enableChild", "mrs_string/enableTDChild");
00888     timbre_features_pr->linkControl("Series/timeDomain/Fanout/tdf/mrs_string/disableChild", "mrs_string/disableTDChild");
00889 
00890     timbre_features_pr->linkControl("Series/lpcFeatures/Fanout/lpcf/mrs_string/enableChild", "mrs_string/enableLPCChild");
00891     timbre_features_pr->linkControl("Series/lpcFeatures/Fanout/lpcf/mrs_string/disableChild", "mrs_string/disableLPCChild");
00892 
00893     timbre_features_pr->updControl("mrs_string/disableSPChild", "all");
00894     timbre_features_pr->updControl("mrs_string/disableTDChild", "all");
00895     timbre_features_pr->updControl("mrs_string/disableLPCChild", "all");
00896 
00897     registerPrototype("TimbreFeatures", timbre_features_pr);
00898   }
00899   break;
00900 
00901   case STEREOPANNINGSPECTRUMFEATURES:
00902   {
00904     // StereoPanningSpectrumFeatures
00906     MarSystem *stereoFeatNet = create("Series", "stereoFeatNet");
00907     MarSystem* stereobranches = create("Parallel", "stereobranches");
00908     MarSystem* left = create("Series", "left");
00909     MarSystem* right = create("Series", "right");
00910     left->addMarSystem(create("ShiftInput", "sileft"));
00911     left->addMarSystem(create("Windowing", "hamleft"));
00912     left->addMarSystem(create("Spectrum", "spkleft"));
00913     right->addMarSystem(create("ShiftInput", "siright"));
00914     right->addMarSystem(create("Windowing", "hamright"));
00915     right->addMarSystem(create("Spectrum", "spkright"));
00916 
00917     stereobranches->addMarSystem(left);
00918     stereobranches->addMarSystem(right);
00919 
00920     stereoFeatNet->addMarSystem(stereobranches);
00921     stereoFeatNet->addMarSystem(create("StereoSpectrum", "sspk"));
00922     stereoFeatNet->addMarSystem(create("StereoSpectrumFeatures", "sspkf"));
00923     registerPrototype("StereoPanningSpectrumFeatures", stereoFeatNet);
00924   }
00925   break;
00926 
00927   case STEREOFEATURES:
00928   {
00929 
00931     // combined stereo features
00933     MarSystem* stereoFeatures = create("Fanout", "stereoFeatures");
00934     MarSystem* stereoTimbreFeatures = create("Parallel", "stereoTimbreFeatures");
00935     MarSystem* featExtractorLeft = create("TimbreFeatures", "featExtractorLeft");
00936     MarSystem* featExtractorRight = create("TimbreFeatures", "featExtractorRight");
00937     stereoTimbreFeatures->addMarSystem(featExtractorLeft);
00938     stereoTimbreFeatures->addMarSystem(featExtractorRight);
00939     stereoFeatures->addMarSystem(stereoTimbreFeatures);
00940     stereoFeatures->addMarSystem(create("StereoPanningSpectrumFeatures", "SPSFeatures"));
00941 
00942     //link winSize controls
00943     stereoFeatures->linkControl("Parallel/stereoTimbreFeatures/TimbreFeatures/featExtractorLeft/mrs_natural/winSize", "mrs_natural/winSize");
00944     stereoFeatures->linkControl("Parallel/stereoTimbreFeatures/TimbreFeatures/featExtractorRight/mrs_natural/winSize", "mrs_natural/winSize");
00945     stereoFeatures->linkControl("StereoPanningSpectrumFeatures/SPSFeatures/Parallel/stereobranches/Series/left/ShiftInput/sileft/mrs_natural/winSize", "mrs_natural/winSize");
00946     stereoFeatures->linkControl("StereoPanningSpectrumFeatures/SPSFeatures/Parallel/stereobranches/Series/right/ShiftInput/siright/mrs_natural/winSize", "mrs_natural/winSize");
00947 
00948     //link enable controls
00949     stereoFeatures->linkControl("Parallel/stereoTimbreFeatures/TimbreFeatures/featExtractorLeft/mrs_string/enableSPChild", "mrs_string/enableSPChild");
00950     stereoFeatures->linkControl("Parallel/stereoTimbreFeatures/TimbreFeatures/featExtractorRight/mrs_string/enableSPChild", "mrs_string/enableSPChild");
00951 
00952     stereoFeatures->linkControl("Parallel/stereoTimbreFeatures/TimbreFeatures/featExtractorLeft/mrs_string/enableTDChild", "mrs_string/enableTDChild");
00953     stereoFeatures->linkControl("Parallel/stereoTimbreFeatures/TimbreFeatures/featExtractorRight/mrs_string/enableTDChild", "mrs_string/enableTDChild");
00954 
00955 
00956     registerPrototype("StereoFeatures", stereoFeatures);
00957   }
00958   break;
00959 
00960   case PHASEVOCODER:
00961   {
00962     //--------------------------------------------------------------------------------
00963     // Phase Vocoder composite prototype
00964     //--------------------------------------------------------------------------------
00965     MarSystem* pvocpr = new Series("pvocpr");
00966     pvocpr->addMarSystem(new ShiftInput("si"));
00967     pvocpr->addMarSystem(new PvFold("fo"));
00968     pvocpr->addMarSystem(new Spectrum("spk"));
00969     pvocpr->addMarSystem(new PvConvert("conv"));
00970     pvocpr->addMarSystem(new PvUnconvert("uconv"));
00971     pvocpr->addMarSystem(new InvSpectrum("ispectrum"));
00972     pvocpr->addMarSystem(new PvOverlapadd("pover"));
00973     pvocpr->addMarSystem(new ShiftOutput("so"));
00974 
00975     pvocpr->linkControl("ShiftInput/si/mrs_natural/winSize",
00976                         "mrs_natural/winSize");
00977     pvocpr->linkControl("PvOverlapadd/pover/mrs_natural/winSize",
00978                         "mrs_natural/winSize");
00979 
00980 
00981     pvocpr->linkControl("PvConvert/conv/mrs_natural/Decimation",
00982                         "mrs_natural/Decimation");
00983     pvocpr->linkControl("PvUnconvert/uconv/mrs_natural/Decimation",
00984                         "mrs_natural/Decimation");
00985     pvocpr->linkControl("PvOverlapadd/pover/mrs_natural/Decimation",
00986                         "mrs_natural/Decimation");
00987 
00988     pvocpr->linkControl("PvUnconvert/uconv/mrs_natural/Interpolation",
00989                         "mrs_natural/Interpolation");
00990     pvocpr->linkControl("PvOverlapadd/pover/mrs_natural/Interpolation",
00991                         "mrs_natural/Interpolation");
00992     pvocpr->linkControl("ShiftOutput/so/mrs_natural/Interpolation",
00993                         "mrs_natural/Interpolation");
00994 
00995     pvocpr->linkControl("PvFold/fo/mrs_natural/FFTSize",
00996                         "mrs_natural/FFTSize");
00997     pvocpr->linkControl("PvOverlapadd/pover/mrs_natural/FFTSize",
00998                         "mrs_natural/FFTSize");
00999 
01000     pvocpr->linkControl("PvConvert/conv/mrs_realvec/phases",
01001                         "PvUnconvert/uconv/mrs_realvec/analysisphases");
01002 
01003     pvocpr->linkControl("PvUnconvert/uconv/mrs_realvec/regions",
01004                         "PvConvert/conv/mrs_realvec/regions");
01005 
01006     pvocpr->linkControl("PvConvert/conv/mrs_natural/Sinusoids",
01007                         "mrs_natural/Sinusoids");
01008     pvocpr->linkControl("PvConvert/conv/mrs_string/mode",
01009                         "mrs_string/convertMode");
01010     pvocpr->linkControl("PvUnconvert/uconv/mrs_string/mode",
01011                         "mrs_string/unconvertMode");
01012     pvocpr->linkControl("PvUnconvert/uconv/mrs_bool/phaselock",
01013                         "mrs_bool/phaselock");
01014 
01015 
01016     pvocpr->linkControl("PvFold/fo/mrs_real/rmsIn",
01017                         "PvOverlapadd/pover/mrs_real/rmsIn");
01018 
01019 
01020     registerPrototype("PhaseVocoder", pvocpr);
01021   }
01022   break;
01023 
01024   case PHASEVOCODEROSCBANK:
01025   {
01026     MarSystem* pvocpr1 = new Series("pvocpr1");
01027     pvocpr1->addMarSystem(new ShiftInput("si"));
01028     pvocpr1->addMarSystem(new PvFold("fo"));
01029     pvocpr1->addMarSystem(new Spectrum("spk"));
01030     pvocpr1->addMarSystem(new PvConvert("conv"));
01031     pvocpr1->addMarSystem(new PvOscBank("pob"));
01032     pvocpr1->addMarSystem(new ShiftOutput("so"));
01033 
01034     pvocpr1->linkControl("ShiftInput/si/mrs_natural/winSize",
01035                          "mrs_natural/winSize");
01036 
01037     pvocpr1->linkControl("PvOscBank/pob/mrs_natural/winSize",
01038                          "mrs_natural/winSize");
01039 
01040     pvocpr1->linkControl("PvFold/fo/mrs_real/rmsIn",
01041                          "PvOscBank/pob/mrs_real/rmsIn");
01042 
01043     pvocpr1->linkControl("PvConvert/conv/mrs_natural/Decimation",
01044                          "mrs_natural/Decimation");
01045     pvocpr1->linkControl("ShiftOutput/so/mrs_natural/Interpolation",
01046                          "mrs_natural/Interpolation");
01047     pvocpr1->linkControl("PvFold/fo/mrs_natural/FFTSize",
01048                          "mrs_natural/FFTSize");
01049     pvocpr1->linkControl("PvConvert/conv/mrs_natural/Sinusoids",
01050                          "mrs_natural/Sinusoids");
01051     pvocpr1->linkControl("PvConvert/conv/mrs_string/mode",
01052                          "mrs_string/convertMode");
01053     pvocpr1->linkControl("PvOscBank/pob/mrs_natural/Interpolation",
01054                          "mrs_natural/Interpolation");
01055     pvocpr1->linkControl("PvOscBank/pob/mrs_real/PitchShift",
01056                          "mrs_real/PitchShift");
01057 
01058     pvocpr1->linkControl("PvOscBank/pob/mrs_bool/phaselock",
01059                          "mrs_bool/phaselock");
01060 
01061     pvocpr1->linkControl("PvConvert/conv/mrs_realvec/phases",
01062                          "PvOscBank/pob/mrs_realvec/analysisphases");
01063 
01064 
01065 
01066 
01067     registerPrototype("PhaseVocoderOscBank", pvocpr1);
01068   }
01069   break;
01070 
01071   // Variables are shared, so instantiate together
01072   case PITCHSACF:
01073   case PITCHPRAAT:
01074   {
01075     //--------------------------------------------------------------------------------
01076     // prototype for pitch Extraction using SACF
01077     //--------------------------------------------------------------------------------
01078     MarSystem* pitchSACF = new Series("pitchSACF");
01079     //pitchSACF->addMarSystem(create("Windowing", "wi"));
01080     pitchSACF->addMarSystem(create("AutoCorrelation", "acr"));
01081     pitchSACF->updControl("AutoCorrelation/acr/mrs_real/magcompress", .67);
01082     // pitchSACF->updControl("AutoCorrelation/acr/mrs_natural/normalize", 1);
01083     pitchSACF->addMarSystem(create("HalfWaveRectifier", "hwr"));
01084     MarSystem* fanout = create("Fanout", "fanout");
01085     fanout->addMarSystem(create("Gain", "id1"));
01086     fanout->addMarSystem(create("TimeStretch", "tsc"));
01087     pitchSACF->addMarSystem(fanout);
01088     MarSystem* fanin = create("Fanin", "fanin");
01089     fanin->addMarSystem(create("Gain", "id2"));
01090     fanin->addMarSystem(create("Negative", "nid"));
01091     pitchSACF->addMarSystem(fanin);
01092     pitchSACF->addMarSystem(create("HalfWaveRectifier", "hwr"));
01093     pitchSACF->addMarSystem(create("Peaker", "pkr"));
01094     pitchSACF->addMarSystem(create("MaxArgMax", "mxr"));
01095     // should be adapted to the sampling frequency !!
01096     pitchSACF->updControl("mrs_natural/inSamples", 512);
01097     pitchSACF->updControl("Fanout/fanout/TimeStretch/tsc/mrs_real/factor", 0.5);
01098     // pitchSACF->updControl("Windowing/wi/mrs_string/type", "Hanning");
01099     pitchSACF->updControl("Peaker/pkr/mrs_real/peakSpacing", 0.00);
01100     // pitchSACF->updControl("Peaker/pkr/mrs_natural/interpolation", 1);
01101     pitchSACF->updControl("Peaker/pkr/mrs_real/peakStrength", 0.4);
01102     pitchSACF->updControl("MaxArgMax/mxr/mrs_natural/nMaximums", 1);
01103     // pitchSACF->updControl("MaxArgMax/mxr/mrs_natural/interpolation", 1);
01104     pitchSACF->linkControl("mrs_natural/lowSamples", "Peaker/pkr/mrs_natural/peakStart");
01105     pitchSACF->linkControl("mrs_natural/highSamples", "Peaker/pkr/mrs_natural/peakEnd");
01106     // set default values
01107     mrs_real lowPitch = 69;
01108     mrs_real highPitch = 93;
01109     mrs_real lowFreq = pitch2hertz(lowPitch);
01110     mrs_real highFreq = pitch2hertz(highPitch);
01111     mrs_natural lowSamples =
01112       hertz2samples(highFreq, pitchSACF->getctrl("mrs_real/osrate")->to<mrs_real>());
01113     mrs_natural highSamples =
01114       hertz2samples(lowFreq, pitchSACF->getctrl("mrs_real/osrate")->to<mrs_real>());
01115     pitchSACF->updControl("mrs_natural/lowSamples", lowSamples);
01116     pitchSACF->updControl("mrs_natural/highSamples", highSamples);
01117     registerPrototype("PitchSACF", pitchSACF);
01118 
01119     //--------------------------------------------------------------------------------
01120     // prototype for pitch Extraction using Praat-Like implementation
01121     // see details and discussion in
01122     // http://www.fon.hum.uva.nl/paul/papers/Proceedings_1993.pdf
01123     //--------------------------------------------------------------------------------
01124     MarSystem* pitchPraat = new Series("pitchPraat");
01125     pitchPraat->addMarSystem(create("Windowing", "wi"));
01126     pitchPraat->addMarSystem(create("AutoCorrelation", "acr"));
01127     pitchPraat->updControl("AutoCorrelation/acr/mrs_natural/normalize", 1);
01128     pitchPraat->updControl("AutoCorrelation/acr/mrs_real/octaveCost", 0.0);
01129     pitchPraat->updControl("AutoCorrelation/acr/mrs_real/voicingThreshold", 0.3);
01130     pitchPraat->linkControl("mrs_real/voicingThreshold", "AutoCorrelation/acr/mrs_real/voicingThreshold");
01131     pitchPraat->addMarSystem(create("Peaker", "pkr"));
01132     pitchPraat->addMarSystem(create("MaxArgMax", "mxr"));
01133     // should be adapted to the sampling frequency !!
01134     // The window should be just long
01135     //  enough to contain three periods (for pitch detection)
01136     //  of MinimumPitch. E.g. if MinimumPitch is 75 Hz, the window length
01137     //  is 40 ms  and padded with zeros to reach a power of two.
01138     pitchPraat->updControl("mrs_natural/inSamples", 1024);
01139     pitchPraat->updControl("Windowing/wi/mrs_string/type", "Hanning");
01140     pitchPraat->updControl("Peaker/pkr/mrs_real/peakSpacing", 0.00);
01141     pitchPraat->updControl("Peaker/pkr/mrs_natural/interpolation", 1);
01142     // pitchPraat->updControl("Peaker/pkr/mrs_real/peakStrength", 0.4);
01143     pitchPraat->updControl("MaxArgMax/mxr/mrs_natural/nMaximums", 1);
01144     pitchPraat->updControl("MaxArgMax/mxr/mrs_natural/interpolation", 1);
01145     pitchPraat->linkControl("mrs_natural/lowSamples", "Peaker/pkr/mrs_natural/peakStart");
01146     pitchPraat->linkControl("mrs_natural/highSamples", "Peaker/pkr/mrs_natural/peakEnd");
01147     // set default values
01148     lowPitch = 36;
01149     highPitch = 79;
01150     lowFreq = pitch2hertz(lowPitch);
01151     highFreq = pitch2hertz(highPitch);
01152 
01153     lowSamples =
01154       hertz2samples(highFreq, pitchPraat->getctrl("mrs_real/osrate")->to<mrs_real>());
01155     highSamples =
01156       hertz2samples(lowFreq, pitchPraat->getctrl("mrs_real/osrate")->to<mrs_real>());
01157     pitchPraat->updControl("mrs_natural/lowSamples", lowSamples);
01158     pitchPraat->updControl("mrs_natural/highSamples", highSamples);
01159     registerPrototype("PitchPraat", pitchPraat);
01160   }
01161   break;
01162 
01163   case PIPE_BLOCK:
01164   {
01165     MarSystem* pipeBlock = new Series("Pipe_Block");
01166 
01167     pipeBlock->addMarSystem(create("AFB_Block_A", "blockA"));
01168 
01169     pipeBlock->addMarSystem(create("AFB_Block_B", "blockB"));
01170     pipeBlock->linkControl("mrs_natural/factor", "AFB_Block_B/blockB/mrs_natural/factor");
01171 
01172     pipeBlock->addMarSystem(create("AFB_Block_C", "blockC"));
01173 
01174     registerPrototype("Pipe_Block", pipeBlock);
01175   }
01176   break;
01177 
01178   case AFB_BLOCK_A:
01179   {
01180     MarSystem* afbBlockA = new Series("AFB_Block_A");
01181 
01182     afbBlockA->addMarSystem(create("Decimating_QMF", "qmf1"));
01183 
01184     MarSystem* parallel = create("Parallel", "parallel");
01185 
01186     parallel->addMarSystem(create("DownSampler", "ds"));
01187     parallel->updControl("DownSampler/ds/mrs_natural/factor", 2);
01188 
01189     MarSystem* ser = new Series("ser");
01190 
01191     ser->addMarSystem(create("Decimating_QMF", "qmf2"));
01192 
01193     ser->addMarSystem(create("Selector", "selector"));
01194 
01195     parallel->addMarSystem(ser);
01196 
01197     afbBlockA->addMarSystem(parallel);
01198 
01199     afbBlockA->updControl("Parallel/parallel/Series/ser/Selector/selector/mrs_natural/enable", 0); // Arian: this one is to be fed to the next pipeline
01200     afbBlockA->updControl("Parallel/parallel/Series/ser/Selector/selector/mrs_natural/disable", 1);
01201 
01202     afbBlockA->addMarSystem(create("Sum", "sum"));
01203 
01204 
01205     registerPrototype("AFB_Block_A", afbBlockA);
01206   }
01207   break;
01208 
01209   case AFB_BLOCK_B:
01210   {
01211     MarSystem* afbBlockB = new Series("AFB_Block_B");
01212 
01213     afbBlockB->addMarSystem(create("Square", "sq"));
01214     afbBlockB->addMarSystem(create("Biquad", "bq"));
01215 
01216     afbBlockB->updControl("Biquad/bq/mrs_string/type", "lowpass");
01217     afbBlockB->updControl("Biquad/bq/mrs_real/resonance", 1.0);
01218     afbBlockB->updControl("Biquad/bq/mrs_real/frequency", 10.0);
01219 
01220     afbBlockB->addMarSystem(create("DownSampler", "ds"));
01221 
01222     afbBlockB->linkControl("mrs_natural/factor", "DownSampler/ds/mrs_natural/factor");
01223 
01224     registerPrototype("AFB_Block_B", afbBlockB);
01225   }
01226   break;
01227 
01228   case AFB_BLOCK_C:
01229   {
01230     MarSystem* afbBlockC = new Series("AFB_Block_C");
01231 
01232     MarSystem* fanout = create("Fanout", "fanout");
01233 
01234 
01235     MarSystem* ser = create("Series", "ser");
01236 
01237     ser->addMarSystem(create("Compressor", "comp"));
01238     ser->addMarSystem(create("Differentiator", "diff"));
01239     ser->addMarSystem(create("HalfWaveRectifier", "rect"));
01240     ser->addMarSystem(create("Gain", "g2"));
01241 
01242     fanout->addMarSystem(create("Gain", "g1"));
01243     fanout->addMarSystem(ser);
01244 
01245     afbBlockC->addMarSystem(fanout);
01246 
01247     afbBlockC->updControl("Fanout/fanout/Series/ser/Gain/g2/mrs_real/gain", 0.8);
01248     afbBlockC->updControl("Fanout/fanout/Gain/g1/mrs_real/gain", 0.2);
01249 
01250     afbBlockC->addMarSystem(create("Sum", "sum"));
01251 
01252     afbBlockC->updControl("Sum/sum/mrs_real/weight", 1.0);
01253 
01254     registerPrototype("AFB_Block_C", afbBlockC);
01255   }
01256   break;
01257 
01258   case DECIMATING_QMF:
01259   {
01260     MarSystem* decimating_QMF = new Series("Decimating_QMF");
01261 
01262     decimating_QMF->addMarSystem(create("Gain", "g"));
01263 
01264     decimating_QMF->updControl("Gain/g/mrs_real/gain", 0.5);
01265 
01266     MarSystem* fanout0 = create("Fanout", "fanout0");
01267 
01268     MarSystem* ser0 = create("Series", "ser0");
01269     MarSystem* ser1 = create("Series", "ser1");
01270 
01271     ser0->addMarSystem(create("DownSampler", "ds0"));
01272     ser0->updControl("DownSampler/ds0/mrs_natural/factor", 2);
01273 
01274     ser0->addMarSystem(create("Biquad", "a0"));
01275     ser0->updControl("Biquad/a0/mrs_string/type", "allpass");
01276     ser0->updControl("Biquad/a0/mrs_real/frequency", 3000.0);
01277     ser0->updControl("Biquad/a0/mrs_real/resonance", 1.0);
01278 
01279     ser1->addMarSystem(create("Delay", "d"));
01280     ser1->updControl("Delay/d/mrs_natural/delaySamples", 1);
01281     ser1->updControl("Delay/d/mrs_real/feedback", 0.0); // not implemented though
01282     ser1->updControl("Delay/d/mrs_real/gain", 1.0); // not implemented though
01283 
01284     ser1->addMarSystem(create("DownSampler", "ds1"));
01285     ser1->updControl("DownSampler/ds1/mrs_natural/factor", 2);
01286 
01287     ser1->addMarSystem(create("Biquad", "a1"));
01288     ser1->updControl("Biquad/a1/mrs_string/type", "allpass");
01289     ser1->updControl("Biquad/a1/mrs_real/frequency", 500.0);
01290     ser1->updControl("Biquad/a1/mrs_real/resonance", 1.0);
01291 
01292     fanout0->addMarSystem(ser0);
01293     fanout0->addMarSystem(ser1);
01294 
01295     decimating_QMF->addMarSystem(fanout0);
01296 
01297     MarSystem* fanout1 = create("Fanout", "fanout1");
01298 
01299     fanout1->addMarSystem(create("Sum", "sum"));
01300     fanout1->addMarSystem(create("Subtract", "sub"));
01301 
01302     decimating_QMF->addMarSystem(fanout1);
01303 
01304     registerPrototype("Decimating_QMF", decimating_QMF);
01305   }
01306   break;
01307 
01308 
01309   case PEAKANALYSE:
01310   {
01311     //--------------------------------------------------------------------------------
01312     // prototype for Peak Extraction stuff
01313     //--------------------------------------------------------------------------------
01314     MarSystem* peAnalysePr = new Series("PeakAnalysePr");
01315     peAnalysePr->addMarSystem(create("ShiftInput", "si"));
01316     peAnalysePr->addMarSystem(create("Shifter", "sh"));
01317     peAnalysePr->addMarSystem(create("Windowing", "wi"));
01318     MarSystem *parallel = create("Parallel", "par");
01319     parallel->addMarSystem(create("Spectrum", "spk1"));
01320     parallel->addMarSystem(create("Spectrum", "spk2"));
01321     peAnalysePr->addMarSystem(parallel);
01322     peAnalysePr->addMarSystem(create("PeakConvert", "conv"));
01323     peAnalysePr->linkControl("mrs_natural/winSize",
01324                              "ShiftInput/si/mrs_natural/winSize");
01325     peAnalysePr->linkControl("mrs_natural/FFTSize",
01326                              "Windowing/wi/mrs_natural/size");
01327     peAnalysePr->linkControl("mrs_string/WindowType",
01328                              "Windowing/wi/mrs_string/type");
01329     peAnalysePr->linkControl("mrs_bool/zeroPhasing",
01330                              "Windowing/wi/mrs_bool/zeroPhasing");
01331     peAnalysePr->linkControl("mrs_natural/frameMaxNumPeaks",
01332                              "PeakConvert/conv/mrs_natural/frameMaxNumPeaks");
01333     //peAnalysePr->linkControl("mrs_natural/Decimation",
01334     //  "PeakConvert/conv/mrs_natural/Decimation");
01335     peAnalysePr->updControl("Shifter/sh/mrs_natural/shift", 1);
01336     registerPrototype("PeakAnalyse", peAnalysePr);
01337   }
01338   break;
01339 
01340   case WHASPNET:
01341   {
01342     //--------------------------------------------------------------------------------
01343     // prototype for WHaSp calculation
01344     //--------------------------------------------------------------------------------
01345     MarSystem* WHaSpnetpr = new Series("WHaSpnetpr");
01346     WHaSpnetpr->addMarSystem(create("PeakAnalyse", "analyse"));
01347     WHaSpnetpr->addMarSystem(create("WHaSp", "whasp"));
01348     //
01349     WHaSpnetpr->linkControl("WHaSp/whasp/mrs_natural/totalNumPeaks",
01350                             "PeakAnalyse/analyse/PeakConvert/conv/mrs_natural/totalNumPeaks");
01351     WHaSpnetpr->linkControl("WHaSp/whasp/mrs_natural/frameMaxNumPeaks",
01352                             "PeakAnalyse/analyse/PeakConvert/conv/mrs_natural/frameMaxNumPeaks");
01353     //
01354     WHaSpnetpr->linkControl("mrs_natural/frameMaxNumPeaks",
01355                             "PeakAnalyse/analyse/mrs_natural/frameMaxNumPeaks");
01356     WHaSpnetpr->updControl("mrs_natural/frameMaxNumPeaks", 20);
01357     //
01358     registerPrototype("WHaSpnet", WHaSpnetpr);
01359   }
01360   break;
01361 
01362   case STEREOFEATURES2:
01363   {
01364     //--------------------------------------------------------------------------------
01365     // prototype for Stereo Features
01366     //--------------------------------------------------------------------------------
01367     MarSystem* stereoFeats2 = new Fanout("StereoFeatures2pr");
01368     stereoFeats2->addMarSystem(create("StereoSpectrumFeatures","stereospkfeats"));
01369     stereoFeats2->addMarSystem(create("StereoSpectrumSources","stereospksources"));
01370     registerPrototype("StereoFeatures2", stereoFeats2);
01371   }
01372   break;
01373 
01374   case CLASSIFIER:
01375   {
01376     //--------------------------------------------------------------------------------
01377     // prototype for Classifier
01378     //--------------------------------------------------------------------------------
01379     MarSystem* classifierpr = create("Fanout", "Classifierpr");
01380     classifierpr->addMarSystem(create("ZeroRClassifier", "zerorcl"));
01381     classifierpr->addMarSystem(create("GaussianClassifier", "gaussiancl"));
01382     classifierpr->addMarSystem(create("SVMClassifier", "svmcl"));
01383 
01384     // Direct way with creating control
01385     classifierpr->addctrl("mrs_natural/nClasses", 1);
01386     classifierpr->addctrl("mrs_string/mode", "train");
01387     classifierpr->setctrlState("mrs_string/mode", true);
01388     classifierpr->addctrl("mrs_realvec/classProbabilities", realvec());
01389     // classifierpr->setctrlState("mrs_realvec/classProbabilities",true);
01390 
01391     classifierpr->linkControl("ZeroRClassifier/zerorcl/mrs_natural/nClasses",
01392                               "mrs_natural/nClasses");
01393     classifierpr->linkControl("GaussianClassifier/gaussiancl/mrs_natural/nClasses",
01394                               "mrs_natural/nClasses");
01395     classifierpr->linkControl("SVMClassifier/svmcl/mrs_natural/nClasses",
01396                               "mrs_natural/nClasses");
01397 
01398     classifierpr->linkControl("ZeroRClassifier/zerorcl/mrs_string/mode",
01399                               "mrs_string/mode");
01400     classifierpr->linkControl("GaussianClassifier/gaussiancl/mrs_string/mode",
01401                               "mrs_string/mode");
01402     classifierpr->linkControl("SVMClassifier/svmcl/mrs_string/mode",
01403                               "mrs_string/mode");
01404 
01405     classifierpr->linkControl("ZeroRClassifier/zerorcl/mrs_realvec/classProbabilities",
01406                               "mrs_realvec/classProbabilities");
01407     classifierpr->linkControl("GaussianClassifier/gaussiancl/mrs_realvec/classProbabilities",
01408                               "mrs_realvec/classProbabilities");
01409     classifierpr->linkControl("SVMClassifier/svmcl/mrs_realvec/classProbabilities",
01410                               "mrs_realvec/classProbabilities");
01411 
01412     classifierpr->updControl("mrs_string/disableChild", "all");
01413     registerPrototype("Classifier", classifierpr);
01414   }
01415   break;
01416 
01417   }
01418   // Future calls should not re-instantiate the prototype
01419   compositesMap_[prototype] = STUB;
01420 }
01421 
01422 MarSystemManager::~MarSystemManager()
01423 {
01424   map<mrs_string, MarSystem *>::const_iterator iter;
01425 
01426   for (iter=registry_.begin(); iter != registry_.end(); ++iter)
01427   {
01428     delete iter->second;
01429   }
01430   registry_.clear();
01431 }
01432 
01433 void
01434 MarSystemManager::registerPrototype(mrs_string type, MarSystem *marsystem)
01435 {
01436   //change type_ of composite to the user specified one
01437   marsystem->setType(type);
01438   // check and dispose old prototype
01439   std::map<std::string,MarSystem*>::iterator iter = registry_.find(type);
01440   if (iter != registry_.end())
01441   {
01442     MarSystem* m = iter->second;
01443     delete m;
01444   }
01445   //and register it
01446   registry_[type] = marsystem;
01447 }
01448 
01449 
01450 MarSystem*
01451 MarSystemManager::getPrototype(mrs_string type)
01452 {
01453   if (registry_.find(type) != registry_.end())
01454     return (MarSystem *)(registry_[type])->clone();
01455   else
01456   {
01457     MRSWARN("MarSystemManager::getPrototype: No prototype found for " + type);
01458     return NULL;
01459   }
01460 }
01461 
01462 MarSystem*
01463 MarSystemManager::create(mrs_string type, mrs_string name)
01464 {
01465 
01466   registerComposite(type);
01467 
01468   if (registry_.find(type) != registry_.end())
01469   {
01470     MarSystem* m = (MarSystem *)(registry_[type])->clone();
01471     m->setName(name);
01472     return m;
01473   }
01474   else
01475   {
01476     MRSWARN("MarSystemManager::create: No prototype found for " + type);
01477     return NULL;
01478   }
01479 }
01480 
01481 MarSystem*
01482 MarSystemManager::create(std::string marsystemname)
01483 {
01484   mrs_string::size_type loc = marsystemname.rfind("/", marsystemname.length()-1);
01485   if (loc != mrs_string::npos)
01486     return create(marsystemname.substr(0,loc),
01487                   marsystemname.substr(loc +1));
01488   else
01489     return create(marsystemname, marsystemname + "_unknown");
01490 }
01491 
01492 
01493 MarSystem*
01494 MarSystemManager::loadFromFile(std::string filename)
01495 {
01496   ifstream ifs(filename.c_str());
01497   MarSystem* net;
01498   net = getMarSystem(ifs);
01499   return net;
01500 }
01501 
01502 
01503 
01504 MarSystem*
01505 MarSystemManager::getMarSystem(istream& is, MarSystem *parent)
01506 {
01507   /* Create a MarSystem object from an input stream in .mpl format
01508    * ( this is the format created by MarSystem::put(ostream& o) )
01509    */
01510   mrs_string skipstr;
01511   mrs_string mcomposite;
01512   mrs_natural i;
01513   bool isComposite;
01514   mrs_string marSystem = "MarSystem";
01515   mrs_string marSystemComposite = "MarSystemComposite";
01516 
01517   /* first line looks like:
01518    * # marSystem(Composite)
01519    */
01520   is >> skipstr;
01521   is >> mcomposite;
01522   if (mcomposite == marSystem)
01523     isComposite = false;
01524   else if (mcomposite == marSystemComposite)
01525     isComposite = true;
01526   else
01527   {
01528     MRSERR("Unknown MarSystemType" << mcomposite);
01529     MRSERR("skipstr = " << skipstr);
01530     return 0;
01531   }
01532 
01533   /* next line looks like:
01534    * # Type = MarSystemSubclass
01535    */
01536   is >> skipstr >> skipstr >> skipstr;
01537   mrs_string mtype;
01538   is >> mtype;
01539 
01540 
01541   /* next line looks like:
01542    * # Name = mname
01543    */
01544   is >> skipstr >> skipstr >> skipstr;
01545   mrs_string mname;
01546   is >> mname;
01547 
01548   MarSystem* msys = getPrototype(mtype);
01549 
01550   if (msys == 0)
01551   {
01552     if (compositesMap_.find(mtype) == compositesMap_.end())
01553     {
01554       MRSERR("MarSystem::getMarSystem - MarSystem " << mtype << " is not yet part of Marsyas");
01555       return 0;
01556     }
01557     else
01558     {
01559       // lazy composite registration
01560       registerComposite(mtype);
01561       msys = getPrototype(mtype);
01562     }
01563   }
01564 
01565   msys->setName(mname);
01566   msys->setParent(parent);
01567 
01568   //delete all children MarSystems in a (prototype) Composite
01569   //and read and link (as possible) local controls
01570   is >> *msys;
01571 
01572   msys->update();
01573 
01574   workingSet_[msys->getName()] = msys; // add to workingSet
01575 
01576   //recreate the Composite destroyed above, relinking all
01577   //linked controls in its way
01578   if (isComposite)
01579   {
01580     /* If this is a composite system, we may have subcomponents
01581      * the number of subcomponents will be listed like this:
01582      * (blank line)
01583      * # nComponents = 3
01584      * (blank line)
01585      * Here, we read in the nComponents, then instantiate each component
01586      */
01587     is >> skipstr >> skipstr >> skipstr;
01588     mrs_natural nComponents;
01589     is >> nComponents;
01590     for (i=0; i < nComponents; ++i)
01591     {
01592       MarSystem* cmsys = getMarSystem(is, msys);
01593       if (cmsys == 0)
01594         return 0;
01595       msys->addMarSystem(cmsys);
01596     }
01597     msys->update();
01598   }
01599   return msys;
01600 }
01601 
01602 //
01603 // Added by Adam Parkin, Jul 2005, invoked by MslModel
01604 //
01605 // Returns a list of all registered prototypes
01606 //
01607 vector <mrs_string> MarSystemManager::registeredPrototypes()
01608 {
01609   vector <mrs_string> retVal;
01610 
01611   map<mrs_string, MarSystem *>::const_iterator iter;
01612 
01613   for (iter=registry_.begin(); iter != registry_.end(); ++iter)
01614   {
01615     retVal.push_back (iter->first);
01616   }
01617 
01618   return retVal;
01619 }
01620 
01621 // Added by Stuart Bray Dec 2004. invoked by MslModel
01622 map<mrs_string, MarSystem*> MarSystemManager::getWorkingSet(istream& is)
01623 {
01624   getMarSystem(is);
01625   return workingSet_;
01626 }
01627 
01628 //
01629 // Added by Adam Parkin Jul 2005, invoked by MslModel
01630 //
01631 // Takes as an argument a string, if the string corresponds
01632 // to a registered MarSystem, the function returns true,
01633 // otherwise returns false
01634 //
01635 bool MarSystemManager::isRegistered (mrs_string name)
01636 {
01637   return (registry_.find(name) != registry_.end());
01638 }