当前位置: 首页>>代码示例>>C++>>正文


C++ MarSystem::updControl方法代码示例

本文整理汇总了C++中MarSystem::updControl方法的典型用法代码示例。如果您正苦于以下问题:C++ MarSystem::updControl方法的具体用法?C++ MarSystem::updControl怎么用?C++ MarSystem::updControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MarSystem的用法示例。


在下文中一共展示了MarSystem::updControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

// please keep this at the end of all the toy_with_ functions.
// to use, copy this and paste it above, then modify as needed
void
toy_with_null(mrs_string sfname)
{
  MarSystemManager mng;

  MarSystem *net = mng.create("Series", "net");
  net->addMarSystem(mng.create("SoundFileSource", "src"));
  net->addMarSystem(mng.create("ShiftInput", "si"));
  // you probably want to add more here
  net->addMarSystem(mng.create("Spectrum", "spec"));
  net->addMarSystem(mng.create("PowerSpectrum", "pspec"));
  net->addMarSystem(mng.create("Spectrum2Chroma", "s2c"));
  net->addMarSystem(mng.create("PlotSink", "ps"));

  net->updControl("SoundFileSource/src/mrs_string/filename", sfname);
  net->updControl("mrs_natural/inSamples", 512);
  net->updControl("mrs_natural/inSamples", 1024);
  net->updControl("ShiftInput/si/mrs_natural/winSize", 512);

  while ( net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>() )
  {
    net->tick();
#if 0
    mrs_realvec v = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
    for (mrs_natural i = 0; i<v.getSize(); ++i)
    {
      printf("%.5g\t", v(i));
    }
    cout<<endl;
#endif
  }
  delete net;
}
开发者ID:sanyaade-teachings,项目名称:marsyas,代码行数:35,代码来源:wreckBeach.cpp

示例2: while

void
toy_with_spectral_single(mrs_string sfname)
{
    MarSystemManager mng;

    MarSystem *net = mng.create("Series", "net");
    net->addMarSystem(mng.create("SoundFileSource", "src"));
    net->addMarSystem(mng.create("ShiftInput", "si"));
    net->addMarSystem(mng.create("Windowing", "win"));
    net->addMarSystem(mng.create("Spectrum", "spec"));
    net->addMarSystem(mng.create("PowerSpectrum", "pspec"));
    net->updControl("SoundFileSource/src/mrs_string/filename", sfname);
    net->updControl("mrs_natural/inSamples", 1024);
    net->updControl("ShiftInput/si/mrs_natural/winSize", 1024);
    net->updControl("Windowing/win/mrs_string/type", "Hanning");

    MarSystem *fan = mng.create("Fanout", "fan");
    net->addMarSystem(fan);
    fan->addMarSystem(mng.create("SpectralFlatnessAllBands", "sfab"));

    while ( net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>() )
    {
        net->tick();
        mrs_realvec v = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
        for (mrs_natural i = 0; i<v.getSize(); ++i)
        {
            printf("%.5g\t", v(i));
        }
        cout<<endl;
    }
    delete net;
}
开发者ID:murraymeehan,项目名称:marsyas,代码行数:32,代码来源:wreckBeach.cpp

示例3: carfac_testing

void carfac_testing(string inAudioFileName)
{
  cout << "carfac_testing" << endl;
  cout << "inAudioFileName=" << inAudioFileName << endl;

  MarSystemManager mng;

  // Create the network
  MarSystem* net = mng.create("Series", "net");
  net->addMarSystem(mng.create("SoundFileSource", "src"));

  MarSystem* carfac = mng.create("CARFAC", "carfac");
  net->addMarSystem(carfac);

  net->addMarSystem(mng.create("Gain", "gain"));

  net->updControl("SoundFileSource/src/mrs_string/filename",inAudioFileName);
  net->updControl("mrs_natural/inSamples",512);

  // Just print the coefficients
  carfac->updControl("mrs_bool/printcoeffs",true);
  carfac->updControl("mrs_bool/printstate",false);
  cout << carfac->toString();

  // Just print the state
  carfac->updControl("mrs_bool/printcoeffs",false);
  carfac->updControl("mrs_bool/printstate",true);
  for (int i = 0; i < 5; i++) {
    net->tick();
    cout << "@@@@@@@@@@@@@@@@@@@@@@@@ "<< i + 1 << " @@@@@@@@@@@@@@@@@@@@@@@@" << endl;
    cout << carfac->toString();

  }
}
开发者ID:Amos-zq,项目名称:marsyas,代码行数:34,代码来源:carfac_testing.cpp

示例4: powerOfTwo

MarSystem*
TranscriberExtract::makePitchNet(const mrs_real srate, const mrs_real lowFreq, MarSystem* rvSink)
{
	mrs_real highFreq = 5000.0;

	MarSystem *net = mng.create("Series", "pitchNet");
	net->addMarSystem(mng.create("ShiftInput", "sfi"));
	net->addMarSystem(mng.create("PitchPraat", "pitch"));
	if (rvSink != NULL)
		net->addMarSystem(rvSink);

	// yes, this is the right way around (lowSamples<-highFreq)
	net->updControl("PitchPraat/pitch/mrs_natural/lowSamples",
	             hertz2samples(highFreq, srate) );
	net->updControl("PitchPraat/pitch/mrs_natural/highSamples",
	             hertz2samples(lowFreq, srate) );

	// The window should be just long enough to contain three periods
	// (for pitch detection) of MinimumPitch.
	mrs_real windowSize = 3.0/lowFreq*srate;
	net->updControl("mrs_natural/inSamples", 512);
	net->updControl("ShiftInput/sfi/mrs_natural/winSize",
	             powerOfTwo(windowSize));

	return net;
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:26,代码来源:TranscriberExtract.cpp

示例5: getFileLengthForWaveform

int getFileLengthForWaveform(string inFileName, int windowSize_, double& min, double& max) {

	MarSystemManager mng;

	// A series to contain everything
	MarSystem* net = mng.create("Series", "net");
	
	// The sound file
	net->addMarSystem(mng.create("SoundFileSource", "src"));
	net->addMarSystem(mng.create("Stereo2Mono", "s2m"));
	net->addMarSystem(mng.create("ShiftInput", "si"));
	net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);


	mrs_real srate = net->getControl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
	if ((position_ == 0) && (start_ != 0.0))
		position_ = (mrs_natural) (srate * start_);
	
	if ((ticks_ == -1) && (length_ != -1.0))
		ticks_ = (mrs_natural) ((length_ * srate) / windowSize_);
	
	net->updControl("SoundFileSource/src/mrs_natural/pos", position_);
	net->updControl("SoundFileSource/src/mrs_natural/inSamples", hopSize_);
	net->updControl("ShiftInput/si/mrs_natural/winSize", windowSize_);
	
	// Compute the AbsMax of this window
	net->addMarSystem(mng.create("AbsMax","absmax"));

	realvec processedData;

	int length = 0;

	while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>() 
		   && (ticks_ == -1 || length < ticks_))  {
		net->tick();
		length++;

		processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
		if (processedData(0) < min)
			min = processedData(0);
		if (processedData(0) > max)
			max = processedData(0);
	}


	delete net;

	if (verboseopt_) {
		cout << "length=" << length << endl;
		cout << "max=" << max << endl;
		cout << "min=" << min << endl;
	}

	return length;
}
开发者ID:murraymeehan,项目名称:marsyas,代码行数:55,代码来源:sound2png.cpp

示例6: 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;
}
开发者ID:murraymeehan,项目名称:marsyas,代码行数:54,代码来源:kea.cpp

示例7: harmonics

// ********************** start toys **********
void
toy_with_harmonicStrength(mrs_string sfname)
{
    MarSystemManager mng;

    MarSystem *net = mng.create("Series", "net");
    net->addMarSystem(mng.create("SoundFileSource", "src"));
    net->addMarSystem(mng.create("ShiftInput", "si"));
    net->addMarSystem(mng.create("Windowing", "win"));
    net->addMarSystem(mng.create("Spectrum", "spec"));
    net->addMarSystem(mng.create("PowerSpectrum", "pspec"));
    net->addMarSystem(mng.create("HarmonicStrength", "harm"));
    net->updControl("SoundFileSource/src/mrs_string/filename", sfname);
    net->updControl("mrs_natural/inSamples", 512);
    net->updControl("ShiftInput/si/mrs_natural/winSize", 1024);
    net->updControl("Windowing/win/mrs_string/type", "Hanning");

    mrs_natural num_harmonics = 30;
    realvec harmonics(num_harmonics);
    /*
    cout<<"---------------------------"<<endl;
    cout<<"Relative harmonic strengths"<<endl;
    for (mrs_natural h = 0; h<num_harmonics; ++h)
    {
    		if (h==num_harmonics-1)
    		{
    			cout<<"0.5"<<"\t";
    			harmonics(h) = 0.5;
    		}
    		else
    	{
    		cout<<h<<"\t";
    		harmonics(h) = h+1;
    	}
    }
    cout<<endl;
    */

    //net->updControl("HarmonicStrength/harm/mrs_realvec/harmonics", harmonics);
    net->updControl("HarmonicStrength/harm/mrs_natural/harmonicsSize", num_harmonics);
    net->updControl("HarmonicStrength/harm/mrs_real/harmonicsWidth", 0.0);
    net->updControl("HarmonicStrength/harm/mrs_natural/type", 1);
    net->updControl("HarmonicStrength/harm/mrs_real/base_frequency", 200.0);
    // typical value for piano strings
    net->updControl("HarmonicStrength/harm/mrs_real/inharmonicity_B", 2e-5);

    while ( net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>() )
    {
        net->tick();
        mrs_realvec v = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
        for (mrs_natural h = 0; h<num_harmonics; ++h)
        {
            //printf("%.2f\t", v(h));
            printf("%.8g\t", v(h));
        }
        cout<<endl;
    }
    delete net;
}
开发者ID:murraymeehan,项目名称:marsyas,代码行数:60,代码来源:wreckBeach.cpp

示例8:

int
main(int argc, const char **argv)
{	
    (void) argc;  // tells the compiler that we know that we're not
    (void) argv;  // using these two variables
	MRSDIAG("helloWorld.cpp - main");

	// cout << "This is probably the simplest Marsyas example code: it simply
	// generates a sine wave with a frequency of 440Hz and send it to the audio
	// card output. Simple press CTRL+C to quit." << endl;
	
	//we usualy start by creating a MarSystem manager 
	//to help us on MarSystem creation
	MarSystemManager mng;

	//create the network, which is a simple Series network with a sine wave
	//oscilator and a audio sink object to send the ausio data for playing 
	//in the sound card
	MarSystem *network = mng.create("Series", "network");
	network->addMarSystem(mng.create("SineSource", "src"));
	network->addMarSystem(mng.create("AudioSink", "dest"));
	network->addMarSystem(mng.create("SoundFileSink", "dest2"));

	//set the window (i.e. audio frame) size (in samples). Let's say, 256 samples.
	//This is done in the outmost MarSystem (i.e. the Series/network) because flow
	//controls (as is the case of inSamples) are propagated through the network.
	//Check the Marsyas documentation for mode details.
	network->updControl("mrs_natural/inSamples", 4096);
 

	//set oscilator frequency to 440Hz
	network->updControl("SineSource/src/mrs_real/frequency", 440.0);

	// set the sampling to 44100  - a safe choice in most configurations 
	network->updControl("mrs_real/israte", 44100.0);
	network->updControl("AudioSink/dest/mrs_bool/initAudio", true);
	network->updControl("SoundFileSink/dest2/mrs_string/filename", "helloworld.wav");
	

	//now it's time for ticking the network, 
	//ad aeternum (i.e. until the user quits by CTRL+C)
	while (1) 
	{
		network->tick();
	}

	//ok, this is not really necessary because we are quiting by CTRL+C, 
	//but it's a good habit anyway ;-)
	delete network;

	return(0);
}
开发者ID:abramhindle,项目名称:marsyas-fork,代码行数:52,代码来源:helloWorld.cpp

示例9: makeAmplitudeNet

MarSystem* TranscriberExtract::makeAmplitudeNet(MarSystem* rvSink)
{
	MarSystem *net = mng.create("Series", "amplitudeNet");
	net->addMarSystem(mng.create("ShiftInput", "sfiAmp"));
	net->addMarSystem(mng.create("Rms", "rms"));
	if (rvSink != NULL)
		net->addMarSystem(rvSink);

	net->updControl("mrs_natural/inSamples", 512);
	net->updControl("ShiftInput/sfiAmp/mrs_natural/winSize", 512);

	return net;
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:13,代码来源:TranscriberExtract.cpp

示例10: getNormalizingGain

realvec
TranscriberExtract::getAmpsFromAudio(const std::string audioFilename)
{
	mrs_real normalize = getNormalizingGain(audioFilename);

	MarSystem* pnet = mng.create("Series", "pnet");
	mrs_real srate;
	srate  = addFileSource(pnet, audioFilename);
	
	pnet->addMarSystem(mng.create("Gain", "normalizing"));
	pnet->updControl("Gain/normalizing/mrs_real/gain",normalize);
	MarSystem* rvSink = mng.create("RealvecSink", "rvSink");
	pnet->addMarSystem(makeAmplitudeNet(rvSink));

	while ( pnet->getctrl("mrs_bool/hasData")->to<mrs_bool>() )
		pnet->tick();

	realvec rmsList = getAmpsFromRealvecSink(rvSink);
	delete pnet;

	// normalize RMS
	rmsList -= rmsList.minval();
	mrs_real maxRms = rmsList.maxval();
	if (maxRms != 0)
		rmsList /= maxRms;
	return rmsList;
}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:27,代码来源:TranscriberExtract.cpp

示例11: 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;
}
开发者ID:Amos-zq,项目名称:marsyas,代码行数:43,代码来源:audioCompare.cpp

示例12: processedData

// Variation that outputs RMS and Flux
void 
output_rmsflux(string inFileName)
{

	MarSystemManager mng;
	MarSystem* net = mng.create("Series", "net");

	net->addMarSystem(mng.create("SoundFileSource", "src"));
	net->addMarSystem(mng.create("Stereo2Mono", "s2m"));

	// A fanout that will do both RMS and Flux calculations
	MarSystem* fanout = mng.create("Fanout","fanout");
	net->addMarSystem(fanout);

	// The branch to do the RMS
	MarSystem* rms_series = mng.create("Series","rms_series");
	rms_series->addMarSystem(mng.create("Rms", "rms"));
	fanout->addMarSystem(rms_series);

	// The branch to do the Flux
	MarSystem* flux_series = mng.create("Series","flux_series");
	flux_series->addMarSystem(mng.create("ShiftInput", "si"));
	flux_series->addMarSystem(mng.create("Windowing", "win"));
	flux_series->addMarSystem(mng.create("Spectrum","spk"));
	flux_series->addMarSystem(mng.create("PowerSpectrum", "pspk"));
	flux_series->addMarSystem(mng.create("Flux", "flux")); 
	fanout->addMarSystem(flux_series);

	// Update the controls with required values
	net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);

	realvec processedData;
	float time = 0;
	mrs_natural samples_per_tick = net->getControl("SoundFileSource/src/mrs_natural/onSamples")->to<mrs_natural>();
	mrs_real rate = net->getControl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
	mrs_real sec_per_tick = samples_per_tick / rate;
	while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()) {
		net->tick();
		processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();
		cout << time << "," << processedData(0,0) << "," << processedData(1,0) << endl;
		time += sec_per_tick;
	}

	delete net;

}
开发者ID:murraymeehan,项目名称:marsyas,代码行数:47,代码来源:sound2png.cpp

示例13: Series

void
WHaSp::createSimMatrixNet()
{
  if(HWPSnet_)
    return;

  HWPSnet_ = new Series("HWPSnet");

  //add a feat selector and
  //set the features needed for HWPS
  MarSystem* peFeatSelect = new PeakFeatureSelect("peFeatSelect");
  peFeatSelect->updControl("mrs_natural/selectedFeatures",
                           PeakFeatureSelect::pkFrequency | PeakFeatureSelect::pkSetFrequencies| PeakFeatureSelect::pkSetAmplitudes);
  HWPSnet_->addMarSystem(peFeatSelect);

  //create a similarityMatrix MarSystem that uses the HPWS metric
  SelfSimilarityMatrix* simMat = new SelfSimilarityMatrix("simMat");
  simMat->addMarSystem(new HWPS("hwps"));

  HWPSnet_->addMarSystem(simMat);

  //link totalNumPeaks control to PeakFeatureSelect
  HWPSnet_->getctrl("PeakFeatureSelect/peFeatSelect/mrs_natural/totalNumPeaks")->linkTo(ctrl_totalNumPeaks_, NOUPDATE);
  HWPSnet_->update(); //only call update to HWPSnet_ since this is being called from WHaSp::update()! -> avoid potential infinite recursion!

  //link frameMaxNumPeaks control to PeakFeatureSelect
  HWPSnet_->getctrl("PeakFeatureSelect/peFeatSelect/mrs_natural/frameMaxNumPeaks")->linkTo(ctrl_frameMaxNumPeaks_, NOUPDATE);
  HWPSnet_->update(); //only call update to HWPSnet_ since this is being called from WHaSp::update()! -> avoid potential infinite recursion!

  //link histSize control to HWPS metric
  HWPSnet_->getctrl("SelfSimilarityMatrix/simMat/HWPS/hwps/mrs_natural/histSize")->linkTo(ctrl_histSize_, NOUPDATE);
  HWPSnet_->update(); //only call update to HWPSnet_ since this is being called from WHaSp::update()! -> avoid potential infinite recursion!

  HWPSnet_->setctrl("SelfSimilarityMatrix/simMat/HWPS/hwps/mrs_natural/histSize", 20);
  HWPSnet_->update(); //only call update to HWPSnet_ since this is being called from WHaSp::update()! -> avoid potential infinite recursion!

  HWPSnet_->updControl("SelfSimilarityMatrix/simMat/HWPS/hwps/mrs_bool/calcDistance", true);

  //HWPSnet_->setctrl("SelfSimilarityMatrix/simMat/HWPS/hwps/mrs_natural/histSize", 100);
  HWPSnet_->update(); //only call update to HWPSnet_ since this is being called from WHaSp::update()! -> avoid potential infinite recursion!

}
开发者ID:sanyaade-teachings,项目名称:marsyas,代码行数:42,代码来源:WHaSp.cpp

示例14: record

void record(mrs_real length, mrs_real gain, string filename) 
{
    MarSystemManager mng;

    MarSystem* recordNet = mng.create("Series", "recordNet");
    MarSystem* asrc = mng.create("AudioSource", "asrc");
    MarSystem* dest = mng.create("SoundFileSink", "dest");

    recordNet->addMarSystem(asrc);
    recordNet->addMarSystem(dest);

    recordNet->updControl("mrs_natural/inSamples", 4096);
    recordNet->updControl("mrs_real/israte", sropt);
    recordNet->updControl("AudioSource/asrc/mrs_natural/nChannels", copt);
    recordNet->updControl("AudioSource/asrc/mrs_real/gain", gain);

    // Ready to initialize audio device 
    recordNet->updControl("AudioSource/asrc/mrs_bool/initAudio", true);

    recordNet->updControl("SoundFileSink/dest/mrs_string/filename", filename);

    mrs_real srate = recordNet->getctrl("mrs_real/israte")->to<mrs_real>();
    mrs_natural nChannels = recordNet->getctrl("AudioSource/asrc/mrs_natural/nChannels")->to<mrs_natural>();
    cout << "AudioSource srate =  " << srate << endl; 
    cout << "AudioSource nChannels = " << nChannels << endl;
    mrs_natural inSamples = recordNet->getctrl("mrs_natural/inSamples")->to<mrs_natural>();


    mrs_natural iterations = (mrs_natural)((srate * length) / inSamples);

    cout << "Iterations = " << iterations << endl;


    for (mrs_natural t = 0; t < iterations; t++) 
    {
        recordNet->tick();
    }




}
开发者ID:GanAlps,项目名称:Extracting-Features-from-audio,代码行数:42,代码来源:record.cpp

示例15: fftHistogram

void fftHistogram(string inFileName)
{
	double fftBins = windowSize_ / 2.0 + 1;  // N/2 + 1

	MarSystemManager mng;
	MarSystem* net = mng.create("Series", "net");
	net->addMarSystem(mng.create("SoundFileSource", "src"));
	net->addMarSystem(mng.create("Stereo2Mono", "s2m"));
	net->addMarSystem(mng.create("ShiftInput", "si"));
	net->addMarSystem(mng.create("Spectrum","spk"));
	net->addMarSystem(mng.create("PowerSpectrum","pspk"));
	net->updControl("PowerSpectrum/pspk/mrs_string/spectrumType", "decibels");
	net->updControl("SoundFileSource/src/mrs_string/filename", inFileName);
	net->updControl("SoundFileSource/src/mrs_natural/pos", position_);
	net->updControl("SoundFileSource/src/mrs_natural/inSamples", hopSize_);
	net->updControl("ShiftInput/si/mrs_natural/winSize", windowSize_);
	net->updControl("mrs_natural/inSamples", int(hopSize_));

	mrs_real frequency = net->getctrl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>();
	double pngHeight = fftBins * (highFreq_ / (frequency / 2.0));
	realvec processedData;

	// Iterate over the whole input file by ticking, outputting columns
	// of data to the .png file with each tick
	double x = 0;
	while (net->getctrl("SoundFileSource/src/mrs_bool/hasData")->to<mrs_bool>()
		   && (ticks_ == -1 || x < ticks_))  {
		net->tick();
		processedData = net->getctrl("mrs_realvec/processedData")->to<mrs_realvec>();

		for (int i = 0; i < pngHeight; ++i) {
			double data_y = i;

			double data = processedData(int(data_y),0);

			cout << "data=" << data << endl;
		}
		x++;
	}

	delete net;
}
开发者ID:murraymeehan,项目名称:marsyas,代码行数:42,代码来源:sound2png.cpp


注:本文中的MarSystem::updControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。